public static ResponseCurve ResponseCurveField(Rect position, ResponseCurve curve) { int controlID = GUIUtility.GetControlID(FocusType.Passive); ResponseCurveFieldState state = (ResponseCurveFieldState)GUIUtility.GetStateObject( typeof(ResponseCurveFieldState), controlID); Rect left = new Rect(position); left.width *= 0.5f; Rect right = new Rect(position); right.x += left.width; right.width -= left.width; if (Event.current.type == EventType.Repaint) { curve.DrawGraph(state.texture, right.width, right.height); } EditorGUI.DrawPreviewTexture(right, state.texture); float oldWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 80f; s_guiRect.SetRect(left); curve.curveType = (ResponseCurveType)EditorGUI.EnumPopup(s_guiRect.GetFieldRect(), "Curve Type", curve.curveType); curve.slope = EditorGUI.FloatField(s_guiRect.GetFieldRect(), "Slope", curve.slope); curve.exp = EditorGUI.FloatField(s_guiRect.GetFieldRect(), "Exp", curve.exp); curve.vShift = EditorGUI.FloatField(s_guiRect.GetFieldRect(), "V Shift", curve.vShift); curve.hShift = EditorGUI.FloatField(s_guiRect.GetFieldRect(), "H Shift", curve.hShift); curve.threshold = EditorGUI.FloatField(s_guiRect.GetFieldRect(), "Threshold", curve.threshold); Rect lineRect = s_guiRect.GetFieldRect(); Rect toggleRect = new Rect(lineRect) { width = EditorGUIUtility.labelWidth + 16f }; Rect selectRect = new Rect(lineRect) { x = lineRect.x + toggleRect.width, width = lineRect.width - toggleRect.width }; curve.invert = EditorGUI.Toggle(toggleRect, "Invert", curve.invert); int idx = EditorGUI.Popup(selectRect, 0, PresetCurveNames); curve = ApplyResponseCurvePreset(PresetCurveNames[idx], curve); EditorGUIUtility.labelWidth = oldWidth; return(curve); }
public override void OnGUI(Rect position, ReflectedProperty property, GUIContent label) { s_guiRect.SetRect(position); EditorGUIX.PropertyField(s_guiRect, property[nameof(FlightGroupDefinition.name)]); EditorGUIX.PropertyField(s_guiRect, property[nameof(FlightGroupDefinition.goals)]); }
public override void OnGUI(Rect position, ReflectedProperty property, GUIContent label) { //can't run this in initialize because editor styles is null there if (style == null) { style = new GUIStyle(EditorStyles.popup); style.normal.textColor = Color.blue; style.active.textColor = Color.blue; style.focused.textColor = Color.blue; } guiRect.SetRect(position); ReflectedProperty curveProperty = property["curve"]; if (curveProperty == null) { DrawHeaderBox(property, false, s_nullCurve); return; } ResponseCurve curve = curveProperty.Value as ResponseCurve; if (!property.IsExpanded) { DrawCollapsed(property, curve); } else { DrawExpanded(property, curve); } }
public override void OnGUI(Rect position, ReflectedProperty property, GUIContent label) { GUIRect guiRect = new GUIRect(); guiRect.SetRect(position); EditorGUIX.PropertyField(guiRect.GetFieldRect(), property[NameField]); EditorGUIX.PropertyField(guiRect.GetFieldRect(), property[ShipCategoryField]); }
public override void OnGUI(Rect position, ReflectedProperty property, GUIContent label) { guiRect.SetRect(position); float oldLabelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 100; EditorGUIX.PropertyField(guiRect.GetFieldRect(), property[NameField]); EditorGUIUtility.labelWidth = oldLabelWidth; EditorGUIX.PropertyField(guiRect, property[GoalsField]); }
public override void OnGUI(Rect position, ReflectedProperty property, GUIContent label = null) { guiRect.SetRect(position); Initialize(property); int index = -1; int newIndex; if (property.Value != null) { index = Array.IndexOf(subclasses, property.Type); } if (index != -1) { Rect rect = guiRect.GetFieldRect(); float width = EditorGUIUtility.labelWidth; Rect r1 = new Rect(rect) { width = width }; Rect r2 = new Rect(rect) { x = rect.x + width, width = rect.width - width }; property.IsExpanded = EditorGUI.Foldout(r1, property.IsExpanded, property.Label); newIndex = EditorGUI.Popup(r2, index + 1, subclassNames) - 1; } else { newIndex = EditorGUI.Popup(guiRect.GetFieldRect(), property.Label, index + 1, subclassNames) - 1; } if (index != newIndex) { property.SetValueAndCopyCompatibleProperties( newIndex == -1 ? null : EditorReflector.MakeInstance(subclasses[newIndex]) ); property.IsExpanded = newIndex != -1; } if (property.IsExpanded && newIndex != -1) { EditorGUI.indentLevel += 2; EditorGUIX.DrawProperties(guiRect.GetRect(), property); EditorGUI.indentLevel -= 2; } }
public override void OnGUI(Rect position, ReflectedProperty property, GUIContent label = null) { if (property == null) { return; } guiRect.SetRect(position); Initialize(property); EditorGUIX.Foldout(guiRect, property); property.IsExpanded = true; //temp if (property.IsExpanded) { EditorGUI.indentLevel++; EditorGUIX.PropertyField(guiRect, property[NameField]); EditorGUIX.PropertyField(guiRect, property[WeightField]); EditorGUIX.PropertyField(guiRect, property[BonusCalculatorField]); ReorderableListGUI.ListFieldAbsolute(EditorGUI.IndentedRect(guiRect.GetRect()), adapter); EditorGUI.indentLevel--; } }
public override void OnGUI(Rect position, ReflectedProperty property, GUIContent label) { s_guiRect.SetRect(position); EditorGUIX.PropertyField(s_guiRect, property[NameField]); EditorGUIX.PropertyField(s_guiRect, property[ShipTypeField]); EditorGUIX.PropertyField(s_guiRect, property[SceneEntityIdField]); EditorGUIX.PropertyField(s_guiRect, property[GoalsField]); EditorGUIX.PropertyField(s_guiRect, property[BehaviorSetField]); EditorGUIX.PropertyField(s_guiRect, property[StandaloneBehaviorsField]); if (!property.HasModifiedProperties) { return; } GameDatabase db = GameDatabase.ActiveInstance; int sceneEntityId = property[SceneEntityIdField].intValue; Entity sceneEntity = db.FindSceneEntityById(sceneEntityId); property.ApplyChanges(); db.LinkSceneEntity(sceneEntity, property.GetValue <EntityDefinition>()); }
public override void OnGUI(Rect position, ReflectedProperty property, GUIContent label = null) { guiRect.SetRect(position); if (style == null) { style = new GUIStyle(GUI.skin.box); } if (graphTexture == null) { graphTexture = new Texture2D(1, 1, TextureFormat.RGBA32, true); } curve = (ResponseCurve)property.Value ?? new ResponseCurve(); if (property.IsExpanded) { EditorGUIX.Foldout(guiRect, property); } if (!property.IsExpanded) { DrawGraph(64, 32); GUIContent content = EditorGUIX.TempLabel(curve.ShortDisplayString); content.image = graphTexture; style.alignment = TextAnchor.MiddleLeft; GUI.Box(guiRect.GetFieldRect(2), content, style); content.image = null; if (Event.current.type == EventType.MouseDown) { if (position.Contains(Event.current.mousePosition)) { property.IsExpanded = true; Event.current.Use(); } } return; } GUIRect[] splits = guiRect.SplitHorizontal(0.5f); GUIRect left = splits[0]; GUIRect right = splits[1]; DrawGraph(right.GetRect().width, right.GetRect().height); GUIContent graphContent = EditorGUIX.TempLabel(string.Empty); graphContent.image = graphTexture; GUI.Box(right.GetRect(), graphContent, style); graphContent.image = null; float oldWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 100; EditorGUIX.PropertyField(left.GetFieldRect(), property.FindProperty("curveType")); EditorGUIX.PropertyField(left.GetFieldRect(), property.FindProperty("slope")); EditorGUIX.PropertyField(left.GetFieldRect(), property.FindProperty("exp")); EditorGUIX.PropertyField(left.GetFieldRect(), property.FindProperty("vShift")); EditorGUIX.PropertyField(left.GetFieldRect(), property.FindProperty("hShift")); EditorGUIX.PropertyField(left.GetFieldRect(), property.FindProperty("threshold")); Rect lineRect = left.GetFieldRect(); Rect toggleRect = new Rect(lineRect) { width = EditorGUIUtility.labelWidth + 16f }; Rect selectRect = new Rect(lineRect) { x = lineRect.x + toggleRect.width, width = lineRect.width - toggleRect.width }; EditorGUIX.PropertyField(toggleRect, property.FindProperty("invert")); int idx = EditorGUI.Popup(selectRect, 0, presetCurveNames); property.Value = GetPreset(presetCurveNames[idx], curve); EditorGUIUtility.labelWidth = oldWidth; property.ApplyChanges(); }
public override void OnGUI(Rect position, ReflectedProperty property, GUIContent label) { guiRect.SetRect(position); EditorGUIX.PropertyField(guiRect.GetFieldRect(), property["name"]); EditorGUIX.DrawProperties(guiRect.GetFieldRect(8), property, new [] { "name" }); }