Beispiel #1
0
		public override void OnInspectorGUI()
		{
			serializedObject.Update();
			GUI.enabled = false;
			script = EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false) as MonoScript;
			GUI.enabled = true;

			EditorGUILayout.Space();
			EditorGUILayout.LabelField("Visualizers");
			var facs = serializedObject.FindProperty("Visualizers");
			for (int i = 0; i < facs.arraySize; i++)
			{
				var ind = i;
				EditorGUILayout.BeginHorizontal();

				EditorGUILayout.BeginVertical();
				GUILayout.Space(5);
				EditorGUILayout.BeginHorizontal();
				if (_factory.Visualizers[i] != null)
				{
					_factory.Visualizers[i].Key = EditorGUILayout.TextField(_factory.Visualizers[i].Key, GUILayout.MaxWidth(100));
				}
				//facs.GetArrayElementAtIndex(ind).objectReferenceValue = EditorGUILayout.ObjectField(facs.GetArrayElementAtIndex(i).objectReferenceValue, typeof(LayerVisualizerBase)) as ScriptableObject;
				if (_factory.Visualizers[i] == null)
					EditorGUILayout.TextField("null");
				else
					EditorGUILayout.ObjectField(_factory.Visualizers[i], typeof(LayerVisualizerBase), false);
				EditorGUILayout.EndHorizontal();
				EditorGUILayout.EndVertical();

				if (GUILayout.Button(NodeBasedEditor.magnifierTexture, (GUIStyle)"minibuttonleft", GUILayout.Width(30)))
				{
					ScriptableCreatorWindow.Open(typeof(LayerVisualizerBase), facs, ind);
				}
				if (GUILayout.Button(new GUIContent("-"), (GUIStyle)"minibuttonright", GUILayout.Width(30), GUILayout.Height(22)))
				{
					facs.DeleteArrayElementAtIndex(ind);
				}
				EditorGUILayout.EndHorizontal();
			}

			EditorGUILayout.Space();
			EditorGUILayout.BeginHorizontal();
			if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle)"minibuttonleft"))
			{
				facs.arraySize++;
				facs.GetArrayElementAtIndex(facs.arraySize - 1).objectReferenceValue = null;
			}
			if (GUILayout.Button(new GUIContent("Find Asset"), (GUIStyle)"minibuttonright"))
			{
				ScriptableCreatorWindow.Open(typeof(LayerVisualizerBase), facs);
			}
			EditorGUILayout.EndHorizontal();
			
			serializedObject.ApplyModifiedProperties();
		}
        public override void OnInspectorGUI()
        {
            if (_factory == null)
            {
                return;
            }

            serializedObject.Update();

            GUI.enabled = false;
            script      = EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false) as MonoScript;
            GUI.enabled = true;

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(mapId_Prop, new GUIContent("Map Id"));
            if (GUILayout.Button("R", GUILayout.Width(30)))
            {
                mapId_Prop.stringValue = _defaultMapId;
                GUI.FocusControl(null);
                Repaint();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(style_Prop, new GUIContent("Optimized Style"));

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

            EditorGUILayout.LabelField("Visualizers");
            var facs = serializedObject.FindProperty("Visualizers");

            for (int i = 0; i < facs.arraySize; i++)
            {
                var ind = i;
                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.BeginVertical();
                GUILayout.Space(5);
                GUI.enabled = false;
                EditorGUILayout.BeginHorizontal();
                if (_factory.Visualizers[i] != null)
                {
                    _factory.Visualizers[i].Key = EditorGUILayout.TextField(_factory.Visualizers[i].Key, GUILayout.MaxWidth(100));
                }
                //facs.GetArrayElementAtIndex(ind).objectReferenceValue = EditorGUILayout.ObjectField(facs.GetArrayElementAtIndex(i).objectReferenceValue, typeof(LayerVisualizerBase)) as ScriptableObject;
                if (_factory.Visualizers[i] == null)
                {
                    EditorGUILayout.TextField("null");
                }
                else
                {
                    EditorGUILayout.ObjectField(_factory.Visualizers[i], typeof(LayerVisualizerBase), false);
                }
                EditorGUILayout.EndHorizontal();
                GUI.enabled = true;
                EditorGUILayout.EndVertical();

                if (GUILayout.Button(NodeBasedEditor.magnifierTexture, (GUIStyle)"minibuttonleft", GUILayout.Width(30)))
                {
                    ScriptableCreatorWindow.Open(typeof(LayerVisualizerBase), facs, ind);
                }
                if (GUILayout.Button(new GUIContent("-"), (GUIStyle)"minibuttonright", GUILayout.Width(30), GUILayout.Height(22)))
                {
                    facs.DeleteArrayElementAtIndex(ind);
                }
                EditorGUILayout.EndHorizontal();
            }

            if (GUILayout.Button(new GUIContent("Add New")))
            {
                ScriptableCreatorWindow.Open(typeof(LayerVisualizerBase), facs);
            }
            EditorUtility.SetDirty(_factory);
            serializedObject.ApplyModifiedProperties();
        }
