예제 #1
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            _propertySettingsPrefabsPath.stringValue = UViewEditorUtils.LayoutPathSelector(_propertySettingsPrefabsPath.stringValue, "Default Prefabs Path");

            if (!UViewEditorUtils.ValidateResourcePath(_propertySettingsPrefabsPath.stringValue))
            {
                EditorGUILayout.HelpBox(string.Format("Prefabs should be stored in a '{0}' folder", UViewEditorUtils.kResources), MessageType.Error);
            }

            _propertySettingsScriptsPath.stringValue = UViewEditorUtils.LayoutPathSelector(_propertySettingsScriptsPath.stringValue, "Default Scripts Path");

            EditorGUILayout.PropertyField(_propertySettingsScriptTemplate);
            EditorGUILayout.PropertyField(_propertySettingsPrefabTemplate);

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Reset to Defaults", GUILayout.Width(120)))
            {
                _settings.RestoreDefaults();
            }

            EditorGUILayout.EndHorizontal();

            serializedObject.ApplyModifiedProperties();
        }
예제 #2
0
        public void OnGUI()
        {
            bool error = false;

            EditorGUILayout.Space();

            _createViewName = EditorGUILayout.TextField("View Name", _createViewName);

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            _prefabPath = UViewEditorUtils.LayoutPathSelector(_prefabPath, "Prefab Path");
            if (!UViewEditorUtils.ValidateResourcePath(_prefabPath))
            {
                error = true;
                EditorGUILayout.HelpBox(string.Format("Prefabs should be stored in a '{0}' folder", UViewEditorUtils.kResources), MessageType.Error);
            }

            _scriptPath = UViewEditorUtils.LayoutPathSelector(_scriptPath, "Script Path");

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Reset Paths", EditorStyles.miniButton))
            {
                _scriptPath = _settings.scriptsPath;
                _prefabPath = _settings.prefabsPath;
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);

            string pathViewName = string.IsNullOrEmpty(_createViewName) ? "{VIEW_NAME}" : _createViewName;

            EditorGUILayout.LabelField(CreatePath(pathViewName, _prefabPath, "prefab"));
            EditorGUILayout.LabelField(CreatePath(pathViewName, _scriptPath, "cs"));

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical();
            GUILayout.FlexibleSpace();

            EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(_createViewName) || error);
            if (GUILayout.Button("Create"))
            {
                CreateView(_createViewName, _prefabPath, _scriptPath);
                Close();
            }
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();
        }