Exemple #1
0
        private static void AddTempleteUI(EPrefabType prefabType, string prefabName)
        {
            string prefabPath    = prefabType.isNestPrefab() ? EditorPath.NestUIAssetPath : EditorPath.TempleteUIAssetPath;
            string path          = EditorPath.Combine(EditorPath.ProjectPathStart, prefabPath);
            string prefabWithExt = Tool.GetNameWithExtension(prefabName, EditorConst.PrefabExtension);

            m_dicPrefabPath.Add(prefabType, EditorPath.Combine(path, prefabWithExt));
        }
Exemple #2
0
 public static string GetPrefabPath(EPrefabType prefabType)
 {
     if (!m_dicPrefabPath.ContainsKey(prefabType))
     {
         Debug.LogError("Prefab path is not add in Model Class");
         return(string.Empty);
     }
     return(m_dicPrefabPath[prefabType]);
 }
Exemple #3
0
        static Model()
        {
            Array prefabTypes = Enum.GetValues(typeof(EPrefabType));

            m_dicPrefabPath = new Dictionary <EPrefabType, string>(prefabTypes.Length);
            for (int index = 0; index < prefabTypes.Length; index++)
            {
                EPrefabType prefabType = (EPrefabType)prefabTypes.GetValue(index);
                AddTempleteUI(prefabType, prefabType.ToString());
            }
        }
Exemple #4
0
 public static void OpenFullWindow(EPrefabType prefabType)
 {
     if (m_lastWindow != null)
     {
         Selection.activeGameObject = m_lastWindow;
     }
     else
     {
         m_lastWindow = AddGameObject(prefabType);
     }
 }
Exemple #5
0
 public static bool isNestPrefab(this EPrefabType type)
 {
     for (ushort index = 0; index < m_arrayNestPrefab.Length; index++)
     {
         if (type == m_arrayNestPrefab[index])
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #6
0
        private static GameObject AddPrefabGameObject(EPrefabType prefabType, bool isConnect)
        {
            string path = Model.GetPrefabPath(prefabType);

            if (string.IsNullOrEmpty(path))
            {
                return(null);
            }
            GameObject gameObject = AssetDatabase.LoadAssetAtPath <GameObject>(path);

            if (gameObject == null)
            {
                Debug.LogError("Load prefab is null. path = " + path);
                return(null);
            }
            Transform parent;

            if (prefabType == EPrefabType.FullScreenWindow || prefabType == EPrefabType.Window)
            {
                parent = m_windowParent;
            }
            else
            {
                parent = Selection.activeTransform;
            }
            if (isConnect)
            {
                gameObject = PrefabUtility.InstantiatePrefab(gameObject, parent) as GameObject;
            }
            else
            {
                gameObject = Object.Instantiate(gameObject, parent);
            }
            gameObject.name            = prefabType.ToString();
            Selection.activeGameObject = gameObject;
            Normalize(gameObject);
            return(gameObject);
        }
Exemple #7
0
 public static GameObject AddPrefabGameObject(EPrefabType prefabType)
 {
     return(AddPrefabGameObject(prefabType, true));
 }