public override void OnInspectorGUI() { var script = (SpawnPool)target; EditorGUI.indentLevel = 0; PGEditorUtils.LookLikeControls(); script.poolName = EditorGUILayout.TextField("Pool Name", script.poolName); script.matchPoolScale = EditorGUILayout.Toggle("Match Pool Scale", script.matchPoolScale); script.matchPoolLayer = EditorGUILayout.Toggle("Match Pool Layer", script.matchPoolLayer); script.dontReparent = EditorGUILayout.Toggle("Don't Reparent", script.dontReparent); script.dontDestroyOnLoad = EditorGUILayout.Toggle("Don't Destroy On Load", script.dontDestroyOnLoad); script.logMessages = EditorGUILayout.Toggle("Log Messages", script.logMessages); this.expandPrefabs = PGEditorUtils.SerializedObjFoldOutList <PrefabPool> ( "Per-Prefab Pool Options", script._perPrefabPoolOptions, this.expandPrefabs, ref script._editorListItemStates, true ); // Flag Unity to save the changes to to the prefab to disk if (GUI.changed) { EditorUtility.SetDirty(target); } }
public override void OnInspectorGUI() { var script = (Targetable)target; EditorGUI.indentLevel = 0; PGEditorUtils.LookLikeControls(); script.debugLevel = PGEditorUtils.EnumPopup <DEBUG_LEVELS>("Debug Level", script.debugLevel); // Flag Unity to save the changes to to the prefab to disk if (GUI.changed) { EditorUtility.SetDirty(target); } }
public override void OnInspectorGUI() { var script = (PreRuntimePoolItem)target; EditorGUI.indentLevel = 0; PGEditorUtils.LookLikeControls(); script.poolName = EditorGUILayout.TextField("Pool Name", script.poolName); script.prefabName = EditorGUILayout.TextField("Prefab Name", script.prefabName); script.despawnOnStart = EditorGUILayout.Toggle("Despawn On Start", script.despawnOnStart); script.doNotReparent = EditorGUILayout.Toggle("Do Not Reparent", script.doNotReparent); // Flag Unity to save the changes to to the prefab to disk if (GUI.changed) { EditorUtility.SetDirty(target); } }
public override void OnInspectorGUI() { var script = (TargetTracker)target; EditorGUI.indentLevel = 1; PGEditorUtils.LookLikeControls(); script.numberOfTargets = EditorGUILayout.IntField("Targets (-1 for all)", script.numberOfTargets); script.targetLayers = PGEditorUtils.LayerMaskField("Target Layers", script.targetLayers); script.sortingStyle = PGEditorUtils.EnumPopup <TargetTracker.SORTING_STYLES> ( "Sorting Style", script.sortingStyle ); if (script.sortingStyle != TargetTracker.SORTING_STYLES.None) { EditorGUI.indentLevel = 2; script.sortInterval = EditorGUILayout.FloatField("Minimum Interval", script.sortInterval); EditorGUI.indentLevel = 1; } EditorGUI.indentLevel = 0; this.showPerimeter = EditorGUILayout.Foldout(this.showPerimeter, "Perimeter Settings"); if (this.showPerimeter) { EditorGUI.indentLevel = 2; script.perimeterLayer = EditorGUILayout.LayerField("Perimeter Layer", script.perimeterLayer); EditorGUILayout.BeginHorizontal(); // Only trigger the update if it actually changes. This runs code in a peroperty // that may be expensive var shape = script.perimeterShape; shape = PGEditorUtils.EnumPopup <TargetTracker.PERIMETER_SHAPES>("Perimeter Shape", shape); if (shape != script.perimeterShape) { script.perimeterShape = shape; } GUILayout.Label("Gizmo", GUILayout.MaxWidth(40)); script.drawGizmo = EditorGUILayout.Toggle(script.drawGizmo, GUILayout.MaxWidth(47)); EditorGUILayout.EndHorizontal(); if (script.drawGizmo) { EditorGUI.indentLevel = 3; EditorGUILayout.BeginHorizontal(); script.gizmoColor = EditorGUILayout.ColorField("Gizmo Color", script.gizmoColor); GUIStyle style = EditorStyles.miniButton; style.alignment = TextAnchor.MiddleCenter; style.fixedWidth = 52; bool clicked = GUILayout.Toggle(false, "Reset", style); if (clicked) { script.gizmoColor = script.defaultGizmoColor; } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel = 2; GUILayout.Space(4); } Vector3 range = script.range; switch (script.perimeterShape) { case TargetTracker.PERIMETER_SHAPES.Sphere: range.x = EditorGUILayout.FloatField("Range", range.x); range.y = range.x; range.z = range.x; break; case TargetTracker.PERIMETER_SHAPES.Box: range = EditorGUILayout.Vector3Field("Range", range); break; case TargetTracker.PERIMETER_SHAPES.Capsule: range = EditorGUILayout.Vector2Field("Range", range); range.z = range.x; break; } script.range = range; script.perimeterPositionOffset = EditorGUILayout.Vector3Field("Position Offset", script.perimeterPositionOffset); script.perimeterRotationOffset = EditorGUILayout.Vector3Field("Rotation Offset", script.perimeterRotationOffset); } EditorGUI.indentLevel = 1; GUILayout.Space(4); script.debugLevel = (DEBUG_LEVELS)EditorGUILayout.EnumPopup("Debug Level", (System.Enum)script.debugLevel); // Flag Unity to save the changes to to the prefab to disk if (GUI.changed) { EditorUtility.SetDirty(target); } }
public override void OnInspectorGUI() { var script = (TargetProMessenger)target; EditorGUI.indentLevel = 1; PGEditorUtils.LookLikeControls(); script.otherTarget = PGEditorUtils.ObjectField <GameObject> ( "Other Message Target (Optional)", script.otherTarget ); script.forComponent = (TargetProMessenger.COMPONENTS)EditorGUILayout.EnumPopup ( new GUIContent("For Component", "Choose which component's events to use"), script.forComponent ); script.messageMode = (TargetProMessenger.MESSAGE_MODE)EditorGUILayout.EnumPopup ( new GUIContent("Message Mode", "SendMessage will only send to this GameObject"), script.messageMode ); // Change the label spacing EditorGUIUtility.LookLikeControls(220); EditorGUI.indentLevel = 3; if (script.forComponent == TargetProMessenger.COMPONENTS.FireController) { script.fireController_OnStart = EditorGUILayout.Toggle("FireController_OnStart", script.fireController_OnStart); script.fireController_OnUpdate = EditorGUILayout.Toggle("FireController_OnUpdate", script.fireController_OnUpdate); script.fireController_OnTargetUpdate = EditorGUILayout.Toggle("FireController_OnTargetUpdate", script.fireController_OnTargetUpdate); script.fireController_OnIdleUpdate = EditorGUILayout.Toggle("FireController_OnIdleUpdate", script.fireController_OnIdleUpdate); script.fireController_OnFire = EditorGUILayout.Toggle("FireController_OnFire", script.fireController_OnFire); script.fireController_OnStop = EditorGUILayout.Toggle("FireController_OnStop", script.fireController_OnStop); } else if (script.forComponent == TargetProMessenger.COMPONENTS.Projectile) { script.projectile_OnLaunched = EditorGUILayout.Toggle("Projectile_OnLaunched", script.projectile_OnLaunched); script.projectile_OnLaunchedUpdate = EditorGUILayout.Toggle("Projectile_OnLaunchedUpdate", script.projectile_OnLaunchedUpdate); script.projectile_OnDetonation = EditorGUILayout.Toggle("Projectile_OnDetonation", script.projectile_OnDetonation); } else if (script.forComponent == TargetProMessenger.COMPONENTS.Targetable) { script.targetable_OnHit = EditorGUILayout.Toggle("Targetable_OnHit", script.targetable_OnHit); script.targetable_OnDetected = EditorGUILayout.Toggle("Targetable_OnDetected", script.targetable_OnDetected); script.targetable_OnNotDetected = EditorGUILayout.Toggle("Targetable_OnNotDetected", script.targetable_OnNotDetected); } EditorGUI.indentLevel = 1; GUILayout.Space(4); // Change the label spacing back PGEditorUtils.LookLikeControls(); script.debugLevel = PGEditorUtils.EnumPopup <DEBUG_LEVELS>("Debug Level", script.debugLevel); // Flag Unity to save the changes to to the prefab to disk if (GUI.changed) { EditorUtility.SetDirty(target); } }
public override void OnInspectorGUI() { var script = (Detonator)target; GUIStyle style; PGEditorUtils.LookLikeControls(); EditorGUI.indentLevel = 1; script.targetLayers = PGEditorUtils.LayerMaskField ( "Hit Layers", script.targetLayers ); script.perimeterLayer = EditorGUILayout.LayerField("Range Layer", script.perimeterLayer); EditorGUILayout.BeginHorizontal(); // Only trigger the update if it actually changes. This runs code in a peroperty // that may be expensive var shape = script.perimeterShape; shape = PGEditorUtils.EnumPopup <TargetTracker.PERIMETER_SHAPES>("Detonation Shape", shape); if (shape != script.perimeterShape) { script.perimeterShape = shape; } script.overrideGizmoVisibility = false; GUILayout.Label("Gizmo", GUILayout.MaxWidth(40)); script.drawGizmo = EditorGUILayout.Toggle(script.drawGizmo, GUILayout.MaxWidth(47)); EditorGUILayout.EndHorizontal(); if (script.drawGizmo) { EditorGUI.indentLevel = 3; EditorGUILayout.BeginHorizontal(); script.gizmoColor = EditorGUILayout.ColorField("Gizmo Color", script.gizmoColor); style = EditorStyles.miniButton; style.alignment = TextAnchor.MiddleCenter; style.fixedWidth = 52; bool clicked = GUILayout.Toggle(false, "Reset", style); if (clicked) { script.gizmoColor = script.defaultGizmoColor; } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel = 2; GUILayout.Space(4); } script.durration = EditorGUILayout.FloatField("Expand Durration", script.durration); // Display some information GUILayout.Space(6); style = new GUIStyle(EditorStyles.label); style.wordWrap = true; style.fontStyle = FontStyle.Italic; GUILayout.Label ( "If spawned by a projectile, " + "the folowing range and effects are inherited from the projectile...", style ); Vector3 range = script.range; switch (script.perimeterShape) { case TargetTracker.PERIMETER_SHAPES.Sphere: range.x = EditorGUILayout.FloatField("Max Range", range.x); range.y = range.x; range.z = range.x; break; case TargetTracker.PERIMETER_SHAPES.Box: range = EditorGUILayout.Vector3Field("Max Range", range); break; case TargetTracker.PERIMETER_SHAPES.Capsule: range = EditorGUILayout.Vector2Field("Max Range", range); range.z = range.x; break; } script.range = range; GUILayout.Space(6); this.expandEffects = PGEditorUtils.SerializedObjFoldOutList <HitEffectGUIBacker> ( "EffectOnTargets", script._effectsOnTarget, this.expandEffects, ref script._editorListItemStates, true ); GUILayout.Space(4); script.debugLevel = (DEBUG_LEVELS)EditorGUILayout.EnumPopup("Debug Level", (System.Enum)script.debugLevel); // Flag Unity to save the changes to to the prefab to disk if (GUI.changed) { EditorUtility.SetDirty(target); } }
public override void OnInspectorGUI() { var script = (FireController)target; GUIContent content; EditorGUI.indentLevel = 1; PGEditorUtils.LookLikeControls(); content = new GUIContent("Interval", "Fire every X seconds"); script.interval = EditorGUILayout.FloatField(content, script.interval); content = new GUIContent ( "Init Countdown at 0", "Able to fire immediatly when first spawned, before interval count begins" ); script.initIntervalCountdownAtZero = EditorGUILayout.Toggle(content, script.initIntervalCountdownAtZero); content = new GUIContent ( "Wait For Alignment", "Wait for the emitter to line up with the target before fireing. The " + "count will continue so this will fire as soon as possible." ); script.waitForAlignment = EditorGUILayout.Toggle(content, script.waitForAlignment); if (script.waitForAlignment) { EditorGUI.indentLevel = 2; script.emitter = PGEditorUtils.ObjectField <Transform>("Emitter (Optional)", script.emitter); 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." ); script.lockOnAngleTolerance = EditorGUILayout.FloatField(content, script.lockOnAngleTolerance); content = new GUIContent ( "Flat Comparison", "If false the true 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.)" ); script.flatAngleCompare = EditorGUILayout.Toggle(content, script.flatAngleCompare); EditorGUI.indentLevel = 1; } script.notifyTargets = PGEditorUtils.EnumPopup <FireController.NOTIFY_TARGET_OPTIONS> ( "Notify Targets", script.notifyTargets ); if (script.notifyTargets > FireController.NOTIFY_TARGET_OPTIONS.Off) { script.ammoPrefab = PGEditorUtils.ObjectField <Transform> ( "Ammo (Optional)", script.ammoPrefab ); } EditorGUI.indentLevel = 2; this.expandEffects = PGEditorUtils.SerializedObjFoldOutList <HitEffectGUIBacker> ( "EffectOnTargets", script._effectsOnTarget, this.expandEffects, ref script._editorListItemStates, true ); EditorGUI.indentLevel = 1; GUILayout.Space(4); script.debugLevel = PGEditorUtils.EnumPopup <DEBUG_LEVELS>("Debug Level", script.debugLevel); // Flag Unity to save the changes to to the prefab to disk if (GUI.changed) { EditorUtility.SetDirty(target); } }
// Use this for initialization public override void OnInspectorGUI() { FontAnalyse script = (FontAnalyse)target; EditorGUI.indentLevel = 0; PGEditorUtils.LookLikeControls(); Rect sfxPathRect = EditorGUILayout.GetControlRect(); // 用刚刚获取的文本输入框的位置和大小参数,创建一个文本输入框,用于输入特效路径 EditorGUI.TextField(sfxPathRect, "ImgPath", script.ImgPath); // 判断当前鼠标正拖拽某对象或者在拖拽的过程中松开了鼠标按键 // 同时还需要判断拖拽时鼠标所在位置处于文本输入框内 if ((Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragExited) && sfxPathRect.Contains(Event.current.mousePosition)) { // 判断是否拖拽了文件 if (DragAndDrop.paths != null && DragAndDrop.paths.Length > 0) { string sfxPath = DragAndDrop.paths [0]; // 拖拽的过程中,松开鼠标之后,拖拽操作结束,此时就可以使用获得的 sfxPath 变量了 #if UNITY_EDITOR_OSX if (!string.IsNullOrEmpty(sfxPath) && Event.current.type == EventType.DragExited) { #else if (!string.IsNullOrEmpty(sfxPath) && Event.current.type == EventType.DragUpdated) { #endif DragAndDrop.AcceptDrag(); script.ImgPath = common.TextUtil.cut(sfxPath, "Resources/", false, false); } } } sfxPathRect = EditorGUILayout.GetControlRect(); // 用刚刚获取的文本输入框的位置和大小参数,创建一个文本输入框,用于输入特效路径 EditorGUI.TextField(sfxPathRect, "DataPath", script.DataPath); // 判断当前鼠标正拖拽某对象或者在拖拽的过程中松开了鼠标按键 // 同时还需要判断拖拽时鼠标所在位置处于文本输入框内 if ((Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragExited) && sfxPathRect.Contains(Event.current.mousePosition)) { // 判断是否拖拽了文件 if (DragAndDrop.paths != null && DragAndDrop.paths.Length > 0) { string sfxPath = DragAndDrop.paths [0]; // 拖拽的过程中,松开鼠标之后,拖拽操作结束,此时就可以使用获得的 sfxPath 变量了 #if UNITY_EDITOR_OSX if (!string.IsNullOrEmpty(sfxPath) && Event.current.type == EventType.DragExited) { #else if (!string.IsNullOrEmpty(sfxPath) && Event.current.type == EventType.DragUpdated) { #endif DragAndDrop.AcceptDrag(); script.DataPath = common.TextUtil.cut(sfxPath, "Resources/", false, false); } } } script.advanceAddition = EditorGUILayout.IntField("advanceAddition", script.advanceAddition); script.pixelPerUnit = EditorGUILayout.FloatField("pixelPerUnit", script.pixelPerUnit); // // script.matchPoolScale = EditorGUILayout.Toggle("Match Pool Scale", script.matchPoolScale); // script.matchPoolLayer = EditorGUILayout.Toggle("Match Pool Layer", script.matchPoolLayer); // // script.dontReparent = EditorGUILayout.Toggle("Don't Reparent", script.dontReparent); // // script._dontDestroyOnLoad = EditorGUILayout.Toggle("Don't Destroy On Load", script._dontDestroyOnLoad); // // script.logMessages = EditorGUILayout.Toggle("Log Messages", script.logMessages); EditorGUILayout.BeginHorizontal(); // 1/2 the item button width GUILayout.Space(0); // Master add at end button. List items will insert if (GUILayout.Button(new GUIContent("Generate", "Click to generate data"), EditorStyles.toolbarButton)) { if (script.ImgPath != null && script.DataPath != null) { script.slice(script.ImgPath, script.DataPath); CharacterGroup[] groups = FindObjectsOfType <CharacterGroup>(); for (int i = 0; i < groups.Length; i++) { groups[i].setTextInEditor(false); } } } if (GUILayout.Button(new GUIContent("Clear", "Click to generate data"), EditorStyles.toolbarButton)) { script.clear(); } EditorGUILayout.EndHorizontal(); this.expandPrefabs = PGEditorUtils.SerializedObjFoldOutList <FontData> ( "Per-Prefab Pool Options", script.fontDataList, this.expandPrefabs, ref script._editorListItemStates, true ); // Flag Unity to save the changes to to the prefab to disk if (GUI.changed) { EditorUtility.SetDirty(target); } } }
public override void OnInspectorGUI() { var script = (LineOfSightModifier)target; PGEditorUtils.LookLikeControls(); EditorGUI.indentLevel = 1; // Display some information GUILayout.Space(6); GUIStyle style = new GUIStyle(EditorStyles.textField); style.wordWrap = true; style.fontStyle = FontStyle.Italic; style.padding = new RectOffset(4, 4, 4, 4); EditorGUILayout.LabelField ( "Add layers to activate LOS filtering.\n" + " - Target Tracker to ignore targets\n" + " - Fire Controller to hold fire", style ); script.targetTrackerLayerMask = PGEditorUtils.LayerMaskField ( "Target Tracker Mask", script.targetTrackerLayerMask ); // Might as well set the component if we are going to do GetComponent. // Also works as a singleton, not that it matters much in Editor scripts. if (script.fireCtrl == null) { script.fireCtrl = script.GetComponent <FireController>(); } if (script.fireCtrl) { script.fireControllerLayerMask = PGEditorUtils.LayerMaskField ( "Fire Controller Mask", script.fireControllerLayerMask ); } GUILayout.Space(6); script.testMode = PGEditorUtils.EnumPopup <LineOfSightModifier.TEST_MODE> ( "LOS Test Mode", script.testMode ); if (script.testMode == LineOfSightModifier.TEST_MODE.SixPoint) { EditorGUI.indentLevel = 2; script.radius = EditorGUILayout.FloatField("Radius", script.radius); EditorGUI.indentLevel = 1; } GUILayout.Space(4); script.debugLevel = (DEBUG_LEVELS)EditorGUILayout.EnumPopup("Debug Level", (System.Enum)script.debugLevel); // Flag Unity to save the changes to to the prefab to disk if (GUI.changed) { EditorUtility.SetDirty(target); } }
public override void OnInspectorGUI() { var script = (Projectile)target; PGEditorUtils.LookLikeControls(); GUIContent content; EditorGUI.indentLevel = 1; script.targetLayers = PGEditorUtils.LayerMaskField ( "Hit Layers", script.targetLayers ); script.detonationMode = PGEditorUtils.EnumPopup <Projectile.DETONATION_MODES> ( "Detonation Mode", script.detonationMode ); content = new GUIContent ( "Timer (0 = OFF)", "An optional timer (in seconds) to detonate this " + "projectile if it expires." ); script.timer = EditorGUILayout.FloatField(content, script.timer); content = new GUIContent ( "Detonate On Sleep", "If the projectile has a rigidbody, this will detonate it if it falls " + "asleep. See Unity's docs for more information on how this happens." ); script.detonateOnRigidBodySleep = EditorGUILayout.Toggle(content, script.detonateOnRigidBodySleep); content = new GUIContent("Area Hit", "True to an area, not just a single target"); script.areaHit = EditorGUILayout.Toggle(content, script.areaHit); if (script.areaHit) { EditorGUI.indentLevel = 2; script.numberOfTargets = EditorGUILayout.IntField("Targets (-1 for all)", script.numberOfTargets); script.sortingStyle = PGEditorUtils.EnumPopup <TargetTracker.SORTING_STYLES> ( "Sorting Style", script.sortingStyle ); if (script.sortingStyle != TargetTracker.SORTING_STYLES.None) { EditorGUI.indentLevel = 3; script.sortInterval = EditorGUILayout.FloatField("Min Interval", script.sortInterval); EditorGUI.indentLevel = 2; } script.perimeterLayer = EditorGUILayout.LayerField("Range Layer", script.perimeterLayer); EditorGUILayout.BeginHorizontal(); // Only trigger the update if it actually changes. This runs code in a peroperty // that may be expensive var shape = script.perimeterShape; shape = PGEditorUtils.EnumPopup <TargetTracker.PERIMETER_SHAPES>("Perimeter Shape", shape); if (shape != script.perimeterShape) { script.perimeterShape = shape; } script.overrideGizmoVisibility = false; GUILayout.Label("Gizmo", GUILayout.MaxWidth(40)); script.drawGizmo = EditorGUILayout.Toggle(script.drawGizmo, GUILayout.MaxWidth(47)); EditorGUILayout.EndHorizontal(); if (script.drawGizmo) { EditorGUI.indentLevel = 3; EditorGUILayout.BeginHorizontal(); script.gizmoColor = EditorGUILayout.ColorField("Gizmo Color", script.gizmoColor); GUIStyle style = EditorStyles.miniButton; style.alignment = TextAnchor.MiddleCenter; style.fixedWidth = 52; bool clicked = GUILayout.Toggle(false, "Reset", style); if (clicked) { script.gizmoColor = script.defaultGizmoColor; } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel = 2; GUILayout.Space(4); } Vector3 range = script.range; switch (script.perimeterShape) { case TargetTracker.PERIMETER_SHAPES.Sphere: range.x = EditorGUILayout.FloatField("Range", range.x); range.y = range.x; range.z = range.x; break; case TargetTracker.PERIMETER_SHAPES.Box: range = EditorGUILayout.Vector3Field("Range", range); break; case TargetTracker.PERIMETER_SHAPES.Capsule: range = EditorGUILayout.Vector2Field("Range", range); range.z = range.x; break; } script.range = range; //script.perimeterPositionOffset = EditorGUILayout.Vector3Field("Position Offset", script.perimeterPositionOffset); //script.perimeterRotationOffset = EditorGUILayout.Vector3Field("Rotation Offset", script.perimeterRotationOffset); GUILayout.Space(8); } else { script.overrideGizmoVisibility = true; } EditorGUI.indentLevel = 1; script.notifyTargets = PGEditorUtils.EnumPopup <Projectile.NOTIFY_TARGET_OPTIONS> ( "Notify Targets", script.notifyTargets ); script.detonationPrefab = PGEditorUtils.ObjectField <Transform> ( "Spawn On Detonation", script.detonationPrefab ); EditorGUI.indentLevel = 2; this.expandEffects = PGEditorUtils.SerializedObjFoldOutList <HitEffectGUIBacker> ( "EffectOnTargets (May be inherited)", script._effectsOnTarget, this.expandEffects, ref script._editorListItemStates, true ); GUILayout.Space(4); script.debugLevel = (DEBUG_LEVELS)EditorGUILayout.EnumPopup("Debug Level", (System.Enum)script.debugLevel); // Flag Unity to save the changes to to the prefab to disk if (GUI.changed) { EditorUtility.SetDirty(target); } }