public override void Render() { if (rootProperty == null) { return; } SerializedPropertyX id = rootProperty.FindProperty("id"); SerializedPropertyX icon = rootProperty.FindProperty("icon"); GUILayout.BeginHorizontal(); EditorGUILayoutX.PropertyField(icon, GUIContent.none, false, GUILayout.Width(64f), GUILayout.Height(64f)); GUILayout.BeginVertical(); GUILayout.Space(20f); EditorGUILayoutX.PropertyField(id, new GUIContent("Character Name"), true); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Restore")) { targetItem.Restore(); GUIUtility.keyboardControl = 0; } if (GUILayout.Button("Delete")) { targetItem.QueueDelete(); } if (GUILayout.Button("Save")) { targetItem.Save(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); }
public override void Render() { if (rootProperty == null) { return; } SerializedPropertyX nameProp = rootProperty["id"]; GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); GUILayout.Space(20f); EditorGUILayoutX.PropertyField(nameProp, new GUIContent("Evaluator Name"), true); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Restore")) { targetItem.Restore(); GUIUtility.keyboardControl = 0; } if (GUILayout.Button("Delete")) { targetItem.QueueDelete(); } if (GUILayout.Button("Save")) { targetItem.Save(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); }
protected override void RenderBody(SerializedPropertyX considerationProperty, RenderData _data, int index) { ConsiderationRenderData data = _data as ConsiderationRenderData; Consideration consideration = considerationProperty.GetValue <Consideration>(); //manually render description and curve to make sure they come first DrawerUtil.PushLabelWidth(125); DrawerUtil.PushIndentLevel(1); consideration.description = EditorGUILayout.TextField(new GUIContent("Description"), consideration.description); GUIContent content = new GUIContent(); content.text = Util.SplitAndTitlize(consideration.GetType().Name); EditorGUILayout.BeginHorizontal(); data.isInputDisplayed = EditorGUILayout.Foldout(data.isInputDisplayed, content); EditorGUILayout.EndHorizontal(); if (data.isInputDisplayed) { EditorGUI.indentLevel++; for (int i = 0; i < considerationProperty.ChildCount; i++) { SerializedPropertyX child = considerationProperty.GetChildAt(i); if (skipRenderingFields.IndexOf(child.name) != -1) { continue; } EditorGUILayoutX.PropertyField(child, child.label, child.isExpanded); } EditorGUI.indentLevel--; } RenderCurve(considerationProperty.FindProperty("curve"), data); DrawerUtil.PopLabelWidth(); DrawerUtil.PopIndentLevel(); }
public override void OnGUI(SerializedPropertyX property, GUIContent label) { IntRange attr = property.GetValue <IntRange>(); label.text = property.displayName + " (" + attr.Value + ")"; property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, label); if (property.isExpanded) { property["baseValue"].Value = EditorGUILayout.IntField(new GUIContent("Base Value"), property["baseValue"].GetValue <int>()); if (Mathf.Approximately(attr.BaseValue, 0)) { attr.BaseValue = 0; } attr.BaseValue = property["baseValue"].GetValue <int>(); property["currentValue"].Value = attr.Value; EditorGUI.indentLevel++; IntModifier[] modifiers = attr.GetReadOnlyModiferList(); for (int i = 0; i < modifiers.Length; i++) { IntModifier modifier = modifiers[i]; string valueStr = "Flat: " + modifier.flatBonus + " Percent: " + modifier.percentBonus; GUI.enabled = false; EditorGUILayout.TextField(new GUIContent(modifier.id), valueStr); GUI.enabled = true; } EditorGUILayoutX.PropertyField(property["min"]); EditorGUILayoutX.PropertyField(property["max"]); EditorGUI.indentLevel--; } }
public override void OnGUI(SerializedPropertyX property, GUIContent label) { Initialize(property); if ((bool)debugMode.Value) { EditorGUI.indentLevel++; for (int i = 0; i < property.ChildCount; i++) { SerializedPropertyX child = property.GetChildAt(i); child.isExpanded = true; if (skipRenderingFields.IndexOf(child.name) != -1) { continue; } EditorGUILayoutX.PropertyField(child, child.label, child.isExpanded); } EditorGUI.indentLevel--; CalculateButton(property); } else { EditorGUI.indentLevel++; EditorGUILayoutX.PropertyField(debugMode, debugMode.label, debugMode.isExpanded); EditorGUI.indentLevel--; } listRenderer.Render(); }
private void RenderDetails() { if (selection == null) { return; } scroll = GUILayout.BeginScrollView(scroll); { treeView.UpdateDisplayName( selection[IdField].intValue, selection[NameField].stringValue ); EditorGUILayout.BeginVertical((GUILayoutOption[])null); { EditorGUILayoutX.PropertyField(selection); if (selection.HasModifiedProperties) { selection.ApplyModifiedProperties(); treeView.SetDataRebuildAndSelect(); } } EditorGUILayout.EndVertical(); } GUILayout.EndScrollView(); }
private void RenderEntityInspector() { EditorGUILayoutX.BeginVertical(); if (reflectedSelection != null) { EditorGUILayoutX.PropertyField(reflectedSelection); } EditorGUILayoutX.EndVertical(); }
public override void Render() { if (targetItem == null) { return; } SerializedPropertyX castMode = rootProperty.FindProperty("castMode"); SerializedPropertyX ignoreGCD = rootProperty.FindProperty("IgnoreGCD"); SerializedPropertyX castTime = rootProperty.FindProperty("castTime").FindProperty("baseValue"); SerializedPropertyX channelTime = rootProperty.FindProperty("channelTime").FindProperty("baseValue"); SerializedPropertyX channelTicks = rootProperty.FindProperty("channelTicks").FindProperty("baseValue"); SerializedPropertyX charges = rootProperty.FindProperty("charges"); GUILayout.BeginHorizontal(); EditorGUILayoutX.PropertyField(castMode, false); ignoreGCD.Value = EditorGUILayout.ToggleLeft("Ignore GCD", (bool)ignoreGCD.Value); GUILayout.EndHorizontal(); int castVal = (int)castMode.Value; if (castVal != (int)CastMode.Instant) { if (castVal != (int)CastMode.Channel) { castTime.Value = EditorGUILayout.FloatField(new GUIContent("Cast Time"), (float)castTime.Value); } if (castVal != (int)CastMode.Cast) { channelTime.Value = EditorGUILayout.FloatField(new GUIContent("Channel Time"), (float)channelTime.Value); channelTicks.Value = EditorGUILayout.IntField(new GUIContent("Channel Ticks"), (int)channelTicks.Value); } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Charges (" + charges.ArraySize + ")"); if (GUILayout.Button("+", GUILayout.Width(25f))) { charges.ArraySize++; } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel++; for (int i = 0; i < charges.ArraySize; i++) { EditorGUILayout.BeginHorizontal(); SerializedPropertyX chargeProp = charges.GetChildAt(i); SerializedPropertyX cooldown = chargeProp.FindProperty("cooldown").FindProperty("baseValue"); cooldown.Value = EditorGUILayout.FloatField(new GUIContent("Cooldown"), (float)cooldown.Value); GUI.enabled = charges.ArraySize > 1; if (GUILayout.Button("-", GUILayout.Width(25f), GUILayout.Height(15f))) { charges.DeleteArrayElementAt(i); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel--; }
public override void Render() { if (rootProperty == null) { return; } SerializedPropertyX isPlayer = rootProperty.FindProperty("isPlayer"); SerializedPropertyX items = rootProperty.FindProperty("items"); SerializedPropertyX abilities = rootProperty.FindProperty("abilities"); SerializedPropertyX prefab = rootProperty.FindProperty("prefab"); GUILayout.BeginVertical(); isPlayer.Value = EditorGUILayout.Toggle(new GUIContent("Player"), (bool)isPlayer.Value); EditorGUILayoutX.PropertyField(prefab); EditorGUILayout.LabelField("Items (" + items.ArraySize + ")"); if (GUILayout.Button("+", GUILayout.Width(20f), GUILayout.Height(15f))) { items.ArraySize++; } EditorGUI.indentLevel++; for (int i = 0; i < items.ArraySize; i++) { GUILayout.BeginHorizontal(); if (GUILayout.Button("-", GUILayout.Width(20f), GUILayout.Height(15f))) { items.DeleteArrayElementAt(i); } EditorGUILayoutX.PropertyField(items.GetChildAt(i)); GUILayout.EndHorizontal(); } EditorGUI.indentLevel--; EditorGUILayout.LabelField("Abilities (" + abilities.ArraySize + ")"); if (GUILayout.Button("+", GUILayout.Width(20f), GUILayout.Height(15f))) { abilities.ArraySize++; } EditorGUI.indentLevel++; for (int i = 0; i < abilities.ArraySize; i++) { GUILayout.BeginHorizontal(); if (GUILayout.Button("-", GUILayout.Width(20f), GUILayout.Height(15f))) { abilities.DeleteArrayElementAt(i); } EditorGUILayoutX.PropertyField(abilities.GetChildAt(i)); GUILayout.EndHorizontal(); } EditorGUI.indentLevel--; GUILayout.EndVertical(); }
public override void OnGUI(SerializedPropertyX property, GUIContent label) { shown = EditorGUILayout.Foldout(shown, label); if (!shown) { return; } EditorGUI.indentLevel++; EditorGUILayoutX.PropertyField(property["abilityCreator"]); if (property["abilityCreator"].Changed) { //todo assert type matches } if (property["abilityCreator"].Value == null) { property["contextCreator"].Value = null; return; } Type type; PlayerContextCreator current = property["contextCreator"].GetValue <PlayerContextCreator>(); Type currentType = null; if (current != null) { currentType = current.GetType(); } SerializedPropertyX creatorProperty = property["contextCreator"]; if (popup.DrawPopup("Context Constructor", currentType, out type)) { if (type != null) { creatorProperty.Value = Activator.CreateInstance(type); } else { creatorProperty.Value = null; } } if (creatorProperty.Value != null) { EditorGUI.indentLevel++; EditorGUILayoutX.DrawProperties(creatorProperty); EditorGUI.indentLevel--; } EditorGUI.indentLevel--; }
protected virtual void RenderBody(SerializedPropertyX property, RenderData data, int index) { EditorGUI.indentLevel++; for (int i = 0; i < property.ChildCount; i++) { SerializedPropertyX child = property.GetChildAt(i); if (skipRenderingFields.IndexOf(child.name) != -1) { continue; } EditorGUILayoutX.PropertyField(child, child.label, child.isExpanded); } EditorGUI.indentLevel--; }
private void RenderDetails() { if (selectedAsset == null) { return; } scrollVec = EditorGUILayout.BeginScrollView(scrollVec); { EditorGUILayout.BeginVertical((GUILayoutOption[])null); EditorGUILayoutX.PropertyField(reflectedSelection); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); reflectedSelection?.ApplyModifiedProperties(); }
private HashSet <ItemType> _itemTypesCheck = new HashSet <ItemType>(); // workaround for the fact that we cannot make serializable hashsets public override void Render() { if (rootProperty == null) { return; } SerializedPropertyX isSoulbound = rootProperty.FindProperty("isSoulbound"); SerializedPropertyX isUnique = rootProperty.FindProperty("isUnique"); SerializedPropertyX isStackable = rootProperty.FindProperty("isStackable"); SerializedPropertyX isUsable = rootProperty.FindProperty("isUsable"); SerializedPropertyX isDestructable = rootProperty.FindProperty("isDestructable"); SerializedPropertyX isTypes = rootProperty.FindProperty("isType"); GUILayout.BeginVertical(); isSoulbound.Value = EditorGUILayout.Toggle(new GUIContent("Soulbound"), (bool)isSoulbound.Value); isUnique.Value = EditorGUILayout.Toggle(new GUIContent("Unique"), (bool)isUnique.Value); isUsable.Value = EditorGUILayout.Toggle(new GUIContent("Usable"), (bool)isUsable.Value); isDestructable.Value = EditorGUILayout.Toggle(new GUIContent("Destructable"), (bool)isDestructable.Value); isStackable.Value = EditorGUILayout.Toggle(new GUIContent("Stackable"), (bool)isStackable.Value); EditorGUILayout.LabelField("Attributes (" + isTypes.ArraySize + ")"); if (GUILayout.Button("+", GUILayout.Width(20f), GUILayout.Height(15f))) { // part of the workaround if (isTypes.ArraySize > 0) { if (!_itemTypesCheck.Add((ItemType)isTypes.GetChildAt(isTypes.ArraySize - 1).Value)) { return; } } isTypes.ArraySize++; } EditorGUI.indentLevel++; for (int i = 0; i < isTypes.ArraySize; i++) { GUILayout.BeginHorizontal(); if (GUILayout.Button("-", GUILayout.Width(20f), GUILayout.Height(15f))) { _itemTypesCheck.Remove((ItemType)isTypes.GetChildAt(i).Value); // also part of the workaround isTypes.DeleteArrayElementAt(i); } EditorGUILayoutX.PropertyField(isTypes.GetChildAt(i)); GUILayout.EndHorizontal(); } EditorGUI.indentLevel--; GUILayout.EndVertical(); }
public void DefaultRenderBody(SerializedPropertyX property, RenderData data, int index) { EditorGUI.indentLevel++; if (Reflector.GetCustomPropertyDrawerFor(property) != null) { EditorGUILayoutX.PropertyField(property, property.label, property.isExpanded); return; } for (int i = 0; i < property.ChildCount; i++) { SerializedPropertyX child = property.GetChildAt(i); if (skipRenderingFields.IndexOf(child.name) != -1) { continue; } EditorGUILayoutX.PropertyField(child, child.label, child.isExpanded); } EditorGUI.indentLevel--; }
protected override void RenderBody(SerializedPropertyX property, RenderData data, int index) { EditorGUI.indentLevel++; EditorGUILayoutX.PropertyField(property, property.label, property.isExpanded); EditorGUI.indentLevel--; }
protected override void RenderBody(SerializedPropertyX property, RenderData renderData, int index) { DecisionRenderData data = renderData as DecisionRenderData; EditorGUI.indentLevel++; EditorGUILayoutX.PropertyField(property["name"]); EditorGUILayoutX.PropertyField(property["description"]); EditorGUILayoutX.PropertyField(property["weight"]); SerializedPropertyX action = property["action"]; SerializedPropertyX collector = property["contextCollector"]; CharacterAction charAction = action.GetValue <CharacterAction>(); string contextString = "<" + charAction.ContextType.Name + ">"; string actionString = "Action (" + action.Type.Name + contextString + ")"; if (action.ChildCount > 0) { data.isActionShown = EditorGUILayout.Foldout(data.isActionShown, actionString); } else { GUIContent content = new GUIContent(actionString); content.image = EditorGUIUtility.FindTexture("cs Script Icon"); EditorGUILayout.LabelField(content); data.isActionShown = false; } if (data.isActionShown) { EditorGUI.indentLevel++; EditorGUILayoutX.DrawProperties(action); EditorGUI.indentLevel--; } data.GetContextCollectorData(charAction, collector.GetValue <ContextCollector>()); string[] options = data.contextCollectorNames; int currentIndex = data.contextCollectorIndex; int idx = EditorGUILayout.Popup("Collector", currentIndex, options, GUILayout.Width(EditorGUIUtility.labelWidth + 300f)); if (idx != data.contextCollectorIndex) { if (idx == 0) { collector.Value = null; //todo return an empty collector type? } else { Type newCollectorType = data.contextCollectorTypes[idx]; collector.Value = Activator.CreateInstance(newCollectorType) as ContextCollector; } } if (collector.Value != null) { EditorGUI.indentLevel++; EditorGUILayoutX.DrawProperties(collector); EditorGUI.indentLevel--; } data.isEvaluatorShown = EditorGUILayout.Foldout(data.isEvaluatorShown, "Evaluator"); if (data.isEvaluatorShown) { EditorGUI.indentLevel++; SerializedPropertyX evaluator = property["evaluator"]; SerializedPropertyX considerations = evaluator["considerations"]; SerializedPropertyX requirements = evaluator["requirements"]; if (considerations.ChildCount == 0 && requirements.ChildCount == 0) { data.GetEvaluatorTemplateData(charAction.ContextType); int newIdx = EditorGUILayout.Popup("Set From Template", 0, data.evaluatorOptions, GUILayout.Width(EditorGUIUtility.labelWidth + 300f)); if (newIdx != 0) { evaluator.Value = data.evaluatorCreators[newIdx].Create(); data.requirementSection.SetTargetProperty(evaluator); data.considerationSection.SetTargetProperty(evaluator); } } data.requirementSection.Render(); data.considerationSection.Render(); EditorGUI.indentLevel--; } EditorGUI.indentLevel--; }