protected override void OnInspectorGUIUpdate() { base.OnInspectorGUIUpdate(); GUIContent content; GUILayout.BeginHorizontal(); content = new GUIContent("Position", "Option to match the target's position."); EditorGUILayout.PropertyField(this.position, content); if (this.position.boolValue) { PGEditorUtils.ToggleButton(this.outputPosX, new GUIContent("X", "Toggle Costraint for this axis."), 24); PGEditorUtils.ToggleButton(this.outputPosY, new GUIContent("Y", "Toggle Costraint for this axis."), 24); PGEditorUtils.ToggleButton(this.outputPosZ, new GUIContent("Z", "Toggle Costraint for this axis."), 24); } GUILayout.EndHorizontal(); content = new GUIContent("Rotation", "Option to match the target's rotation."); EditorGUILayout.PropertyField(this.rotation, content); if (this.rotation.boolValue) { EditorGUI.indentLevel += 1; content = new GUIContent("Output", "Used to alter the way the rotations are set."); EditorGUILayout.PropertyField(this.output, content); EditorGUI.indentLevel -= 1; } content = new GUIContent("Scale", "Option to match the target's scale."); EditorGUILayout.PropertyField(this.scale, content); }
public override void OnInspectorGUI() { this.serializedObject.Update(); Object[] targetObjs = this.serializedObject.targetObjects; FireDistanceModifier curEditTarget; GUIContent content; GUIStyle style; EditorGUIUtility.labelWidth = PGEditorUtils.CONTROLS_DEFAULT_LABEL_WIDTH; EditorGUI.indentLevel = 1; content = new GUIContent ( "Origin Mode", "The origin is the point from which the distance is measuered." ); EditorGUILayout.PropertyField(this.originMode, content); var noLabel = new GUIContent(""); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Distance:", GUILayout.MaxWidth(70)); EditorGUILayout.LabelField("Min", GUILayout.MaxWidth(40)); EditorGUILayout.PropertyField(this.minDistance, noLabel, GUILayout.MinWidth(40)); EditorGUILayout.LabelField("Max", GUILayout.MaxWidth(40)); EditorGUILayout.PropertyField(this.maxDistance, noLabel, GUILayout.MinWidth(40)); EditorGUILayout.EndHorizontal(); // GIZMO... EditorGUILayout.BeginHorizontal(); GUILayout.Space(12); // For some reason the button won't indent. So fake it. content = new GUIContent ( "Gizmo", "Visualize the distance in the Editor by turning this on." ); PGEditorUtils.ToggleButton(this.drawGizmo, content, 50); if (this.drawGizmo.boolValue) { EditorGUILayout.PropertyField(this.gizmoColor, noLabel, GUILayout.MinWidth(60)); style = EditorStyles.miniButton; style.alignment = TextAnchor.MiddleCenter; style.fixedWidth = 52; if (GUILayout.Button("Reset", style)) { for (int i = 0; i < targetObjs.Length; i++) { curEditTarget = (FireDistanceModifier)targetObjs[i]; curEditTarget.gizmoColor = curEditTarget.defaultGizmoColor; } } } EditorGUILayout.EndHorizontal(); GUILayout.Space(4); content = new GUIContent ( "Debug Level", "Set it higher to see more verbose information." ); EditorGUILayout.PropertyField(this.debugLevel, content); serializedObject.ApplyModifiedProperties(); // Flag Unity to save the changes to to the prefab to disk // This is needed to make the gizmos update immediatly. if (GUI.changed) { EditorUtility.SetDirty(target); } }
public override void OnInspectorGUI() { this.serializedObject.Update(); GUIContent content; EditorGUI.indentLevel = 0; EditorGUIUtility.labelWidth = PGEditorUtils.CONTROLS_DEFAULT_LABEL_WIDTH; Object[] targetObjs = this.serializedObject.targetObjects; AreaTargetTracker curEditTarget; content = new GUIContent( "Targets (-1 for all)", "The number of targets to return. Set to -1 to return all targets" ); EditorGUILayout.PropertyField(this.numberOfTargets, content); content = new GUIContent ( "Target Layers", "The layers in which the area is allowed to find targets." ); EditorGUILayout.PropertyField(this.targetLayers, content); EditorGUI.BeginChangeCheck(); content = new GUIContent("Sorting Style", "The style of sorting to use"); EditorGUILayout.PropertyField(this.sortingStyle, content); var sortingStyle = (TargetTracker.SORTING_STYLES) this.sortingStyle.enumValueIndex; // If changed, trigger the property setter for all objects being edited if (EditorGUI.EndChangeCheck()) { for (int i = 0; i < targetObjs.Length; i++) { curEditTarget = (AreaTargetTracker)targetObjs[i]; Undo.RecordObject(curEditTarget, targetObjs[0].GetType() + " sortingStyle"); curEditTarget.sortingStyle = sortingStyle; } } if (sortingStyle != TargetTracker.SORTING_STYLES.None) { EditorGUI.indentLevel += 1; content = new GUIContent( "Minimum Interval", "How often the target list will be sorted. If set to 0, " + "sorting will only be triggered when Targets enter or exit range." ); EditorGUILayout.PropertyField(this.updateInterval, content); EditorGUI.indentLevel -= 1; } this.showArea = EditorGUILayout.Foldout(this.showArea, "Area Settings"); if (this.showArea) { EditorGUI.indentLevel += 1; EditorGUI.BeginChangeCheck(); content = new GUIContent ( "Area Layer", "The layer to put the area in." ); content = EditorGUI.BeginProperty(new Rect(0, 0, 0, 0), content, this.areaLayer); int layer = EditorGUILayout.LayerField(content, this.areaLayer.intValue); // If changed, trigger the property setter for all objects being edited if (EditorGUI.EndChangeCheck()) { for (int i = 0; i < targetObjs.Length; i++) { curEditTarget = (AreaTargetTracker)targetObjs[i]; Undo.RecordObject(curEditTarget, targetObjs[0].GetType() + " areaLayer"); curEditTarget.areaLayer = layer; } } EditorGUI.EndProperty(); EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); content = new GUIContent ( "Area Shape", "The shape of the area used to detect targets in range" ); EditorGUILayout.PropertyField(this.areaShape, content); // If changed, trigger the property setter for all objects being edited if (EditorGUI.EndChangeCheck()) { var shape = (AreaTargetTracker.AREA_SHAPES) this.areaShape.enumValueIndex; string undo_message = targetObjs[0].GetType() + " areaShape"; for (int i = 0; i < targetObjs.Length; i++) { curEditTarget = (AreaTargetTracker)targetObjs[i]; if (curEditTarget.area != null) // Only works at runtime. { // // This would have happened anyway, but this way is undoable // if (curEditTarget.area.coll != null) // { // Undo.DestroyObjectImmediate(curEditTarget.area.coll); // } // else if (curEditTarget.area.coll2D != null) // { // Undo.DestroyObjectImmediate(curEditTarget.area.coll2D); // } Undo.RecordObject(curEditTarget.area.transform, undo_message); } Undo.RecordObject(curEditTarget, undo_message); // Property. Handles collider changes at runtime. curEditTarget.areaShape = shape; } } Area area; bool ok; for (int i = 0; i < targetObjs.Length; i++) { curEditTarget = (AreaTargetTracker)targetObjs[i]; area = curEditTarget.area; ok = false; if (area == null) { continue; } if (area.coll != null) { switch (curEditTarget.areaShape) { case AreaTargetTracker.AREA_SHAPES.Sphere: if (area.coll is SphereCollider) { ok = true; } break; case AreaTargetTracker.AREA_SHAPES.Box: if (area.coll is BoxCollider) { ok = true; } break; case AreaTargetTracker.AREA_SHAPES.Capsule: if (area.coll is CapsuleCollider) { ok = true; } break; } } else if (area.coll2D != null) { switch (curEditTarget.areaShape) { case AreaTargetTracker.AREA_SHAPES.Box2D: if (area.coll2D is BoxCollider2D) { ok = true; } break; case AreaTargetTracker.AREA_SHAPES.Circle2D: if (area.coll2D is CircleCollider2D) { ok = true; } break; } } if (!ok) { var shape = (AreaTargetTracker.AREA_SHAPES) this.areaShape.enumValueIndex; curEditTarget.areaShape = shape; } } content = new GUIContent ( "Gizmo ", "Visualize the area in the Editor by turning this on." ); PGEditorUtils.ToggleButton(this.drawGizmo, content, 50); //script.drawGizmo = EditorGUILayout.Toggle(script.drawGizmo, GUILayout.MaxWidth(47)); EditorGUILayout.EndHorizontal(); if (this.drawGizmo.boolValue) { EditorGUI.indentLevel += 1; EditorGUILayout.BeginHorizontal(); content = new GUIContent ( "Gizmo Color", "The color of the gizmo when displayed" ); EditorGUILayout.PropertyField(this.gizmoColor, content); // If clicked, reset the color to the default GUIStyle style = EditorStyles.miniButton; style.alignment = TextAnchor.MiddleCenter; style.fixedWidth = 52; if (GUILayout.Button("Reset", style)) { for (int i = 0; i < targetObjs.Length; i++) { curEditTarget = (AreaTargetTracker)targetObjs[i]; curEditTarget.gizmoColor = curEditTarget.defaultGizmoColor; } } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel -= 1; GUILayout.Space(4); } this.displayRange <AreaTargetTracker>(targetObjs); EditorGUI.BeginChangeCheck(); content = new GUIContent ( "Position Offset", "An optional position offset for the area. For example, if you have an" + "object resting on the ground which has a range of 4, a position offset of" + "Vector3(0, 4, 0) will place your area so it is also sitting on the ground." ); EditorGUILayout.PropertyField(this.areaPositionOffset, content); // If changed, trigger the property setter for all objects being edited if (EditorGUI.EndChangeCheck()) { string undo_message = targetObjs[0].GetType() + " areaPositionOffset"; for (int i = 0; i < targetObjs.Length; i++) { curEditTarget = (AreaTargetTracker)targetObjs[i]; Undo.RecordObject(curEditTarget, undo_message); if (curEditTarget.area != null) // Only works at runtime. { Undo.RecordObject(curEditTarget.area.transform, undo_message); } curEditTarget.areaPositionOffset = this.areaPositionOffset.vector3Value; } } EditorGUI.BeginChangeCheck(); content = new GUIContent ( "Rotation Offset", "An optional rotational offset for the area." ); EditorGUILayout.PropertyField(this.areaRotationOffset, content); // If changed, trigger the property setter for all objects being edited if (EditorGUI.EndChangeCheck()) { string undo_message = targetObjs[0].GetType() + " areaPositionOffset"; for (int i = 0; i < targetObjs.Length; i++) { curEditTarget = (AreaTargetTracker)targetObjs[i]; Undo.RecordObject(curEditTarget, undo_message); if (curEditTarget.area != null) // Only works at runtime. { Undo.RecordObject(curEditTarget.area.transform, undo_message); } curEditTarget.areaRotationOffset = this.areaRotationOffset.vector3Value; } } } EditorGUI.indentLevel -= 1; GUILayout.Space(8); content = new GUIContent ( "Debug Level", "Set it higher to see more verbose information." ); EditorGUILayout.PropertyField(this.debugLevel, content); serializedObject.ApplyModifiedProperties(); // Flag Unity to save the changes to to the prefab to disk // This is needed to make the gizmos update immediatly. if (GUI.changed) { EditorUtility.SetDirty(target); } }
public override void OnInspectorGUI() { this.serializedObject.Update(); Object[] targetObjs = this.serializedObject.targetObjects; AngleLimitModifier curEditTarget; GUIContent content; EditorGUIUtility.labelWidth = PGEditorUtils.CONTROLS_DEFAULT_LABEL_WIDTH; EditorGUI.indentLevel = 0; EditorGUI.BeginChangeCheck(); content = new GUIContent ( "Origin", "The transform used to determine alignment. If not used, this will be the transform " + "of the GameObject this component is attached to." ); EditorGUILayout.PropertyField(this.origin, content); // If changed, trigger the property setter for all objects being edited if (EditorGUI.EndChangeCheck()) { for (int i = 0; i < targetObjs.Length; i++) { curEditTarget = (AngleLimitModifier)targetObjs[i]; Undo.RecordObject(curEditTarget, targetObjs[0].GetType() + " origin"); curEditTarget.origin = (Transform)this.origin.objectReferenceValue; } } EditorGUILayout.BeginHorizontal(); EditorGUIUtility.labelWidth = 106; content = new GUIContent ( "Angle Tolerance", "If waitForAlignment is true: If the emitter is pointing towards " + "the target within this angle in degrees, the target can be fired on." ); EditorGUILayout.PropertyField(this.angle, content); EditorGUIUtility.labelWidth = PGEditorUtils.CONTROLS_DEFAULT_LABEL_WIDTH; content = new GUIContent ( "Flat Comparison", "If false the actual angles will be compared for alignment. " + "(More precise. Emitter must point at target.)\n" + "If true, only the direction matters. " + "(Good when turning in a direction but perfect alignment isn't needed.)" ); PGEditorUtils.ToggleButton(this.flatAngleCompare, content, 88); EditorGUILayout.EndHorizontal(); if (this.flatAngleCompare.boolValue) { EditorGUI.indentLevel += 1; EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); // To make the rest of the row right-justified content = new GUIContent ( "Flatten Axis", "The axis to flatten when comparing angles to see if alignment has occurred. " + "For example, for a 2D game, this should be Z. For a 3D game that wants to " + "ignore altitude, set this to Y." ); EditorGUILayout.PropertyField(this.flatCompareAxis, content, GUILayout.Width(228)); EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel -= 1; } content = new GUIContent ( "Filter Type", "Determines if filtering will be performed on a TargetTracker's targets or an " + "EventTrigger's targets. See the component description for more detail. This is" + "ignored unless a its GameObject has both. Otherwise the mode will be " + "auto-detected." ); EditorGUILayout.PropertyField(this.filterType, content); GUILayout.Space(4); content = new GUIContent ( "Debug Level", "Set it higher to see more verbose information." ); EditorGUILayout.PropertyField(this.debugLevel, content); serializedObject.ApplyModifiedProperties(); // Flag Unity to save the changes to to the prefab to disk // This is needed to make the gizmos update immediatly. if (GUI.changed) { EditorUtility.SetDirty(target); } }
protected override void OnInspectorGUIUpdate() { base.OnInspectorGUIUpdate(); GUIContent content; GUILayout.BeginHorizontal(); content = new GUIContent("Position", "Option to match the target's position."); EditorGUILayout.PropertyField(this.position, content); if (this.position.boolValue) { PGEditorUtils.ToggleButton(this.outputPosX, new GUIContent("X", "Toggle Costraint for this axis."), 24); PGEditorUtils.ToggleButton(this.outputPosY, new GUIContent("Y", "Toggle Costraint for this axis."), 24); PGEditorUtils.ToggleButton(this.outputPosZ, new GUIContent("Z", "Toggle Costraint for this axis."), 24); GUILayout.EndHorizontal(); EditorGUI.indentLevel += 1; content = new GUIContent("interpolation Mode", "Option to match the target's position."); EditorGUILayout.PropertyField(this.pos_interp, content); var posInterp = (SmoothTransformConstraint.INTERP_OPTIONS_POS) this.pos_interp.enumValueIndex; switch (posInterp) { case SmoothTransformConstraint.INTERP_OPTIONS_POS.DampLimited: content = new GUIContent("Time", "roughly how long it takes to match the target (lag)."); EditorGUILayout.PropertyField(this.positionSpeed, content); content = new GUIContent("Max Speed", "The speed limit. Causes more constant motion."); EditorGUILayout.PropertyField(this.positionMaxSpeed, content); break; case SmoothTransformConstraint.INTERP_OPTIONS_POS.Damp: content = new GUIContent("Time", "roughly how long it takes to match the target (lag)."); EditorGUILayout.PropertyField(this.positionSpeed, content); break; default: content = new GUIContent("Percent", "Controls lag."); EditorGUILayout.PropertyField(this.positionSpeed, content); break; } EditorGUI.indentLevel -= 1; } else { GUILayout.EndHorizontal(); } content = new GUIContent("Rotation", "Option to match the target's rotation."); EditorGUILayout.PropertyField(this.rotation, content); if (this.rotation.boolValue) { EditorGUI.indentLevel += 1; content = new GUIContent("Output", "Used to alter the way the rotations are set."); EditorGUILayout.PropertyField(this.output, content); content = new GUIContent ( "Interpolation Mode", "The type of rotation calculation to use. Linear is faster but spherical is more stable when " + "rotations make large adjustments.." ); EditorGUILayout.PropertyField(this.interpolation, content); content = new GUIContent("Speed", "How fast to rotate. Appears different depending on Mode."); EditorGUILayout.PropertyField(this.rotationSpeed, content); EditorGUI.indentLevel -= 1; } content = new GUIContent("Scale", "Option to match the target's scale."); EditorGUILayout.PropertyField(this.scale, content); if (this.scale.boolValue) { EditorGUI.indentLevel += 1; content = new GUIContent("Percent", "Controls lag."); EditorGUILayout.PropertyField(this.scaleSpeed, content); EditorGUI.indentLevel -= 1; } }
public override void OnInspectorGUI() { this.serializedObject.Update(); GUIContent content; EditorGUI.indentLevel = 0; EditorGUIUtility.labelWidth = PGEditorUtils.CONTROLS_DEFAULT_LABEL_WIDTH; Object[] targetObjs = this.serializedObject.targetObjects; EventTrigger curEditTarget; if (InstanceManager.POOLING_ENABLED) { content = new GUIContent ( "PoolName", "The name of a pool to be used with PoolManager or other pooling solution. If " + "not using pooling, this will do nothing and be hidden in the Inspector. " ); EditorGUILayout.PropertyField(this.poolName, content); } content = new GUIContent ( "Hit Layers", "The layers in which the Area is allowed to find targets." ); EditorGUILayout.PropertyField(this.targetLayers, content); content = new GUIContent ( "Hit Mode", "Determines what should cause this EventTrigger to fire.\n" + " TargetOnly\n" + " Only a direct hit will trigger the OnFire event\n" + " HitLayers\n" + " Contact with any colliders in any of the layers in\n" + " the HitLayers mask will trigger the OnFire event." ); EditorGUILayout.PropertyField(this.hitMode, content); content = new GUIContent ( "listenTimeout (0 = OFF)", "An optional timer to allow this EventTrigger to timeout and self-destruct. When " + "set to a value above zero, when this reaches 0, the Fire coroutine will be " + "started and anything in range may be hit (depending on settings). This can be " + "used to give a projectile a max amount of time it can fly around before it " + "dies, or a time-based land mine or pick-up." ); EditorGUILayout.PropertyField(this.listenTimeout, content); content = new GUIContent ( "Fire On Spawn", "If true, the event will be fired as soon as this EventTrigger is spawned by " + "instantiation or pooling." ); EditorGUILayout.PropertyField(this.fireOnSpawn, content); content = new GUIContent ( "Fire On Sleep", "If this EventTrigger has a rigidbody, setting this to true will cause it to " + "fire if it falls asleep. See Unity's docs for more information on how " + "this happens." ); EditorGUILayout.PropertyField(this.fireOnRigidBodySleep, content); content = new GUIContent ( "Area Hit", "If true, more than just the primary target will be affected when this EventTrigger " + "fires. Use the range options to determine the behavior." ); EditorGUILayout.PropertyField(this.areaHit, content); // To make the gizmo delay work correctly, update the GUI here. serializedObject.ApplyModifiedProperties(); if (this.areaHit.boolValue) { this.overrideGizmoVisibility.boolValue = false; EditorGUI.indentLevel += 1; content = new GUIContent( "Targets (-1 = all)", "The number of targets to return. Set to -1 to return all targets" ); EditorGUILayout.PropertyField(this.numberOfTargets, content); content = new GUIContent("Sorting Style", "The style of sorting to use"); EditorGUILayout.PropertyField(this.sortingStyle, content); var sortingStyle = (EventTrigger.SORTING_STYLES) this.sortingStyle.enumValueIndex; if (sortingStyle != EventTrigger.SORTING_STYLES.None) { EditorGUI.indentLevel += 1; content = new GUIContent( "Minimum Interval", "How often the target list will be sorted. If set to 0, " + "sorting will only be triggered when Targets enter or exit range." ); EditorGUILayout.PropertyField(this.updateInterval, content); EditorGUI.indentLevel -= 1; } EditorGUI.BeginChangeCheck(); content = new GUIContent ( "Area Layer", "The layer to put the Area in." ); content = EditorGUI.BeginProperty(new Rect(0, 0, 0, 0), content, this.areaLayer); int layer = EditorGUILayout.LayerField(content, this.areaLayer.intValue); // If changed, trigger the property setter for all objects being edited if (EditorGUI.EndChangeCheck()) { for (int i = 0; i < targetObjs.Length; i++) { curEditTarget = (EventTrigger)targetObjs[i]; Undo.RecordObject(curEditTarget, targetObjs[0].GetType() + " Area Layer"); curEditTarget.areaLayer = layer; } } EditorGUI.EndProperty(); EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); content = new GUIContent ( "Area Shape", "The shape of the Area used to detect targets in range" ); EditorGUILayout.PropertyField(this.areaShape, content); // If changed, trigger the property setter for all objects being edited if (EditorGUI.EndChangeCheck()) { var shape = (AreaTargetTracker.AREA_SHAPES) this.areaShape.enumValueIndex; for (int i = 0; i < targetObjs.Length; i++) { curEditTarget = (EventTrigger)targetObjs[i]; Undo.RecordObject(curEditTarget, targetObjs[0].GetType() + " areaShape"); curEditTarget.areaShape = shape; } } content = new GUIContent ( "Gizmo ", "Visualize the Area in the Editor by turning this on." ); PGEditorUtils.ToggleButton(this.drawGizmo, content, 50); EditorGUILayout.EndHorizontal(); if (this.drawGizmo.boolValue) { EditorGUI.indentLevel += 1; EditorGUILayout.BeginHorizontal(); content = new GUIContent ( "Gizmo Color", "The color of the gizmo when displayed" ); EditorGUILayout.PropertyField(this.gizmoColor, content); // If clicked, reset the color to the default GUIStyle style = EditorStyles.miniButton; style.alignment = TextAnchor.MiddleCenter; style.fixedWidth = 52; if (GUILayout.Button("Reset", style)) { for (int i = 0; i < this.serializedObject.targetObjects.Length; i++) { curEditTarget = (EventTrigger)this.serializedObject.targetObjects[i]; curEditTarget.gizmoColor = curEditTarget.defaultGizmoColor; } } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel -= 1; GUILayout.Space(4); } content = new GUIContent ( "Duration (<0 = stay)", "An optional duration to control how long this EventTrigger stays active. " + "Each target will only be hit once with the event notification unless the " + "Target leaves and then re-enters range. Set this to -1 to keep it alive " + "forever." ); EditorGUILayout.PropertyField(this.duration, content); serializedObject.ApplyModifiedProperties(); if (this.duration.floatValue > 0) { EditorGUI.indentLevel += 1; content = new GUIContent ( "Start Range", "When duration is greater than 0 this can be used have the range change " + "over the course of the duration. This is used for things like a " + "chockwave from a large explosion, which grows over time. " ); content = EditorGUI.BeginProperty(new Rect(0, 0, 0, 0), content, this.startRange); EditorGUI.BeginChangeCheck(); Vector3 startRange = this.startRange.vector3Value; switch ((AreaTargetTracker.AREA_SHAPES) this.areaShape.enumValueIndex) { case AreaTargetTracker.AREA_SHAPES.Circle2D: // Fallthrough case AreaTargetTracker.AREA_SHAPES.Sphere: startRange.x = EditorGUILayout.FloatField(content, startRange.x); startRange.y = startRange.x; startRange.z = startRange.x; break; case AreaTargetTracker.AREA_SHAPES.Box2D: float oldZ = startRange.z; startRange = EditorGUILayout.Vector2Field(content.text, startRange); startRange.z = oldZ; // Nice to maintain if switching between 2D and 3D break; case AreaTargetTracker.AREA_SHAPES.Box: startRange = EditorGUILayout.Vector3Field(content.text, startRange); break; case AreaTargetTracker.AREA_SHAPES.Capsule: startRange = EditorGUILayout.Vector2Field(content.text, startRange); startRange.z = startRange.x; break; } // Only assign the value back if it was actually changed by the user. // Otherwise a single value will be assigned to all objects when multi-object // editing, even when the user didn't touch the control. if (EditorGUI.EndChangeCheck()) { this.startRange.vector3Value = startRange; } EditorGUI.EndProperty(); EditorGUI.indentLevel -= 1; } this.displayRange <EventTrigger>(targetObjs); EditorGUI.BeginChangeCheck(); content = new GUIContent ( "Position Offset", "An optional position offset for the Area. For example, if you have an" + "object resting on the ground which has a range of 4, a position offset of" + "Vector3(0, 4, 0) will place your Area so it is also sitting on the ground." ); EditorGUILayout.PropertyField(this.areaPositionOffset, content); // If changed, trigger the property setter for all objects being edited if (EditorGUI.EndChangeCheck()) { string undo_message = targetObjs[0].GetType() + " areaPositionOffset"; for (int i = 0; i < targetObjs.Length; i++) { curEditTarget = (EventTrigger)targetObjs[i]; Undo.RecordObject(curEditTarget, undo_message); curEditTarget.areaPositionOffset = this.areaPositionOffset.vector3Value; } } EditorGUI.BeginChangeCheck(); content = new GUIContent ( "Rotation Offset", "An optional rotational offset for the Area." ); EditorGUILayout.PropertyField(this.areaRotationOffset, content); // If changed, trigger the property setter for all objects being edited if (EditorGUI.EndChangeCheck()) { string undo_message = targetObjs[0].GetType() + " areaPositionOffset"; for (int i = 0; i < targetObjs.Length; i++) { curEditTarget = (EventTrigger)targetObjs[i]; Undo.RecordObject(curEditTarget, undo_message); curEditTarget.areaRotationOffset = this.areaRotationOffset.vector3Value; } } GUILayout.Space(8); } else { this.overrideGizmoVisibility.boolValue = true; } content = new GUIContent ( "Notify Targets", "Sets the target notification behavior. Telling targets they are hit is optional " + "for situations where a delayed response is required, such as launching a , " + "projectile or for custom handling.\n" + "\n" + "MODES\n" + " Off\n" + " Do not notify anything. delegates can still be used\n" + " for custom handling\n" + " Direct\n" + " OnFire targets will be notified immediately\n" + " PassInfoToEventTrigger\n" + " For every Target hit, a new EventTrigger will be\n" + " spawned and passed this EventTrigger's \n" + " EventInfo. PassToEventTriggerOnce is more \n" + " commonly used when secondary EventTrigger is\n" + " needed, but this can be used for some creative\n" + " or edge use-cases.\n" + " PassInfoToEventTriggerOnce\n" + " OnFire a new EventTrigger will be spawned and\n" + " passed this EventTrigger's EventInfo. Only 1 will\n" + " be spawned. This is handy for making bombs \n" + " where only the first Target would trigger the \n" + " event and only 1 EventTrigger would be spawned\n" + " to expand over time (using duration and start\n" + " range attributes).\n" + " UseEventTriggerInfo\n" + " Same as PassInfoToEventTrigger but the new\n" + " EventTrigger will use its own EventInfo (this \n" + " EventTrigger's EventInfo will be ignored).\n" + " UseEventTriggerInfoOnce\n" + " Same as PassInfoToEventTriggerOnce but the new\n" + " EventTrigger will will used its own EventInfo\n" + " (this EventTrigger's EventInfo will be ignored)." ); EditorGUILayout.PropertyField(this.notifyTargets, content); // // If using EventTrigger... // EventTrigger.NOTIFY_TARGET_OPTIONS curOption; curOption = (EventTrigger.NOTIFY_TARGET_OPTIONS) this.notifyTargets.enumValueIndex; if (curOption > EventTrigger.NOTIFY_TARGET_OPTIONS.Direct) { EditorGUI.indentLevel += 1; content = new GUIContent ( "EventTrigger Prefab", "An optional prefab to instance another EventTrigger. This can be handy if you " + "want to use a 'one-shot' event trigger to then spawn one that expands over " + "time using the duration and startRange to simulate a huge explosion." ); EditorGUILayout.PropertyField(this.eventTriggerPrefab, content); if (InstanceManager.POOLING_ENABLED) { EditorGUI.indentLevel += 1; if (this.eventTriggerPrefab.objectReferenceValue != null) { content = new GUIContent ( "Use Pooling", "If false, do not add the new instance to a pool. Use Unity's " + "Instantiate/Destroy" ); EditorGUILayout.PropertyField(this.usePooling, content); if (this.usePooling.boolValue) { content = new GUIContent ( "Override Pool Name", "If an eventTriggerPrefab is spawned, setting this to true will " + "override the EventTrigger's poolName and use this instead. The " + "instance will also be passed this EventTrigger's " + "eventTriggerPoolName to be used when the EventTrigger is " + "desapwned." ); EditorGUILayout.PropertyField(this.overridePoolName, content); if (this.overridePoolName.boolValue) { content = new GUIContent ( "Pool Name", "The name of a pool to be used with PoolManager or other " + "pooling solution. If not using pooling, this will do " + "nothing and be hidden in the Inspector.\n" + "WARNING: If poolname is set to '', Pooling will be " + "disabled and Unity's Instantiate will be used." ); EditorGUILayout.PropertyField(this.eventTriggerPoolName, content); } } EditorGUI.indentLevel -= 1; } else { this.overridePoolName.boolValue = false; // Reset } } EditorGUI.indentLevel -= 1; } if (curOption < EventTrigger.NOTIFY_TARGET_OPTIONS.UseEventTriggerInfo) { if (this.serializedObject.isEditingMultipleObjects) { content = new GUIContent ( "Event Info List", "A list of EventInfo structs which hold one or more event descriptions of how " + "this EventTrigger can affect a Target." ); EditorGUILayout.PropertyField(this.eventInfoList, content, true); } else { EditorGUI.indentLevel += 2; curEditTarget = (EventTrigger)targetObjs[0]; this.expandEventInfo = PGEditorUtils.SerializedObjFoldOutList <EventInfoListGUIBacker> ( "Event Info List", curEditTarget._eventInfoList, this.expandEventInfo, ref curEditTarget._editorListItemStates, true ); EditorGUI.indentLevel -= 2; } } GUILayout.Space(4); content = new GUIContent ( "Debug Level", "Set it higher to see more verbose information." ); EditorGUILayout.PropertyField(this.debugLevel, content); serializedObject.ApplyModifiedProperties(); // Flag Unity to save the changes to to the prefab to disk // This is needed to make the gizmos update immediatly. if (GUI.changed) { EditorUtility.SetDirty(target); } }