Beispiel #3
0
        private void DrawMeshModifiers(SerializedProperty property)
        {
            EditorGUILayout.BeginVertical();
            EditorGUILayout.LabelField(new GUIContent
            {
                text    = "Mesh Modifiers",
                tooltip = "Modifiers that manipulate the features mesh. "
            });

            var meshfac = property.FindPropertyRelative("MeshModifiers");

            for (int i = 0; i < meshfac.arraySize; i++)
            {
                var ind = i;
                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.BeginVertical();
                meshfac.GetArrayElementAtIndex(ind).objectReferenceValue =
                    EditorGUILayout.ObjectField(meshfac.GetArrayElementAtIndex(i).objectReferenceValue, typeof(MeshModifier), false)
                    as ScriptableObject;

                EditorGUILayout.EndVertical();

                if (GUILayout.Button(new GUIContent("x"), (GUIStyle)"minibuttonright", GUILayout.Width(30)))
                {
                    if (meshfac.arraySize > 0)
                    {
                        meshfac.DeleteArrayElementAtIndex(ind);
                    }
                    if (meshfac.arraySize > 0)
                    {
                        meshfac.DeleteArrayElementAtIndex(ind);
                    }
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUI.indentLevel++;
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(EditorGUI.indentLevel * 12);
            Rect buttonRect = GUILayoutUtility.GetLastRect();

            if (GUILayout.Button(new GUIContent("Add New"), (GUIStyle)"minibuttonleft"))
            {
                PopupWindow.Show(buttonRect, new PopupSelectionMenu(typeof(MeshModifier), meshfac));
                if (Event.current.type == EventType.Repaint)
                {
                    buttonRect = GUILayoutUtility.GetLastRect();
                }
            }

            if (GUILayout.Button(new GUIContent("Add Existing"), (GUIStyle)"minibuttonright"))
            {
                ScriptableCreatorWindow.Open(typeof(MeshModifier), meshfac);
            }

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
            EditorGUI.indentLevel--;
        }
Beispiel #4
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            GUI.enabled = false;
            script      = EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false) as MonoScript;
            GUI.enabled = true;

            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(_positionType, new GUIContent("Feature Position"));


            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Mesh Modifiers");
            var facs = serializedObject.FindProperty("MeshModifiers");

            for (int i = 0; i < facs.arraySize; i++)
            {
                var ind = i;
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.BeginVertical();
                GUILayout.Space(5);
                facs.GetArrayElementAtIndex(ind).objectReferenceValue = EditorGUILayout.ObjectField(facs.GetArrayElementAtIndex(i).objectReferenceValue, typeof(MeshModifier), false) as ScriptableObject;
                EditorGUILayout.EndVertical();
                if (GUILayout.Button(NodeBasedEditor.magnifierTexture, (GUIStyle)"minibuttonleft", GUILayout.Width(30)))
                {
                    ScriptableCreatorWindow.Open(typeof(MeshModifier), facs, ind);
                }
                if (GUILayout.Button(new GUIContent("-"), (GUIStyle)"minibuttonright", GUILayout.Width(30), GUILayout.Height(22)))
                {
                    facs.DeleteArrayElementAtIndex(ind);
                }
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle)"minibuttonleft"))
            {
                facs.arraySize++;
                facs.GetArrayElementAtIndex(facs.arraySize - 1).objectReferenceValue = null;
            }
            if (GUILayout.Button(new GUIContent("Find Asset"), (GUIStyle)"minibuttonright"))
            {
                ScriptableCreatorWindow.Open(typeof(MeshModifier), facs);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Game Object Modifiers");
            var facs2 = serializedObject.FindProperty("GoModifiers");

            for (int i = 0; i < facs2.arraySize; i++)
            {
                var ind = i;
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.BeginVertical();
                GUILayout.Space(5);
                facs2.GetArrayElementAtIndex(ind).objectReferenceValue = EditorGUILayout.ObjectField(facs2.GetArrayElementAtIndex(i).objectReferenceValue, typeof(GameObjectModifier), false) as ScriptableObject;
                EditorGUILayout.EndVertical();

                if (GUILayout.Button(NodeBasedEditor.magnifierTexture, (GUIStyle)"minibuttonleft", GUILayout.Width(30)))
                {
                    ScriptableCreatorWindow.Open(typeof(GameObjectModifier), facs2, ind);
                }
                if (GUILayout.Button(new GUIContent("-"), (GUIStyle)"minibuttonright", GUILayout.Width(30), GUILayout.Height(22)))
                {
                    facs2.DeleteArrayElementAtIndex(ind);
                }
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle)"minibuttonleft"))
            {
                facs.arraySize++;
                facs.GetArrayElementAtIndex(facs.arraySize - 1).objectReferenceValue = null;
            }
            if (GUILayout.Button(new GUIContent("Find Asset"), (GUIStyle)"minibuttonright"))
            {
                ScriptableCreatorWindow.Open(typeof(GameObjectModifier), facs);
            }
            EditorGUILayout.EndHorizontal();

            serializedObject.ApplyModifiedProperties();
        }
