コード例 #1
0
        public override void OnInspectorGUI()
        {
            EditorGUI.BeginChangeCheck();

            EditorGUILayout.LabelField("Particle Properties", EditorStyles.boldLabel);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(new GUIContent("Particle Prefab", "The particle prefab to use."), GUILayout.Width(180));
            interaction.ParticlePrefab = EditorGUILayout.ObjectField(interaction.ParticlePrefab, typeof(ImpactParticles), false) as ImpactParticles;
            EditorGUILayout.EndHorizontal();

            if (interaction.ParticlePrefab == null)
            {
                EditorGUILayout.HelpBox("You must assign an Particle Prefab for this interaction.", MessageType.Error);
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(new GUIContent("Is Particle Looped", "Is the particle prefab looped?"), GUILayout.Width(180));
            interaction.IsParticleLooped = EditorGUILayout.Toggle(interaction.IsParticleLooped);
            EditorGUILayout.EndHorizontal();

            ImpactEditorUtilities.Separator();

            EditorGUILayout.LabelField("Interaction Properties", EditorStyles.boldLabel);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(new GUIContent("Minimum Velocity", "The minimum velocity magnitude required to show particles."), GUILayout.Width(180));
            interaction.MinimumVelocity = EditorGUILayout.FloatField(interaction.MinimumVelocity);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(new GUIContent("Collision Normal Influence", "How much the collision normal should influence the calculated intensity."), GUILayout.Width(180));
            interaction.CollisionNormalInfluence = EditorGUILayout.Slider(interaction.CollisionNormalInfluence, 0, 1);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Separator();

            interaction.EmitOnCollision = EditorGUILayout.ToggleLeft(new GUIContent("Emit On Collision", "Should particles be emitted on single collisions?"), interaction.EmitOnCollision);
            interaction.EmitOnSlide     = EditorGUILayout.ToggleLeft(new GUIContent("Emit On Slide", "Should particles be emitted when sliding?"), interaction.EmitOnSlide);
            interaction.EmitOnRoll      = EditorGUILayout.ToggleLeft(new GUIContent("Emit On Roll", "Should particles be emitted when rolling?"), interaction.EmitOnRoll);

            GUI.enabled = !interaction.IsParticleLooped && (interaction.EmitOnSlide || interaction.EmitOnRoll);

            interaction.EmissionInterval     = ImpactEditorUtilities.RangeEditor(interaction.EmissionInterval, new GUIContent("Emission Interval (Min/Max)", "The interval at which particles should be emitted when sliding or rolling."));
            interaction.EmissionIntervalType = (InteractionIntervalType)EditorGUILayout.EnumPopup(new GUIContent("Interval Type", "Whether the Emission Interval is defined in Time (seconds) or Distance."), interaction.EmissionIntervalType);

            GUI.enabled = true;

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(interaction);
            }
        }
コード例 #2
0
        public override void OnInspectorGUI()
        {
            EditorGUI.BeginChangeCheck();

            drawAudioProperties();

            ImpactEditorUtilities.Separator();

            drawInteractionProperties();

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(interaction);
            }
        }
コード例 #3
0
        private void drawInteractionSet(SerializedProperty interactionSetProperty, ImpactMaterialInteractionSet interactionSet, int index)
        {
            bool removed = false;

            EditorGUILayout.BeginHorizontal();

            SerializedProperty nameProperty = interactionSetProperty.FindPropertyRelative("_name");
            SerializedProperty includeTagsFilterProperty = interactionSetProperty.FindPropertyRelative("_includeTagsFilter");
            SerializedProperty excludeTagsFilterProperty = interactionSetProperty.FindPropertyRelative("_excludeTagsFilter");

            interactionFoldouts[index] = EditorGUILayout.Foldout(interactionFoldouts[index], new GUIContent(nameProperty.stringValue, ""), true);

            Color originalColor = GUI.color;

            GUI.color = warningColor;
            if (GUILayout.Button(new GUIContent("X", "Remove"), GUILayout.Width(20), GUILayout.Height(15)))
            {
                material.RemoveInteractionSet(index);
                interactionFoldouts.RemoveAt(index);
                removed = true;
                EditorUtility.SetDirty(target);
            }
            GUI.color = originalColor;

            EditorGUILayout.EndHorizontal();

            if (!removed && interactionFoldouts[index])
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                EditorGUILayout.BeginVertical();

                GUILayout.Space(2);

                EditorGUILayout.PropertyField(nameProperty, new GUIContent("Name", "A human-readable name for the interaction set."));

                EditorGUILayout.Separator();

                EditorGUILayout.LabelField("Filters", EditorStyles.boldLabel);

                drawTagMaskFilter(includeTagsFilterProperty, new GUIContent("Include Tags", "Tags that, when present, will cause this interaction set to be used."));
                drawTagMaskFilter(excludeTagsFilterProperty, new GUIContent("Exclude Tags", "Tags that, when present, will cause this interaction set to be ignored."));

                ImpactEditorUtilities.Separator();

                drawInteractionsList(interactionSet);
            }
        }
