void OnEnable() { if (Application.isPlaying) { CreateContainer(); if (!string.IsNullOrEmpty(packagePath) && UIPackage.GetByName(packageName) == null) { UIPackage.AddPackage(packagePath); } } else { //不在播放状态时我们不在OnEnable创建,因为Prefab也会调用OnEnable,延迟到Update里创建(Prefab不调用Update) //每次播放前都会disable/enable一次。。。 if (container != null) //如果不为null,可能是因为Prefab revert, 而不是因为Assembly reload, { OnDestroy(); } EMRenderSupport.Add(this); screenSizeVer = 0; uiBounds.position = position; uiBounds.size = cachedUISize; if (uiBounds.size == Vector2.zero) { uiBounds.size = new Vector2(30, 30); } } }
void OnEnable() { if (Application.isPlaying) { CreateContainer(); if (!string.IsNullOrEmpty(packagePath) && UIPackage.GetByName(packageName) == null) { UIPackage.AddPackage(packagePath); } } else { EMRenderSupport.Add(this); } }
void OnEnable() { if (Application.isPlaying) { if (this.container == null) { CreateContainer(); if (!string.IsNullOrEmpty(packagePath) && UIPackage.GetByName(packageName) == null) { UIPackage.AddPackage(packagePath, (string name, string extension, System.Type type) => { #if UNITY_EDITOR return(UnityEditor.AssetDatabase.LoadAssetAtPath(name + extension, type)); #else return(null); #endif }); if (dependPkgPath != "") { string[] paths = dependPkgPath.Split(';'); for (int i = 0; i < paths.Length; ++i) { string path = string.Format("assets/abasset/ui/package/&{0}/{1}", paths[i], paths[i]); UIPackage.AddPackage(path, (string name, string extension, System.Type type) => { #if UNITY_EDITOR return(UnityEditor.AssetDatabase.LoadAssetAtPath(name + extension, type)); #else return(null); #endif }); } } } } else { this.container._disabled = false; } } else { //不在播放状态时我们不在OnEnable创建,因为Prefab也会调用OnEnable,延迟到Update里创建(Prefab不调用Update) //每次播放前都会disable/enable一次。。。 if (container != null) //如果不为null,可能是因为Prefab revert, 而不是因为Assembly reload, { OnDestroy(); } EMRenderSupport.Add(this); screenSizeVer = 0; uiBounds.position = position; uiBounds.size = cachedUISize; if (uiBounds.size == Vector2.zero) { uiBounds.size = new Vector2(30, 30); } } }