- Home /
Is there any reason why I can't use 2 c# scripts on my Player?
I am still learning my way around Unity3D using the 2D feature.
I created 2 c# scripts that I need to link to my character but apparently only one is able to get linked. I tried to remove the script component and re add it but i have the same problem. ( the checkbox next to the 2nd script never shows)
Do I have to do something in order to link 2 scripts to my player? Thanks a lot!
Hello,
what kind of scripts are you trying to add? do you have any messages from unity?
No messages from unity.. $$anonymous$$ove commands like RigidBody 2D
$$anonymous$$ay we see those scripts? (are they Player.cs and CharacterControler2D.cs ?)
Answer by darthtelle · Jul 09, 2014 at 10:04 AM
The checkbox next to the name of the script actually refers to whether your script is enabled or disabled. The only way to enable/disable your script is if you have an Update() function inside the class. The script is still there without a tick or being enabled, it just won't actually run any Update functions.
I believe it's actually any $$anonymous$$onoBehaviour function, my mistake, it is neither just Update, nor Start. It could be examples such as FixedUpdate, Awake, etc. Because I have many, many scripts where I don't use Start and I still have a checkbox associated with that script in the editor. However, there is $$anonymous$$onoBehaviour functions inside the class.
I do have a public void Awake() function but the checkbox fails to appear unless I add a void Update () in the source.
Yes you atcually need one of the initialisation functions to display the check box. Did not know that :p
It seems to be that if you want the tick to show you need to have any $$anonymous$$onoBehaviour except Awake.
This is probably due to the nature of those methods. Awake is called on loading while the others are constantely checked each frame for a call (even Start, only it is not called again after first round).
Is this something that changed from 4.5? I am using 4.5.1 and someone using 4.5 has that checkbox only with Awake function.
Answer by Kiwasi · Jul 09, 2014 at 11:12 AM
I average about five on each GameObject. The only requirement to attach a script is that is inherits from MonoBehaviour. You can also only add one copy of each script to a GameObject.
Answer by MandN · Jul 16, 2014 at 07:35 PM
I managed to fix the problem. I was a simple "s" missing. God damn.. Thanks guys!