We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
图中在其他mono脚本里调用继承了PersistentMonoSingleton的脚本时 该脚本的Awake方法还没执行,这时候从场景上FindObjectOfType得到instance 等到了该脚本Awake方法执行时 mInstance == null 导致DontDestroyOnLoad方法不会被执行 是不是把 DontDestroyOnLoad(transform.gameObject); 这句从if里提出来比较好?
protected virtual void Awake() { if (!Application.isPlaying) { return; } if (mInstance == null) { mInstance = this as T; DontDestroyOnLoad(transform.gameObject); mEnabled = true; } else { if (this != mInstance) { Destroy(this.gameObject); } } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
图中在其他mono脚本里调用继承了PersistentMonoSingleton的脚本时 该脚本的Awake方法还没执行,这时候从场景上FindObjectOfType得到instance
等到了该脚本Awake方法执行时 mInstance == null 导致DontDestroyOnLoad方法不会被执行 是不是把 DontDestroyOnLoad(transform.gameObject); 这句从if里提出来比较好?
The text was updated successfully, but these errors were encountered: