2021
04-27
04-27
Unity 静态变量跨场景操作
创建两个场景同时赋值StaticVarious脚本然后按键好,H,J进行不断切换场景,会发现unity控制台输出数字不断增加,然后把静态去掉,这样结果都是10。usingUnityEngine;usingSystem.Collections;usingUnityEngine.SceneManagement;publicclassStaticVarious:MonoBehaviour{staticintvalue=10;voidStart(){Debug.Log(value++);}publicvoidUpdate(){if(Input.GetKeyDown(Ke...
继续阅读 >