[英]Script Reference in Unity
I'm creating a game that have multiples references to scripts, one to another. 我正在创建一个具有多个脚本引用的游戏。
For exemple: 举个例子:
My doubt enter when I can do two different things: 当我可以做两种不同的事情时,我的怀疑就进入了:
Which one is better? 哪一个更好?
In the Scripts that you will only have one of you can set a public static variable in that class with a public get and private set. 在只有一个脚本的脚本中,可以使用公共get和private集在该类中设置公共静态变量。 On the Start or Awake function you set that variable to this and then you can access that script easily from any other scripts.
在“启动”或“唤醒”功能上,将该变量设置为此,然后可以从任何其他脚本轻松访问该脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.