Beispiel #5
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            GUI.enabled = false;
            script      = EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false) as MonoScript;
            GUI.enabled = true;

            EditorGUILayout.PropertyField(_classKeyProp);
            EditorGUILayout.PropertyField(_keyProp);


            //FILTERS
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Filters");
                var facs = serializedObject.FindProperty("Filters");
                for (int i = 0; i < facs.arraySize; i++)
                {
                    var ind = i;
                    EditorGUILayout.BeginHorizontal();

                    EditorGUILayout.BeginVertical();
                    GUILayout.Space(5);
                    EditorGUILayout.ObjectField(facs.GetArrayElementAtIndex(ind).objectReferenceValue, typeof(FilterBase), false);
                    EditorGUILayout.EndVertical();

                    if (GUILayout.Button(NodeBasedEditor.magnifierTexture, (GUIStyle)"minibuttonleft", GUILayout.Width(30)))
                    {
                        ScriptableCreatorWindow.Open(typeof(FilterBase), facs, ind);
                    }
                    if (GUILayout.Button(new GUIContent("-"), (GUIStyle)"minibuttonright", GUILayout.Width(30), GUILayout.Height(22)))
                    {
                        facs.DeleteArrayElementAtIndex(ind);
                    }
                    EditorGUILayout.EndHorizontal();
                }


                EditorGUILayout.Space();
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle)"minibuttonleft"))
                {
                    facs.arraySize++;
                    facs.GetArrayElementAtIndex(facs.arraySize - 1).objectReferenceValue = null;
                }
                if (GUILayout.Button(new GUIContent("Find Asset"), (GUIStyle)"minibuttonright"))
                {
                    ScriptableCreatorWindow.Open(typeof(FilterBase), facs);
                }
                EditorGUILayout.EndHorizontal();
            }

            //DEFAULT STACK
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Default Stack");
                var def = serializedObject.FindProperty("_defaultStack");
                {
                    EditorGUILayout.BeginHorizontal();

                    EditorGUILayout.BeginVertical();
                    GUILayout.Space(5);
                    EditorGUILayout.ObjectField(_layerVis._defaultStack, typeof(ModifierStackBase));
                    EditorGUILayout.EndVertical();

                    if (GUILayout.Button(NodeBasedEditor.magnifierTexture, (GUIStyle)"minibuttonleft", GUILayout.Width(30)))
                    {
                        ScriptableCreatorWindow.Open(typeof(ModifierStackBase), null, 0, (asset) =>
                        {
                            def.objectReferenceValue = asset;
                            serializedObject.ApplyModifiedProperties();
                        });
                    }
                    if (GUILayout.Button(new GUIContent("-"), (GUIStyle)"minibuttonright", GUILayout.Width(30), GUILayout.Height(22)))
                    {
                        def.objectReferenceValue = null;
                        serializedObject.ApplyModifiedProperties();
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }


            //STACKS
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Stacks");
                var facs = serializedObject.FindProperty("Stacks");
                for (int i = 0; i < facs.arraySize; i++)
                {
                    var ind = i;
                    EditorGUILayout.BeginHorizontal();
                    if (_layerVis.Stacks != null)
                    {
                        var nname = EditorGUILayout.TextField(_layerVis.Stacks[i].Type, GUILayout.MaxWidth(100));
                        facs.GetArrayElementAtIndex(ind).FindPropertyRelative("Type").stringValue = nname;
                    }

                    EditorGUILayout.BeginVertical();
                    GUILayout.Space(5);
                    EditorGUILayout.ObjectField(_layerVis.Stacks[i].Stack, typeof(ModifierStackBase));
                    EditorGUILayout.EndVertical();

                    if (GUILayout.Button(NodeBasedEditor.magnifierTexture, (GUIStyle)"minibuttonleft", GUILayout.Width(30)))
                    {
                        ScriptableCreatorWindow.Open(typeof(ModifierStackBase), facs, ind, (asset) =>
                        {
                            var pp = facs.GetArrayElementAtIndex(ind).FindPropertyRelative("Stack");
                            pp.objectReferenceValue = asset;

                            serializedObject.ApplyModifiedProperties();
                        });
                    }
                    if (GUILayout.Button(new GUIContent("-"), (GUIStyle)"minibuttonright", GUILayout.Width(30), GUILayout.Height(22)))
                    {
                        facs.DeleteArrayElementAtIndex(ind);
                    }
                    EditorGUILayout.EndHorizontal();
                }


                EditorGUILayout.Space();
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle)"minibuttonleft"))
                {
                    facs.arraySize++;
                    facs.GetArrayElementAtIndex(facs.arraySize - 1).objectReferenceValue = null;
                }
                if (GUILayout.Button(new GUIContent("Find Asset"), (GUIStyle)"minibuttonright"))
                {
                    ScriptableCreatorWindow.Open(typeof(ModifierStackBase), facs, 0, (asset) =>
                    {
                        _layerVis.Stacks.Add(new TypeVisualizerTuple()
                        {
                            Stack = (ModifierStackBase)asset
                        });
                    });
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            GUI.enabled = false;
            script      = EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false) as MonoScript;
            GUI.enabled = true;

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(mapId_Prop, new GUIContent("Map Id"));
            if (GUILayout.Button("R", GUILayout.Width(30)))
            {
                mapId_Prop.stringValue = _defaultMapId;
                GUI.FocusControl(null);
                Repaint();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.PropertyField(_useGeoServer);
            // TODO geoAR: make readonly when '_useGeoServer' is not selected
            EditorGUILayout.PropertyField(_gridset);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Visualizers");
            var facs = serializedObject.FindProperty("Visualizers");

            for (int i = 0; i < facs.arraySize; i++)
            {
                var ind = i;
                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.BeginVertical();
                GUILayout.Space(5);
                EditorGUILayout.BeginHorizontal();
                if (_factory.Visualizers[i] != null)
                {
                    _factory.Visualizers[i].Active = EditorGUILayout.Toggle(_factory.Visualizers[i].Active, GUILayout.MaxWidth(20));
                    _factory.Visualizers[i].Key    = EditorGUILayout.TextField(_factory.Visualizers[i].Key, GUILayout.MaxWidth(100));
                }
                //facs.GetArrayElementAtIndex(ind).objectReferenceValue = EditorGUILayout.ObjectField(facs.GetArrayElementAtIndex(i).objectReferenceValue, typeof(LayerVisualizerBase)) as ScriptableObject;
                if (_factory.Visualizers[i] == null)
                {
                    EditorGUILayout.TextField("null");
                }
                else
                {
                    _factory.Visualizers[i] = (LayerVisualizerBase)EditorGUILayout.ObjectField(_factory.Visualizers[i], typeof(LayerVisualizerBase), false);
                }
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();

                if (GUILayout.Button(NodeBasedEditor.magnifierTexture, (GUIStyle)"minibuttonleft", GUILayout.Width(30)))
                {
                    ScriptableCreatorWindow.Open(typeof(LayerVisualizerBase), facs, ind);
                }
                if (GUILayout.Button(new GUIContent("-"), (GUIStyle)"minibuttonright", GUILayout.Width(30), GUILayout.Height(22)))
                {
                    facs.DeleteArrayElementAtIndex(ind);
                }
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle)"minibuttonleft"))
            {
                facs.arraySize++;
                facs.GetArrayElementAtIndex(facs.arraySize - 1).objectReferenceValue = null;
            }
            if (GUILayout.Button(new GUIContent("Find Asset"), (GUIStyle)"minibuttonright"))
            {
                ScriptableCreatorWindow.Open(typeof(LayerVisualizerBase), facs);
            }
            EditorGUILayout.EndHorizontal();

            serializedObject.ApplyModifiedProperties();
        }
