private void ClosedViewButtons(string viewName) { if (_renamingView != "" && _renamingView != viewName) { GUI.enabled = false; } else { GUI.enabled = true; } if (_renamingView == viewName) { _tempViewName = GUILayout.TextArea(_tempViewName); } else { GUILayout.Label(viewName, EditorStyles.boldLabel); } if (IsViewBeingEdited(viewName)) { GUI.enabled = false; } if (GUILayout.Button("Open", GUILayout.Width(100))) { GameObject obj = PrefabUtility.InstantiatePrefab(Resources.Load(_scaffoldingConfig.ViewPrefabPath() + viewName)) as GameObject; #if UNITY_4_6 obj.transform.SetParent(_scaffoldingConfig.DetermineParentGameObjectPath().transform); #else obj.transform.parent = _scaffoldingConfig.DetermineParentGameObjectPath().transform; #endif Selection.activeObject = obj; } GUI.enabled = true; if (IsViewBeingEdited(viewName)) { if (GUILayout.Button("Done", GUILayout.Width(60))) { _renamingView = ""; string oldNamePrefab = _scaffoldingConfig.FullViewPrefabPath() + viewName; string oldNameScript = _scaffoldingConfig.ScriptsPath() + viewName; string newNamePrefab = _scaffoldingConfig.FullViewPrefabPath() + _tempViewName; string newNameScript = _scaffoldingConfig.ScriptsPath() + _tempViewName; AssetDatabase.MoveAsset(oldNamePrefab + ".prefab", newNamePrefab + ".prefab"); RenameFile(oldNameScript + ".cs", viewName, _tempViewName); AssetDatabase.MoveAsset(oldNameScript + ".cs", newNameScript + ".cs"); AssetDatabase.MoveAsset(oldNamePrefab + "Model.prefab", newNamePrefab + "Model.prefab"); RenameFile(oldNameScript + "Model.cs", viewName, _tempViewName); AssetDatabase.MoveAsset(oldNameScript + "Model.cs", newNameScript + "Model.cs"); AssetDatabase.Refresh(); CreateAllViews(); } } else { if (_renamingView != "" && _renamingView != viewName) { GUI.enabled = false; } if (GUILayout.Button("Rename", GUILayout.Width(60))) { _renamingView = viewName; _tempViewName = viewName; } } if (_renamingView != "" && _renamingView != viewName || IsViewBeingEdited(viewName)) { GUI.enabled = false; } if (GUILayout.Button("Delete", GUILayout.Width(50))) { if (EditorUtility.DisplayDialog("Delete " + viewName + " from your project?", "Deleting this view will permenantly remove it from your project, are you sure?", "Yes", "No")) { string name = viewName + "Model"; GameObject go = GameObject.Find(name); DestroyImmediate(go); AssetDatabase.DeleteAsset(_scaffoldingConfig.FullViewPrefabPath() + viewName + ".prefab"); AssetDatabase.DeleteAsset(_scaffoldingConfig.ScriptsPath() + viewName + ".cs"); AssetDatabase.DeleteAsset(_scaffoldingConfig.FullViewPrefabPath() + viewName + "Model.prefab"); AssetDatabase.DeleteAsset(_scaffoldingConfig.ScriptsPath() + viewName + "Model.cs"); AssetDatabase.Refresh(); } } }
private static string TargetPath() { return(_scaffoldingConfig.ScriptsPath() + _fileName + ".cs"); }