コード例 #4
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(tagLibraryProperty, new GUIContent("Tag Library", "The Tag Library to use for displaying tag names."));
            updateTagNames();

            if (material.TagLibrary == null)
            {
                EditorGUILayout.HelpBox(ImpactTagLibraryConstants.TagLibraryNotFoundErrorMessage, MessageType.Info);
            }

            ImpactEditorUtilities.TagMaskPropertyEditor(materialTagsMaskProperty, new GUIContent("Material Tags", "The tags that apply to this material."), tagNames);

            ImpactEditorUtilities.Separator();

            drawInteractionsList();

            serializedObject.ApplyModifiedProperties();
        }
コード例 #5
0
        public override void OnInspectorGUI()
        {
            EditorGUILayout.Separator();

            EditorGUILayout.LabelField("Terrain", EditorStyles.boldLabel);
            terrain.Terrain = EditorGUILayout.ObjectField(new GUIContent("", "The Terrain this object is associated with."), terrain.Terrain, typeof(Terrain), true) as Terrain;

            if (terrain.Terrain == null)
            {
                EditorGUILayout.HelpBox("Assign a Terrain to begin editing Terrain Materials.", MessageType.Info);
            }
            else
            {
                ImpactEditorUtilities.Separator();

                drawTerrainLayersList();
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(terrain);
            }
        }
