Exemplo n.º 1
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());
            }
        }
Exemplo n.º 2
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);
        }