Ejemplo n.º 1
0
 public static void Destroy(string name)
 {
     if (PanelManager._panelDict.ContainsKey(name))
     {
         GameObject gameObject = PanelManager._panelDict[name];
         if (gameObject != null)
         {
             PanelManager.Destroy(gameObject);
         }
         AssetManager.ReleaseProgramAsset(PanelManager.GetPanelAssetAssetInfo(name));
         PanelManager._panelDict.Remove(name);
     }
 }
Ejemplo n.º 2
0
        public static void OnGetGameObject(GameObject go, Action <int> callback)
        {
            go.name = go.name.Replace("_copy(Clone)", string.Empty);
            string    name      = go.name;
            Transform transform = null;

            if (PanelManager._panelDict.ContainsKey(name))
            {
                string text = "已经存在同名面板。 " + name;
                Logger.LogError(text);
                Pandora.Instance.ReportError(text, 0);
                AssetManager.ReleaseProgramAsset(PanelManager.GetPanelAssetAssetInfo(name));
                PanelManager.Destroy(go);
                callback(-3);
                return;
            }
            if (PanelManager._panelParentDict.ContainsKey(name))
            {
                if (PanelManager._panelParentDict[name] == null)
                {
                    string text2 = "面板配置的父节点已经不存在: " + name;
                    Logger.LogError(text2);
                    Pandora.Instance.ReportError(text2, 0);
                    AssetManager.ReleaseProgramAsset(PanelManager.GetPanelAssetAssetInfo(name));
                    PanelManager.Destroy(go);
                    callback(-2);
                    return;
                }
                transform = PanelManager._panelParentDict[name].transform;
            }
            if (transform == null)
            {
                transform = Pandora.Instance.GetGameObject().transform;
            }
            go.transform.SetParent(transform);
            go.transform.localPosition = Vector3.zero;
            go.transform.localScale    = Vector3.one;
            go.transform.localRotation = Quaternion.identity;
            go.SetActive(true);
            PanelManager._panelDict.Add(name, go);
            callback(0);
        }