コード例 #6
0
        public override void OnInspectorGUI()
        {
            configurationManager = target as ImpactManager;
            serializedObject.Update();

            EditorGUILayout.Separator();

            EditorGUILayout.LabelField("General", EditorStyles.boldLabel);

            doProperty(physicsInteractionsLimit, new GUIContent("Physics Interactions Limit", "The maximum number of interactions generated by the built-in physics triggers that can be processed in a single fixed update. 0 = No limit."));
            doProperty(interactionResultBufferSize, new GUIContent("Interaction Result Buffer Size", "The size of the buffer array used to retrieve interaction results. This will be the maximum number of interaction results that can be produced by a single interaction."));
            doProperty(activeContinuousInteractions, new GUIContent("Max Active Continuous Interactions", "The maximum number of continuous interactions (i.e. sliding and rolling) that can be active at the same time."));
            doProperty(materialCompositionBufferSize, new GUIContent("Material Composition Buffer Size", "The size of the buffer array used to retrieve material composition results. This will be the maximum number of materials that can be returned when using material composition."));

            EditorGUILayout.Separator();

            doProperty(dontDestroyOnLoad, new GUIContent("Don't Destroy On Load", "Should the manager persist across scene loads?"));
            doProperty(setAsActiveInstance, new GUIContent("Set as Active Instance", "Should the manager be set as the active ImpactManager instance on Awake?"));

            ImpactEditorUtilities.Separator();

            EditorGUILayout.LabelField("Material Mapping", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(useMaterialMapping, new GUIContent("Use Material Mapping", "Use the Physics Material to Impact Material mapping feature?"));

            EditorGUILayout.HelpBox("Use Material Mapping to map from Physics Materials to Impact Materials so that you don't have to add Impact Object components to every object. This works best for static objects.", MessageType.Info);

            GUI.enabled = useMaterialMapping.boolValue;

            EditorGUILayout.Separator();

            //3D physic material mappings
            physicMaterialMappingFoldout = EditorGUILayout.Foldout(physicMaterialMappingFoldout, "Physic Material Mappings (3D Physics)");

            if (physicMaterialMappingFoldout)
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                GUILayout.Space(2);

                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();

                if (GUILayout.Button("New"))
                {
                    physicMaterialMapping.arraySize++;
                }

                if (GUILayout.Button("Clear"))
                {
                    if (EditorUtility.DisplayDialog("Clear All Physic Material Mappings", "Are you sure you want to remove all Physic Material  Mappings? This cannot be undone.", "Yes", "No"))
                    {
                        physicMaterialMapping.ClearArray();
                    }
                }

                EditorGUILayout.EndHorizontal();

                if (physicMaterialMapping.arraySize == 0)
                {
                    EditorGUILayout.HelpBox("No Physic Material mappings have been created.", MessageType.Info);
                }
                else
                {
                    EditorGUILayout.Separator();

                    for (int i = 0; i < physicMaterialMapping.arraySize; i++)
                    {
                        SerializedProperty mapping        = physicMaterialMapping.GetArrayElementAtIndex(i);
                        SerializedProperty physicMaterial = mapping.FindPropertyRelative("PhysicMaterial");
                        SerializedProperty impactMaterial = mapping.FindPropertyRelative("ImpactMaterial");

                        EditorGUILayout.BeginHorizontal();

                        EditorGUILayout.PropertyField(physicMaterial, new GUIContent());
                        EditorGUILayout.LabelField("→", GUILayout.Width(20));
                        EditorGUILayout.PropertyField(impactMaterial, new GUIContent());

                        Color originalColor = GUI.color;
                        GUI.color = warningColor;
                        if (GUILayout.Button(new GUIContent("X", "Remove"), GUILayout.Width(20), GUILayout.Height(15)))
                        {
                            physicMaterialMapping.DeleteArrayElementAtIndex(i);
                        }
                        GUI.color = originalColor;

                        EditorGUILayout.EndHorizontal();
                    }
                }

                GUILayout.Space(2);

                EditorGUILayout.EndVertical();
            }

            //2D physic material mappings
            physicsMaterial2DMappingFoldout = EditorGUILayout.Foldout(physicsMaterial2DMappingFoldout, "Physics Material 2D Mappings (2D Physics)");

            if (physicsMaterial2DMappingFoldout)
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                GUILayout.Space(2);

                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();

                if (GUILayout.Button("New"))
                {
                    physicsMaterial2DMapping.arraySize++;
                }

                if (GUILayout.Button("Clear"))
                {
                    if (EditorUtility.DisplayDialog("Clear All Physic Material Mappings", "Are you sure you want to remove all Physic Material  Mappings? This cannot be undone.", "Yes", "No"))
                    {
                        physicsMaterial2DMapping.ClearArray();
                    }
                }

                EditorGUILayout.EndHorizontal();

                if (physicsMaterial2DMapping.arraySize == 0)
                {
                    EditorGUILayout.HelpBox("No Physics Material 2D mappings have been created.", MessageType.Info);
                }
                else
                {
                    EditorGUILayout.Separator();

                    for (int i = 0; i < physicsMaterial2DMapping.arraySize; i++)
                    {
                        SerializedProperty mapping        = physicsMaterial2DMapping.GetArrayElementAtIndex(i);
                        SerializedProperty physicMaterial = mapping.FindPropertyRelative("PhysicsMaterial2D");
                        SerializedProperty impactMaterial = mapping.FindPropertyRelative("ImpactMaterial");

                        EditorGUILayout.BeginHorizontal();

                        EditorGUILayout.PropertyField(physicMaterial, new GUIContent());
                        EditorGUILayout.LabelField("→", GUILayout.Width(20));
                        EditorGUILayout.PropertyField(impactMaterial, new GUIContent());

                        Color originalColor = GUI.color;
                        GUI.color = warningColor;
                        if (GUILayout.Button(new GUIContent("X", "Remove"), GUILayout.Width(20), GUILayout.Height(15)))
                        {
                            physicsMaterial2DMapping.DeleteArrayElementAtIndex(i);
                        }
                        GUI.color = originalColor;

                        EditorGUILayout.EndHorizontal();
                    }
                }

                GUILayout.Space(2);

                EditorGUILayout.EndVertical();
            }

            GUI.enabled = true;

            serializedObject.ApplyModifiedProperties();
        }