public override void OnInspectorGUI() { TurretData script = target as TurretData; DrawDefaultInspector(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Parameters", EditorStyles.boldLabel); script.rangeOfView = EditorGUILayout.Slider("Range Of View", script.rangeOfView, 0.1f, 100f); script.targetLayerMask = EditorGUILayoutExtension.MappedMaskField("Target Layer Mask", script.targetLayerMask, this.users); EditorGUILayout.Space(); EditorGUILayout.LabelField("Aim", EditorStyles.boldLabel); script.aimOmega = EditorGUILayout.Slider("Aim Omega", script.aimOmega, 0.1f, 500f); script.aimDuration = EditorGUILayout.Slider("Aim Duration", script.aimDuration, 0f, 10f); script.aimTargetSmooth = EditorGUILayout.Slider("Aim Target Smooth", script.aimTargetSmooth, 0.001f, 10f); script.targetPrefab = EditorGUILayout.ObjectField("Target Prefab", script.targetPrefab, typeof(GameObject), false) as GameObject; EditorGUILayout.Space(); EditorGUILayout.LabelField("Wander", EditorStyles.boldLabel); script.wanderOmega = EditorGUILayout.Slider("Wander Omega", script.wanderOmega, 0.1f, 500f); script.wanderRotationDurationInterval = EditorGUILayoutExtension.IntervalField("Rotation duration interval", script.wanderRotationDurationInterval, new float[2]{0f, 10f}); script.wanderMaxPauseQuarter = EditorGUILayout.IntSlider("Maximum number of pause quarter", script.wanderMaxPauseQuarter, 1, 5); EditorGUILayout.Space(); EditorGUILayout.LabelField("Shoot", EditorStyles.boldLabel); script.loadDuration = EditorGUILayout.Slider("Load Duration", script.loadDuration, 0f, 5f); script.shootDelay = EditorGUILayout.Slider("After shoot delay", script.shootDelay, 0f, 5f); script.lazerPrefab = EditorGUILayout.ObjectField("Lazer Prefab", script.lazerPrefab, typeof(GameObject), false) as GameObject; script.loadPrefab = EditorGUILayout.ObjectField("Load Prefab", script.loadPrefab, typeof(GameObject), false) as GameObject; script.shootPrefab = EditorGUILayout.ObjectField("Shoot Prefab", script.shootPrefab, typeof(GameObject), false) as GameObject; script.haloPrefab = EditorGUILayout.ObjectField("Halo Prefab", script.haloPrefab, typeof(GameObject), false) as GameObject; EditorUtilityExtension.SetDirtyOnGUIChange(script); }
Status OpenNodeViewScriptStatus(DropdownMenuAction action) { if (EditorUtilityExtension.FindScriptFromType(GetType()) != null) { return(Status.Normal); } return(Status.Disabled); }
void OpenNodeViewScript() { var script = EditorUtilityExtension.FindScriptFromType(GetType()); if (script != null) { AssetDatabase.OpenAsset(script.GetInstanceID(), 0, 0); } }
public override void OnInspectorGUI() { RabbitData script = target as RabbitData; base.OnInspectorGUI(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Parameters", EditorStyles.boldLabel); script.speed = EditorGUILayout.Slider("Walk Speed", script.speed, 0.1f, 20f); script.maxStepDistance = EditorGUILayout.IntSlider("Max Step Distance", script.maxStepDistance, 1, 6); script.rangeOfView = EditorGUILayout.Slider("Range Of View", script.rangeOfView, 0f, 20f); EditorGUILayout.Space(); EditorGUILayout.LabelField("Jump", EditorStyles.boldLabel); script.jumpHeight = EditorGUILayout.Slider("Jump Height", script.jumpHeight, 0.1f, 5f); script.afterJumpTempoInterval = EditorGUILayoutExtension.IntervalField("After Jump Delay", script.afterJumpTempoInterval, AFTER_JUMP_MAGNITUDE); EditorUtilityExtension.SetDirtyOnGUIChange(script); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { LazerData script = target as LazerData; DrawDefaultInspector(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Mode", EditorStyles.boldLabel); script.mode = (LazerData.LazerMode)EditorGUILayout.EnumPopup("Lazer Mode", script.mode); EditorGUILayout.Space(); EditorGUILayout.LabelField("Parameters", EditorStyles.boldLabel); script.speed = EditorGUILayout.Slider("Speed", script.speed, 0.1f, 100f); script.lifetime = EditorGUILayout.Slider("Lifetime", script.lifetime, 0.01f, 100f); script.flatten = EditorGUILayout.Toggle("Flatten", script.flatten); script.bounce = EditorGUILayout.Toggle("Bounce", script.bounce); EditorGUILayout.Space(); EditorGUILayout.LabelField("Layer Mask", EditorStyles.boldLabel); script.hitLayerMask = EditorGUILayoutExtension.MappedMaskField("Hit Layer Mask", script.hitLayerMask, this.users); if (script.bounce) { script.bounceLayerMask = EditorGUILayoutExtension.MappedMaskField("Bounce Layer Mask", script.bounceLayerMask, script.hitLayerMask); } if (script.bounce) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Bounce", EditorStyles.boldLabel); script.maxBounceCount = EditorGUILayout.IntSlider("Max Bounce Count", script.maxBounceCount, 1, 200); script.lastBounceMode = (LastBounceMode)EditorGUILayout.EnumPopup("Last Bounce Mode", script.lastBounceMode); EditorGUI.indentLevel++; script.coneAngle = EditorGUILayout.Slider("Cone Angle", script.coneAngle, 0f, 45f); if (script.lastBounceMode == LastBounceMode.Curve || script.lastBounceMode == LastBounceMode.Random) { script.gravityForceMultiplier = EditorGUILayout.Slider("Gravity Force Multiplier", script.gravityForceMultiplier, 0f, 10f); script.forwardForceMultiplier = EditorGUILayout.Slider("Forward Force Multiplier", script.forwardForceMultiplier, 0f, 2f); script.forceDampling = EditorGUILayout.Slider("Force Dampling", script.forceDampling, 0f, 1f); } EditorGUI.indentLevel--; } EditorGUILayout.Space(); EditorGUILayout.LabelField("Effects", EditorStyles.boldLabel); script.lazerImpactPrefab = EditorGUILayout.ObjectField("Lazer Impact Prefab", script.lazerImpactPrefab, typeof(GameObject), false) as GameObject; script.groundImpactPrefab = EditorGUILayout.ObjectField("Ground Impact Prefab", script.groundImpactPrefab, typeof(GameObject), false) as GameObject; EditorGUILayout.Space(); EditorGUILayout.LabelField("Width", EditorStyles.boldLabel); script.width = EditorGUILayout.Slider("Width", script.width, 0.01f, 10f); script.widthSpeed = EditorGUILayout.Slider("Width Decrease Speed", script.widthSpeed, 0.01f, 10f); if (script.mode == LazerData.LazerMode.Shot) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Length", EditorStyles.boldLabel); script.length = EditorGUILayout.Slider("Length", script.length, 0.1f, 20f); // script.tailWidthPointLength = EditorGUILayout.Slider("Tail Width Point Length", script.tailWidthPointLength, 0f, script.length - 0.1f); // if(script.tailWidthPointLength > 0f) { // script.tailWidthPointSpacing = EditorGUILayout.Slider("Tail Width Point Spacing", script.tailWidthPointSpacing, 0f, script.tailWidthPointLength); // } } else { script.widthPointSpeed = EditorGUILayout.Slider("Width Point Decrease Speed", script.widthPointSpeed, 0.01f, 10f); temp = script.distancePerPointMinMax; temp = EditorGUILayout.Vector2Field("Distance Per Point Interval", temp); script.distancePerPointMinMax.Set(Mathf.RoundToInt(Mathf.Min(Mathf.Max(temp.x, 0f), temp.y)), Mathf.RoundToInt(Mathf.Max(temp.x, Mathf.Min(temp.y, 10f)))); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Auto Aim", EditorStyles.boldLabel); script.autoAim = EditorGUILayout.Toggle("Auto Aim", script.autoAim); if (script.autoAim) { script.autoAimRange = EditorGUILayout.Slider("Target Detection Radius", script.autoAimRange, 0f, 50f); script.autoAimThreshold = EditorGUILayout.Slider("Target Alignment Threshold", script.autoAimThreshold, 0f, 1f); script.autoAimLayerMask = EditorGUILayoutExtension.MappedMaskField("Target Layer Mask", script.autoAimLayerMask, script.hitLayerMask); } EditorUtilityExtension.SetDirtyOnGUIChange(script); }
public override void OnInspectorGUI() { this.script = target as PoolingData; DrawDefaultInspector(); EditorGUILayout.Space(); if (GUILayout.Button("ADD NEW POOL")) { script.AddAt(script.pools.Count); } if (GUILayout.Button("REMOVE ALL POOLS")) { script.pools.Clear(); } Rect rect = EditorGUILayout.GetControlRect(true, 0); Rect baserect = rect; EditorGUILayoutExtension.DragAndDropField(635, "", false, this.OnDrag, this.Rules); if (script.pools.Count == 0) { return; } baserect.y += 9; baserect.width = 50; baserect.height = 20; EditorGUI.LabelField(baserect, "Pool", EditorStyles.boldLabel); // Rect n = rect; // n.x += 30; // n.y += 450; // n.width = 200; // n.height = 20; // val = EditorGUI.FloatField(n, "Value", val); GUIStyle style = new GUIStyle(EditorStyles.label); GUIStyle n_style = new GUIStyle(EditorStyles.miniLabel); n_style.fontSize = 8; style.richText = true; PoolingData.Pool pool; baserect.y += 18; for (int i = 0; i < script.pools.Count; ++i) { pool = script.pools[i]; baserect.x = rect.x + -8; baserect.width = rect.width + 7; baserect.height = 21; EditorGUI.DrawRect(baserect, grey); baserect.x += 15; baserect.y += 3; baserect.width = 0; baserect.height = 15; pool.show = EditorGUI.Foldout(baserect, pool.show, ""); baserect.y += -1; baserect.width = 1000; baserect.height = 40; if (pool.prefab) { EditorGUI.LabelField(baserect, pool.prefab.name, style); baserect.x = EditorUtilityExtension.GetTextWidth(pool.prefab.name, EditorStyles.label) + 21; EditorGUI.LabelField(baserect, $"({pool.size})", n_style); } else { EditorGUI.LabelField(baserect, "<color=yellow>Empty</color>", style); } baserect.x = rect.width + -7; baserect.y += 1; baserect.width = 20; baserect.height = 20; if (GUI.Button(baserect, this.plusTexture, GUIStyle.none)) { script.AddAt(i + 1); return; } if (pool.show) { baserect.x = rect.width + -24; baserect.width = 16; baserect.height = 16; if (GUI.Button(baserect, this.trashTexture, GUIStyle.none)) { script.pools.RemoveAt(i); return; } baserect.x = rect.x + -8; baserect.y += 18; baserect.width = rect.width + 7; baserect.height = 46; EditorGUI.DrawRect(baserect, grey); baserect.x += 3; baserect.width += -6; baserect.height += -3; EditorGUI.DrawRect(baserect, dark); baserect.x += 1; baserect.y += 3; baserect.width = rect.width + -2; baserect.height = 17; EditorGUIUtility.labelWidth += -77; pool.prefab = EditorGUI.ObjectField(baserect, "Prefab", pool.prefab, typeof(GameObject), false) as GameObject; EditorGUIUtility.labelWidth += 1; baserect.y += 20; baserect.width = rect.width + -4; baserect.height = 17; pool.size = EditorGUI.IntSlider(baserect, "Size", pool.size, 1, 1000); baserect.y += 5; EditorGUIUtility.labelWidth += 76; } baserect.y += 21; script.pools[i] = pool; } EditorUtilityExtension.SetDirtyOnGUIChange(script); }
// private float val = 0f; public override void OnInspectorGUI() { InteractiveEngine script = target as InteractiveEngine; DrawDefaultInspector(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Elements", EditorStyles.boldLabel); Rect rect = EditorGUILayout.GetControlRect(true, 0); // Rect n = rect; // n.x += 30; // n.y += 600; // n.width = 200; // n.height = 20; // val = EditorGUI.FloatField(n, "Val", val); ChemicalToArrayData e; Rect elementrect = rect; Rect colorrect; if (script.inspector_showDetails == null || script.inspector_showDetails.Length != script.primaries.Count) { script.inspector_showDetails = new bool[script.primaries.Count]; } for (int i = 0; i < script.primaries.Count; ++i) { e = script.primaries[i]; elementrect.x = rect.x + 3; elementrect.width = rect.width + -15; elementrect.height = 22; colorrect = elementrect; colorrect.x += -3; colorrect.y += -3; colorrect.width += 6; colorrect.height += 6; EditorGUI.DrawRect(colorrect, grey); EditorGUI.DrawRect(elementrect, dark); elementrect.x += 18; elementrect.y += 3; elementrect.width = 200; elementrect.height = 20; script.inspector_showDetails[i] = EditorGUI.Foldout(elementrect, script.inspector_showDetails[i], e.element.ToString()); if (script.inspector_showDetails[i]) { elementrect.x += -18; elementrect.y += elementrect.height - 1; elementrect.width = rect.width + -15; elementrect.height = 40; colorrect = elementrect; colorrect.x += -3; colorrect.y += 3; colorrect.width += 6; EditorGUI.DrawRect(colorrect, grey); EditorGUI.DrawRect(elementrect, dark); this.builder.Clear(); this.builder.Append(e.array[0].ToString()); for (int j = 1; j < e.array.Length; ++j) { this.builder.Append(" + ").Append(e.array[j].ToString()); } elementrect.x += 9; elementrect.y += -2; EditorGUI.LabelField(elementrect, "Recipe :", EditorStyles.boldLabel); elementrect.x += 56; EditorGUI.LabelField(elementrect, this.builder.ToString(), EditorStyles.miniLabel); elementrect.x += -56; elementrect.y += 20; EditorGUI.LabelField(elementrect, "Weaknesses :", EditorStyles.boldLabel); ChemicalElement[] weaknesses = script.weaknesses.Find(x => x.element == e.element).array; int index = 0; elementrect.x += 93; elementrect.width = rect.width + -125; bool back = false; do { colorrect = elementrect; this.builder.Clear(); this.builder.Append(weaknesses[index++]); while (index < weaknesses.Length) { if (EditorUtilityExtension.GetTextWidth(this.builder.ToString() + ", " + weaknesses[index], EditorStyles.miniLabel) > elementrect.width) { break; } this.builder.Append(", ").Append(weaknesses[index++]); } if (back) { colorrect.x += -105; colorrect.y += 10; colorrect.width += 116; colorrect.height = 15; EditorGUI.DrawRect(colorrect, grey); colorrect.x += 3; colorrect.y += -3; colorrect.width += -6; colorrect.height = 15; EditorGUI.DrawRect(colorrect, dark); } EditorGUI.LabelField(elementrect, this.builder.ToString(), EditorStyles.miniLabel); elementrect.y += 15; back = true; }while(index < weaknesses.Length); elementrect.y += (i == 0) ? 8 : 10; elementrect.x += -84; } else { elementrect.y += 22; } } if (script.primaries.Count == 0) { elementrect.x += 20; elementrect.y += -5; } elementrect.x += -18; elementrect.y += 5; elementrect.width = rect.width + -15; elementrect.height = 20; if (GUI.Button(elementrect, "WARM UP")) { script.WarmUp(); } }
public sealed override void OnInspectorGUI() { UtilityAIBehaviour script = target as UtilityAIBehaviour; // Rect n = new Rect(); // n.x = baserect.x + 50; // n.y += 500; // n.width = 200; // n.height = 16; // val = EditorGUI.FloatField(n, "Val", val); DrawDefaultInspector(); EditorGUI.BeginChangeCheck(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Utility AI", EditorStyles.boldLabel); baserect = EditorGUILayout.GetControlRect(true, 0); actionrect = baserect; actionrect.height += 17; EditorGUI.LabelField(actionrect, "Update Interval", EditorStyles.miniLabel); actionrect.x += 90; actionrect.width += -95; script.updateRate = EditorGUI.Slider(actionrect, script.updateRate, 0.02f, 1f); buttonStyle = new GUIStyle("Button"); // First action position baserect.y += 39; baserect.width += -5; baserect.height += 49; // Actions field for (int act = 0; act < actions.arraySize; ++act) { actionRef = actions.GetArrayElementAtIndex(act); scorers = actionRef.FindPropertyRelative("scorers"); // Background actionrect = baserect; actionrect.y += -18; actionrect.height += -1; EditorGUI.DrawRect(actionrect, actionColor); // Action field actionrect = baserect; actionrect.x += 8; actionrect.y += -12; actionrect.width += -35; actionrect.height = 14; this.ActionMethodField(actionrect, actionRef); // Trash field actionrect = baserect; actionrect.width = 16; actionrect.height = 16; actionrect.x += baserect.width + -23; actionrect.y += -13; if (EditorApplication.isPlaying) { GUI.enabled = false; } if (GUI.Button(actionrect, this.trashTexture, GUIStyle.none)) { script.displayScorers.RemoveAt(act); script.displayParameters.RemoveAt(act); script.RemoveActionAt(act); serializedObject.Update(); return; } if (EditorApplication.isPlaying) { GUI.enabled = true; } // Arrow scorers field actionrect = baserect; actionrect.x += 19; actionrect.y += 8; actionrect.width = 0; script.displayScorers[act] = EditorGUI.Foldout(actionrect, script.displayScorers[act], "Scorers"); if (script.displayScorers[act]) { script.displayParameters[act] = false; } // Arrow parameters field actionrect.x += baserect.width + -142; actionrect.width = 97; actionrect.height = 16; this.buttonStyle.fontSize = 9; script.displayParameters[act] = GUI.Toggle(actionrect, script.displayParameters[act], "show parameters", this.buttonStyle); if (script.displayParameters[act]) { script.displayScorers[act] = false; } // Parameters fields if (script.displayParameters[act]) { actionrect = baserect; // Background actionrect.y += 30; actionrect.height = 30; EditorGUI.DrawRect(actionrect, actionColor); scorerect = actionrect; scorerect.x += 8; scorerect.y += -2; scorerect.width += -16; scorerect.height += -4; EditorGUI.DrawRect(scorerect, scorerColor); buttonStyle.fontSize = 9; actionrect.height = 15; actionrect.y += 3; if (EditorApplication.isPlaying) { GUI.enabled = false; } actionrect.width = 64; actionrect.x += baserect.width + -239; script.actions[act].isStoppable = GUI.Toggle(actionrect, script.actions[act].isStoppable, "stoppable", buttonStyle); actionrect.x += actionrect.width + 1; actionrect.width = 80; script.actions[act].isParallelizable = GUI.Toggle(actionrect, script.actions[act].isParallelizable, "parallelizable", buttonStyle); actionrect.x += actionrect.width + 1; actionrect.width = 79; script.actions[act].isForceAlone = GUI.Toggle(actionrect, script.actions[act].isForceAlone, "force alone", buttonStyle); if (EditorApplication.isPlaying) { GUI.enabled = true; } // Set position for next action with scorers displayed baserect.y += 30; } // Scorers fields else if (script.displayScorers[act]) { actionrect = baserect; // Background actionrect.y += 30; actionrect.height = (scorers.arraySize > 0) ? 49 * scorers.arraySize + 25 : 22; EditorGUI.DrawRect(actionrect, actionColor); // Display scorers fields for (int sco = 0; sco < scorers.arraySize; ++sco) { scorerect = actionrect; scoreRef = scorers.GetArrayElementAtIndex(sco); // Background scorerect.x += 8; scorerect.y += -2; scorerect.width += -16; scorerect.height = 46; EditorGUI.DrawRect(scorerect, scorerColor); // Select scorer field scorerect.x += 4; scorerect.y += 5; scorerect.width += -27; scorerect.height = 15; if (EditorApplication.isPlaying) { GUI.enabled = false; } scorer = this.ScorerMethodField(scorerect, scoreRef); if (EditorApplication.isPlaying) { GUI.enabled = true; } isCond = this.IsScorerCondition(scorer); script.actions[act].scorers[sco].isCondition = isCond; scorerect.y += 21; // Display condition parameters field if (isCond) { EditorGUI.LabelField(scorerect, "Score"); scorerect.x += 66; scorerect.width += -48; script.actions[act].scorers[sco].score = EditorGUI.IntField(scorerect, script.actions[act].scorers[sco].score); // 'Not' option field buttonStyle.fontSize = 10; scorerect.y += -21; scorerect.width = 31; scorerect.height = 15; if (EditorApplication.isPlaying) { GUI.enabled = false; } script.actions[act].scorers[sco].not = GUI.Toggle(scorerect, script.actions[act].scorers[sco].not, "Not", buttonStyle); if (EditorApplication.isPlaying) { GUI.enabled = true; } } // Display curve parameters field else { EditorGUI.LabelField(scorerect, "Curve"); scorerect.x += 66; scorerect.width += -48; if (script.actions[act].scorers[sco].curve == null) { script.actions[act].scorers[sco].curve = new AnimationCurve(); } script.actions[act].scorers[sco].curve = EditorGUI.CurveField(scorerect, script.actions[act].scorers[sco].curve); scorerect.y += -21; } // Trash button field scorerect.x = actionrect.width + -13; scorerect.width = 15; scorerect.height = 15; if (EditorApplication.isPlaying) { GUI.enabled = false; } if (GUI.Button(scorerect, this.trashTexture, GUIStyle.none)) { script.actions[act].RemoveScorerAt(sco); serializedObject.Update(); return; } if (EditorApplication.isPlaying) { GUI.enabled = true; } // Set position for next scorer actionrect.y += 49; } // Add scorer button field actionrect.x += 8; actionrect.y += (scorers.arraySize > 0) ? 0 : -2; actionrect.width = baserect.width + -15; actionrect.height = 18; if (EditorApplication.isPlaying) { GUI.enabled = false; } buttonStyle.fontSize = 10; if (GUI.Button(actionrect, "ADD NEW SCORER", buttonStyle)) { int nb = script.actions[act].scorers.Count; if (this.scorerMethodNames.Length == nb) { Debug.Log($"No need to add another scorer, there is enough ! (Number of scorer found: {nb})"); } else if (this.scorerMethodNames.Length == 0) { Debug.Log($"There is no scorer yet !"); } else { int scorerIndex = this.GetNextAvailableScorer(script.actions[act].scorers); script.actions[act].AddScorer(this.scorerMethodNames[scorerIndex], this.IsScorerCondition(scorer), scorerIndex); serializedObject.Update(); } } if (EditorApplication.isPlaying) { GUI.enabled = true; } // Set position for next action with scorers displayed baserect.y += (scorers.arraySize > 0) ? scorers.arraySize * 49 + 25 : 22; } // Set position for next action baserect.y += 52; } baserect.y += -16; baserect.width += 1; actionrect = baserect; actionrect.height = 23; if (EditorApplication.isPlaying) { GUI.enabled = false; } if (GUI.Button(actionrect, "ADD NEW ACTION")) { if (actionMethodNames.Length == script.actions.Count) { Debug.Log($"There is no more action to add ! (Number of action found: {actionMethodNames.Length})"); } else { script.displayScorers.Add(false); script.displayParameters.Add(false); script.AddAction(this.actionMethodNames[script.actions.Count], script.actions.Count); serializedObject.Update(); } } if (EditorApplication.isPlaying) { GUI.enabled = true; } if (EditorGUI.EndChangeCheck()) { script.UpdateAllMaxCache(); } EditorUtilityExtension.SetDirtyOnGUIChange(script); serializedObject.ApplyModifiedProperties(); }