Beispiel #7
0
        void DrawModifiers(SerializedProperty property, GUIContent label)
        {
            var groupFeaturesProperty = property.FindPropertyRelative("coreOptions").FindPropertyRelative("groupFeatures");

            ShowPosition = EditorGUILayout.Foldout(ShowPosition, label.text);
            EditorGUILayout.BeginVertical();
            if (ShowPosition)
            {
                EditorGUILayout.BeginHorizontal();
                if (groupFeaturesProperty.boolValue == false)
                {
                    EditorGUILayout.PrefixLabel(new GUIContent
                    {
                        text    = "Feature Position",
                        tooltip = "Position to place feature in the tile. "
                    });
                    var featurePositionProperty = property.FindPropertyRelative("moveFeaturePositionTo");
                    featurePositionProperty.enumValueIndex = EditorGUILayout.Popup(featurePositionProperty.enumValueIndex,
                                                                                   featurePositionProperty.enumDisplayNames);
                }

                EditorGUILayout.EndHorizontal();

                EditorGUILayout.Space();

                EditorGUILayout.LabelField(new GUIContent
                {
                    text    = "Mesh Modifiers",
                    tooltip = "Modifiers that manipulate the features mesh. "
                });

                var meshfac = property.FindPropertyRelative("MeshModifiers");

                for (int i = 0; i < meshfac.arraySize; i++)
                {
                    var ind = i;
                    EditorGUILayout.BeginHorizontal();

                    EditorGUILayout.BeginVertical();
                    meshfac.GetArrayElementAtIndex(ind).objectReferenceValue =
                        EditorGUILayout.ObjectField(meshfac.GetArrayElementAtIndex(i).objectReferenceValue, typeof(MeshModifier), false)
                        as ScriptableObject;

                    EditorGUILayout.EndVertical();

                    if (GUILayout.Button(new GUIContent("x"), (GUIStyle)"minibuttonright", GUILayout.Width(30)))
                    {
                        meshfac.DeleteArrayElementAtIndex(ind);
                        meshfac.DeleteArrayElementAtIndex(ind);
                    }

                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.Space();
                EditorGUI.indentLevel++;
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(EditorGUI.indentLevel * 12);
                Rect buttonRect = GUILayoutUtility.GetLastRect();
                if (GUILayout.Button(new GUIContent("Add New"), (GUIStyle)"minibuttonleft"))
                {
                    PopupWindow.Show(buttonRect, new PopupSelectionMenu(typeof(MeshModifier), meshfac));
                    if (Event.current.type == EventType.Repaint)
                    {
                        buttonRect = GUILayoutUtility.GetLastRect();
                    }
                }

                if (GUILayout.Button(new GUIContent("Add Existing"), (GUIStyle)"minibuttonright"))
                {
                    ScriptableCreatorWindow.Open(typeof(MeshModifier), meshfac);
                }

                EditorGUILayout.EndHorizontal();
                EditorGUI.indentLevel--;
                EditorGUILayout.Space();

                EditorGUILayout.LabelField(new GUIContent
                {
                    text    = "Game Object Modifiers",
                    tooltip = "Modifiers that manipulate the GameObject after mesh generation."
                });
                var gofac = property.FindPropertyRelative("GoModifiers");
                for (int i = 0; i < gofac.arraySize; i++)
                {
                    var ind = i;
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.BeginVertical();
                    GUILayout.Space(5);
                    gofac.GetArrayElementAtIndex(ind).objectReferenceValue =
                        EditorGUILayout.ObjectField(gofac.GetArrayElementAtIndex(i).objectReferenceValue, typeof(GameObjectModifier),
                                                    false) as ScriptableObject;
                    EditorGUILayout.EndVertical();

                    if (GUILayout.Button(new GUIContent("x"), GUILayout.Width(30)))
                    {
                        gofac.DeleteArrayElementAtIndex(ind);
                        gofac.DeleteArrayElementAtIndex(ind);
                    }

                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.Space();
                EditorGUI.indentLevel++;
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(EditorGUI.indentLevel * 12);
                //buttonRect = GUILayoutUtility.GetLastRect();
                if (GUILayout.Button(new GUIContent("Add New"), (GUIStyle)"minibuttonleft"))
                {
                    PopupWindow.Show(buttonRect, new PopupSelectionMenu(typeof(GameObjectModifier), gofac));
                    if (Event.current.type == EventType.Repaint)
                    {
                        buttonRect = GUILayoutUtility.GetLastRect();
                    }
                }
                //EditorWindow.Repaint();
                //buttonRect = GUILayoutUtility.GetLastRect();
                if (GUILayout.Button(new GUIContent("Add Existing"), (GUIStyle)"minibuttonright"))
                {
                    ScriptableCreatorWindow.Open(typeof(GameObjectModifier), gofac);
                }

                EditorGUILayout.EndHorizontal();
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndVertical();
        }
Beispiel #8
0
        private void DrawGoModifiers(SerializedProperty property)
        {
            EditorGUILayout.BeginVertical();

            EditorGUILayout.LabelField(new GUIContent
            {
                text    = "Game Object Modifiers",
                tooltip = "Modifiers that manipulate the GameObject after mesh generation."
            });
            var gofac = property.FindPropertyRelative("GoModifiers");

            for (int i = 0; i < gofac.arraySize; i++)
            {
                var ind = i;
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.BeginVertical();
                GUILayout.Space(5);
                gofac.GetArrayElementAtIndex(ind).objectReferenceValue =
                    EditorGUILayout.ObjectField(gofac.GetArrayElementAtIndex(i).objectReferenceValue, typeof(GameObjectModifier),
                                                false) as ScriptableObject;
                EditorGUILayout.EndVertical();

                if (GUILayout.Button(new GUIContent("x"), GUILayout.Width(30)))
                {
                    bool elementWasDeleted = false;
                    if (gofac.arraySize > 0)
                    {
                        gofac.DeleteArrayElementAtIndex(ind);
                        elementWasDeleted = true;
                    }
                    if (gofac.arraySize > 0)
                    {
                        gofac.DeleteArrayElementAtIndex(ind);
                    }
                    if (elementWasDeleted)
                    {
                        EditorHelper.CheckForModifiedProperty(property);
                    }
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUI.indentLevel++;
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(EditorGUI.indentLevel * 12);
            Rect buttonRect = GUILayoutUtility.GetLastRect();

            if (GUILayout.Button(new GUIContent("Add New"), (GUIStyle)"minibuttonleft"))
            {
                PopupWindow.Show(buttonRect, new PopupSelectionMenu(typeof(GameObjectModifier), gofac));
                if (Event.current.type == EventType.Repaint)
                {
                    buttonRect = GUILayoutUtility.GetLastRect();
                }
            }

            if (GUILayout.Button(new GUIContent("Add Existing"), (GUIStyle)"minibuttonright"))
            {
                ScriptableCreatorWindow.Open(typeof(GameObjectModifier), gofac, -1, null, property);
            }

            EditorGUILayout.EndHorizontal();
            EditorGUI.indentLevel--;
            EditorGUILayout.EndVertical();
        }
        void DrawModifiers(SerializedProperty property, GUIContent label)
        {
            showPosition = EditorGUILayout.Foldout(showPosition, label.text);
            EditorGUILayout.BeginVertical();
            if (showPosition)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel(new GUIContent {
                    text = "Feature Position", tooltip = "Position to place feature in the tile. "
                });
                var featurePositionProperty = property.FindPropertyRelative("moveFeaturePositionTo");
                featurePositionProperty.enumValueIndex = EditorGUILayout.Popup(featurePositionProperty.enumValueIndex, featurePositionProperty.enumDisplayNames);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.Space();
                EditorGUILayout.LabelField(new GUIContent {
                    text = "Mesh Modifiers", tooltip = "Modifiers that manipulate the features mesh. "
                });

                var meshfac = property.FindPropertyRelative("MeshModifiers");

                for (int i = 0; i < meshfac.arraySize; i++)
                {
                    var ind = i;
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.BeginVertical();
                    //GUILayout.Space(5);
                    meshfac.GetArrayElementAtIndex(ind).objectReferenceValue = EditorGUILayout.ObjectField(meshfac.GetArrayElementAtIndex(i).objectReferenceValue, typeof(MeshModifier), false) as ScriptableObject;
                    EditorGUILayout.EndVertical();
                    if (GUILayout.Button(new GUIContent("+"), (GUIStyle)"minibuttonleft", GUILayout.Width(30)))
                    {
                        ScriptableCreatorWindow.Open(typeof(MeshModifier), meshfac, ind);
                    }
                    if (GUILayout.Button(new GUIContent("-"), (GUIStyle)"minibuttonright", GUILayout.Width(30)))
                    {
                        meshfac.DeleteArrayElementAtIndex(ind);
                    }
                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.Space();
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle)"minibuttonleft"))
                {
                    meshfac.arraySize++;
                    meshfac.GetArrayElementAtIndex(meshfac.arraySize - 1).objectReferenceValue = null;
                }
                if (GUILayout.Button(new GUIContent("Find Asset"), (GUIStyle)"minibuttonright"))
                {
                    ScriptableCreatorWindow.Open(typeof(MeshModifier), meshfac);
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.Space();
                EditorGUILayout.LabelField(new GUIContent {
                    text = "Game Object Modifiers", tooltip = "Modifiers that manipulate the GameObject after mesh generation."
                });
                var gofac = property.FindPropertyRelative("GoModifiers");
                for (int i = 0; i < gofac.arraySize; i++)
                {
                    var ind = i;
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.BeginVertical();
                    GUILayout.Space(5);
                    gofac.GetArrayElementAtIndex(ind).objectReferenceValue = EditorGUILayout.ObjectField(gofac.GetArrayElementAtIndex(i).objectReferenceValue, typeof(GameObjectModifier), false) as ScriptableObject;
                    EditorGUILayout.EndVertical();

                    if (GUILayout.Button(new GUIContent("+"), (GUIStyle)"minibuttonleft", GUILayout.Width(30)))
                    {
                        ScriptableCreatorWindow.Open(typeof(GameObjectModifier), gofac, ind);
                    }
                    if (GUILayout.Button(new GUIContent("-"), (GUIStyle)"minibuttonright", GUILayout.Width(30)))
                    {
                        gofac.DeleteArrayElementAtIndex(ind);
                    }
                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.Space();
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button(new GUIContent("Add New Empty"), (GUIStyle)"minibuttonleft"))
                {
                    gofac.arraySize++;
                    gofac.GetArrayElementAtIndex(gofac.arraySize - 1).objectReferenceValue = null;
                }
                if (GUILayout.Button(new GUIContent("Find Asset"), (GUIStyle)"minibuttonright"))
                {
                    ScriptableCreatorWindow.Open(typeof(GameObjectModifier), gofac);
                }
                EditorGUILayout.EndHorizontal();
                //GUILayout.EndArea();
            }
            //EditorGUI.indentLevel--;
            EditorGUILayout.EndVertical();
        }