public void OnDestroy() { instance = null; if (_uiTexture.mainTexture != null) { _uiTexture.mainTexture = null; } // 强制释放从Resources加载的资源,否则会常驻内存 if (_uiAtlas != null) { Resources.UnloadAsset(_uiAtlas.texture); Resources.UnloadAsset(_uiAtlas.spriteMaterial); _uiAtlas = null; } }
public void Awake() { instance = this; WarningScreen = transform.Find("WarningScreen").gameObject; QualityControlLabel = WarningScreen.GetComponent <UILabel>("QualityControlLabel"); SplashScreen = transform.Find("SplashScreen").gameObject; SplashLabel = SplashScreen.transform.Find("SplashLabel").GetComponent <UILabel>(); VersionLabel = SplashScreen.transform.Find("DistributeAnchor/Layout/FullVersion").GetComponent <UILabel>(); SplashProgressBar = SplashScreen.transform.Find("ProgressBar").GetComponent <UIProgressBar>(); DownloadDialogue = transform.Find("DialogueScreen").GetComponent <LTDownloadDialogueController>(); SplashProgressBar.value = 0; _uiTexture = SplashScreen.GetComponent <UITexture>("Panel/Texture"); _fxComponent = SplashScreen.FindEx("Panel/Texture/FX"); _uiAtlas = WarningScreen.GetComponent <UISprite>().atlas; }