Пример #1
0
 public override void OnInspectorGUI()
 {
     if (GUILayout.Button("Open Character Editor"))
     {
         CharacterEditorWindow window = CharacterEditorWindow.ShowWindow();
         window.Target = target as CharacterEditorData;
     }
 }
        private void OnWizardCreate()
        {
            // Check if the character data already exists
            if (AssetDatabase.IsValidFolder(data.RootFolder))
            {
                bool result = EditorUtility.DisplayDialog("Error",
                                                          "A character with the internal name of \"" + data.InternalName +
                                                          "\" already exists. Either edit the existing Character, or delete and restart.",
                                                          "Delete",
                                                          "Cancel");
                if (result)
                {
                    AssetDatabase.DeleteAsset(data.RootFolder);
                }
                else
                {
                    return;
                }
            }

            data.Generate();

            GameObject prefabSource;

            if (_sourceObject == null)
            {
                prefabSource = new GameObject(data.InternalName);
            }
            else
            {
                prefabSource = _sourceObject.gameObject;
            }

            prefabSource.GetOrAddComponent <Character>().InternalName = data.InternalName;

            Object prefab = prefabSource.GetPrefab();

            if (prefab == null)
            {
                prefab = PrefabUtil.CreatePrefab(data.RootFolder, prefabSource);
            }
            else
            {
                AssetUtil.MoveAsset(data.RootFolder, prefab);
            }

            data.Prefab = prefab as GameObject;

            Selection.activeGameObject = prefabSource;

            CharacterEditorWindow.ShowWindow().Target = data;
        }