Template object and script,GameObject scripts duplicated from a template game object
Hi all,
I created a template game object with all required components and accompanying script. The intention is to re-use this object for different instances throughout the game, each instance with different values for the object's attributes.
When trying this out with 2 instances, the script seems to carry over to both objects. Inside the script I use GameObject.Find and GameObject.FindWithTag to get relevant Text components to update but these seem to go cross-instance. When I declare the variables public and assign objects through the editor, things work as expected.
What am I doing wrong?
Thanks in advance and kind regards! ,Hi,
I created a gameObject with all components and associated script to which I intend to duplicate in my project (attributes will be different, behaviour based on attributes is the same). I noticed that when trying the code, the scripts on 2 instances of this template seem to interfere with eachother.
In the template script I use GameObject.Find() or GameObject.FindByTag() to get certain components to work with inside the script but those seem to find components from other instances of the template. If I instead create public variables for these objects and assign them through the editor, things run correctly. This is however a bigger burden on maintenance through the editor.
What is the cause?
Thanks in advance!