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();
    }
Beispiel #2
0
        protected override void OnExpandedGUI(WorldStampCreator parent)
        {
            if (EditorGUILayoutX.IndentedButton("Reset"))
            {
                ResetMask(parent.Template.Bounds, parent.Template.Terrain);
            }
            var hCreator = parent.GetCreator <HeightmapDataCreator>();
            var zLevel   = hCreator.ZeroLevel * parent.Template.Bounds.size.y;
            var width    = Mathf.Clamp(parent.Template.Bounds.size.y.ToString().Length * 16, 32, 64);

            if (_fillHeight.x == _fillHeight.y)
            {
                _fillHeight.y = _fillHeight.x + 0.001f;
            }
            _fillHeight = new Vector2(Mathf.Clamp(_fillHeight.x, -zLevel, parent.Template.Bounds.size.y - zLevel), Mathf.Clamp(_fillHeight.y, -zLevel, parent.Template.Bounds.size.y - zLevel));
            EditorGUILayout.BeginHorizontal();
            _fillHeight.x = EditorGUILayout.FloatField(_fillHeight.x, GUILayout.Width(width));
            EditorGUILayout.MinMaxSlider(ref _fillHeight.x, ref _fillHeight.y, -zLevel, parent.Template.Bounds.size.y - zLevel);
            _fillHeight.y = EditorGUILayout.FloatField(_fillHeight.y, GUILayout.Width(width));
            //_fillHeight = new Vector2(Mathf.RoundToInt(_fillHeight.x), Mathf.RoundToInt(_fillHeight.y));
            if (GUILayout.Button("Fill Below Height"))
            {
                FillMaskFromMinY(parent.Template.Bounds, parent.Template.Terrain, hCreator.Heights, _fillHeight - Vector2.one * (hCreator.ZeroLevel * parent.Template.Bounds.size.y));
            }
            EditorGUILayout.EndHorizontal();
            if (EditorGUILayoutX.IndentedButton("Load From Texture"))
            {
                LoadFromTexture(parent);
            }
        }
Beispiel #3
0
 private void RenderList()
 {
     EditorGUILayoutX.BeginVertical();
     treeView.OnGUILayout();
     InfamyGUI.Button("Save", saveCallback);
     EditorGUILayoutX.EndVertical();
 }
    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--;
        }
    }
Beispiel #5
0
    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 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();
    }
Beispiel #7
0
    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();
    }
Beispiel #8
0
        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();
        }
Beispiel #9
0
 private void RenderEntityInspector()
 {
     EditorGUILayoutX.BeginVertical();
     if (reflectedSelection != null)
     {
         EditorGUILayoutX.PropertyField(reflectedSelection);
     }
     EditorGUILayoutX.EndVertical();
 }
Beispiel #10
0
    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();
    }
Beispiel #12
0
    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--;
 }
Beispiel #14
0
 private void RenderDetails()
 {
     if (selectedAsset == null)
     {
         return;
     }
     scrollVec = EditorGUILayout.BeginScrollView(scrollVec);
     {
         EditorGUILayout.BeginVertical((GUILayoutOption[])null);
         EditorGUILayoutX.PropertyField(reflectedSelection);
         EditorGUILayout.EndHorizontal();
     }
     EditorGUILayout.EndScrollView();
     reflectedSelection?.ApplyModifiedProperties();
 }
Beispiel #15
0
    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();
    }
Beispiel #16
0
 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--;
 }
Beispiel #17
0
    public override void OnInspectorGUI()
    {
        PlayerSkillBook skillBook = target as PlayerSkillBook;

        if (root == null)
        {
            if (!string.IsNullOrEmpty(skillBook.source))
            {
                new AssetDeserializer(skillBook.source, false).DeserializeInto("__default__", skillBook);
            }
            root = new SerializedObjectX(target);
        }
        EditorGUILayoutX.DrawProperties(root);
        bool didChange = root.Root.ApplyModifiedProperties();

        if (didChange)
        {
            AssetSerializer serializer = new AssetSerializer();
            serializer.AddItem(target);
            serializedObject.FindProperty("source").stringValue = serializer.WriteToString();
            serializedObject.ApplyModifiedProperties();
        }
    }
Beispiel #18
0
 public override void DrawSpecificGUI()
 {
     Strength = Mathf.Max(0, EditorGUILayout.Slider("Strength", Strength, 0, 1));
     Flow     = Mathf.Max(0, EditorGUILayout.FloatField("Flow", Flow));
     Radius   = Mathf.Max(0, EditorGUILayoutX.IntSlider("Radius", Radius, 0, 10));
 }
    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--;
    }
Beispiel #20
0
        private void DoSplatsSection()
        {
            WorldStamp singleInstance = targets.Length == 1 ? target as WorldStamp : null;
            bool       canWrite       = !singleInstance ||
                                        (singleInstance.Data.SplatData != null && singleInstance.Data.SplatData.Count > 0);

            DoHeader("Splats", ref _splatsExpanded, _splatsEnabled, canWrite);
            if (_splatsExpanded)
            {
                EditorGUI.indentLevel++;
                if (!canWrite)
                {
                    EditorGUILayout.HelpBox("No Splats in Stamp", MessageType.Info);
                }
                GUI.enabled = canWrite;
                EditorGUILayout.PropertyField(_stencilSplats);
                EditorGUILayout.PropertyField(_splatBlendMode);

                if (targets.Length > 1)
                {
                    EditorGUILayout.HelpBox("Can't Edit Multiple Splat Ignores", MessageType.Info);
                }
                else
                {
                    var stamp = target as WorldStamp;
                    foreach (var keyValuePair in stamp.Data.SplatData)
                    {
                        var splatWrapper = keyValuePair.Wrapper;
                        var ignored      = stamp.IgnoredSplats.Contains(splatWrapper);
                        GUILayout.BeginHorizontal();
                        GUI.color = ignored ? Color.red : Color.green;
                        var newPicked = (SplatPrototypeWrapper)EditorGUILayout.ObjectField(splatWrapper, typeof(SplatPrototypeWrapper), false);
                        if (newPicked != null && newPicked != splatWrapper)
                        {
                            keyValuePair.Wrapper = newPicked;
                            EditorUtility.SetDirty(stamp);
                            var prefab = PrefabUtility.GetPrefabObject(stamp);
                            if (prefab)
                            {
                                EditorUtility.SetDirty(prefab);
                            }
                        }
                        if (EditorGUILayoutX.IndentedButton(ignored ? "Unmute" : "Mute"))
                        {
                            if (stamp.IgnoredSplats.Contains(splatWrapper))
                            {
                                stamp.IgnoredSplats.Remove(splatWrapper);
                            }
                            else
                            {
                                stamp.IgnoredSplats.Add(splatWrapper);
                            }
                        }
                        GUILayout.EndHorizontal();
                    }
                    GUI.color = Color.white;
                }
                GUI.enabled = true;
                EditorGUI.indentLevel--;
            }
        }
Beispiel #21
0
        public static object DrawGUI(object target, string label = "", Type targetType = null, FieldInfo fieldInfo = null, object context = null)
        {
#if UNITY_EDITOR
            if (targetType == null && target == null && fieldInfo == null)
            {
                Debug.LogError("Insufficient information to determine type.");
                return(null);
            }

            if (targetType == null)
            {
                targetType = target != null?target.GetType() : fieldInfo.FieldType;
            }

            var drawer = GetDrawer(targetType);
            if (context != null && drawer != null)
            {
                target = drawer.DrawGUI(target, label, targetType, fieldInfo, context);
            }
            else
            {
                if (target != null)
                {
                    var isInList      = context != null && typeof(IList).IsAssignableFrom(context.GetType());
                    var isUnityObject = typeof(UnityEngine.Object).IsAssignableFrom(targetType);
                    if (!isInList && !isUnityObject && !targetType.IsAssignableFrom(typeof(IList)) && !targetType.IsArray)
                    {
                        EditorGUILayout.BeginHorizontal();
                        if (string.IsNullOrEmpty(label) && fieldInfo != null)
                        {
                            label = fieldInfo.Name;
                        }
                        EditorGUILayout.LabelField(string.Format("{0} [{1}]", label, targetType));
                        if (GUILayout.Button(GenericEditor.DeleteContent, EditorStyles.label, GUILayout.Width(20)))
                        {
                            return(null);
                        }
                        EditorGUILayout.EndHorizontal();
                    }

                    if (fieldInfo != null)
                    {
                        //Debug.Log(string.Format("FieldInfo for {0} wasn't null, so increased IndentLevel from {1} to {2}", fieldInfo.Name, EditorGUI.indentLevel, EditorGUI.indentLevel +1));
                        EditorGUI.indentLevel++;
                    }
                    var fields = GetFields(targetType);
                    foreach (var field in fields)
                    {
                        var subObj = field.GetValue(target);
                        subObj = DrawGUI(subObj, GetFriendlyName(field), subObj != null ? subObj.GetType() : field.FieldType, field, target);
                        field.SetValue(target, subObj);
                    }
                    if (fieldInfo != null)
                    {
                        //Debug.Log(string.Format("FieldInfo for {0} wasn't null, so decreased IndentLevel from {1} to {2}", fieldInfo.Name, EditorGUI.indentLevel, EditorGUI.indentLevel -1));
                        EditorGUI.indentLevel--;
                    }
                }
                else
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(label);
                    if (targetType.IsAbstract || targetType.IsInterface)
                    {
                        EditorGUILayoutX.DerivedTypeSelectButton(targetType, (o) =>
                        {
                            fieldInfo.SetValue(context, o);
                        }
                                                                 );
                    }
                    else if (EditorGUILayoutX.IndentedButton("Add " + targetType.Name))
                    {
                        target = Activator.CreateInstance(targetType);
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }

            var unityObj = target as Object;
            if (!Application.isPlaying && unityObj)
            {
                EditorUtility.SetDirty(unityObj);
                EditorSceneManager.MarkAllScenesDirty();
            }
#endif
            return(target);
        }
Beispiel #22
0
 protected override void RenderBody(SerializedPropertyX property, RenderData data, int index)
 {
     EditorGUI.indentLevel++;
     EditorGUILayoutX.PropertyField(property, property.label, property.isExpanded);
     EditorGUI.indentLevel--;
 }
Beispiel #23
0
        private void DoTreesSection()
        {
            WorldStamp singleInstance = targets.Length == 1 ? target as WorldStamp : null;
            bool       canWrite       = !singleInstance || singleInstance.Data.Trees.Count > 0;

            DoHeader("Trees", ref _treesExpanded, _treesEnabled, canWrite);
            if (_treesExpanded)
            {
                EditorGUI.indentLevel++;
                if (!canWrite)
                {
                    EditorGUILayout.HelpBox("No Trees in Stamp", MessageType.Info);
                }
                if (targets.Length > 1)
                {
                    EditorGUILayout.HelpBox("Can't Edit Multiple Tree Ignores", MessageType.Info);
                }
                else
                {
                    var stamp = target as WorldStamp;

                    if (stamp.Data.Trees.Count > 0 && (stamp.Data.TreePrototypeCache == null || stamp.Data.TreePrototypeCache.Count == 0))
                    {
                        stamp.Data.TreePrototypeCache = new List <GameObject>();
                        foreach (var tree in stamp.Data.Trees)
                        {
                            if (!stamp.Data.TreePrototypeCache.Contains(tree.Prototype))
                            {
                                stamp.Data.TreePrototypeCache.Add(tree.Prototype);
                            }
                        }
                    }

                    for (var i = 0; i < stamp.Data.TreePrototypeCache.Count; ++i)
                    {
                        var prototype = stamp.Data.TreePrototypeCache[i];
                        if (prototype == null)
                        {
                            continue;
                        }

                        var ignored = stamp.IgnoredTrees.Contains(prototype);
                        GUILayout.BeginHorizontal();
                        GUI.color = ignored ? Color.red : Color.green;
                        var newPicked = (GameObject)EditorGUILayout.ObjectField(prototype, typeof(GameObject), false);
                        if (newPicked != null && newPicked != prototype)
                        {
                            prototype = newPicked;
                            EditorUtility.SetDirty(stamp);
                            var prefab = PrefabUtility.GetPrefabObject(stamp);
                            if (prefab)
                            {
                                EditorUtility.SetDirty(prefab);
                            }
                        }
                        if (EditorGUILayoutX.IndentedButton(ignored ? "Unmute" : "Mute"))
                        {
                            if (stamp.IgnoredTrees.Contains(prototype))
                            {
                                stamp.IgnoredTrees.Remove(prototype);
                            }
                            else
                            {
                                stamp.IgnoredTrees.Add(prototype);
                            }
                        }
                        GUILayout.EndHorizontal();
                    }
                    GUI.color = Color.white;
                }
                EditorGUILayout.PropertyField(_removeTrees, new GUIContent("Remove Existing Trees"));
                GUI.enabled = canWrite;
                EditorGUILayout.PropertyField(_stencilTrees);
                GUI.enabled = true;
                EditorGUI.indentLevel--;
            }
        }
Beispiel #24
0
    public override void OnInspectorGUI()
    {
        var castedTarget = (GameActionAuth)target;

        EditorGUI.BeginChangeCheck();

        DrawPrimaryTitle("Simulation");

        GUIContent label = EditorGUIUtilityX.TempContent("Game Action Type");

        EditorGUILayoutX.SearchablePopupString(_gameActionProp, label, s_availableTypeNames);

        if (_gameActionProp.stringValue != "")
        {
            Type gameActionType = TypeUtility.FindType(_gameActionProp.stringValue, false);
            if (gameActionType != null)
            {
                Type[] settingAuthTypes = GameActionSettingAuthBase.GetRequiredSettingAuthTypes(gameActionType);

                // Remove extra setting in property list
                for (int i = _gameActionSettingsProp.arraySize - 1; i >= 0; i--)
                {
                    if (castedTarget.GameActionSettings[i] == null || !settingAuthTypes.Contains(castedTarget.GameActionSettings[i].GetType()))
                    {
                        _gameActionSettingsProp.DeleteArrayElementAtIndex(i);
                        castedTarget.GameActionSettings.RemoveAt(i);
                    }
                }

                // Add missing setting to property list
                for (int i = 0; i < settingAuthTypes.Length; i++)
                {
                    Type currentAuthSettingType = settingAuthTypes[i];
                    if (currentAuthSettingType == null)
                    {
                        continue;
                    }

                    if (!castedTarget.GameActionSettings.Any((x) => x.GetType() == currentAuthSettingType))
                    {
                        _gameActionSettingsProp.InsertArrayElementAtIndex(_gameActionSettingsProp.arraySize);
                        SerializedProperty currentGameActionSetting = _gameActionSettingsProp.GetArrayElementAtIndex(_gameActionSettingsProp.arraySize - 1);
                        var newAuthSetting = Activator.CreateInstance(currentAuthSettingType);
                        currentGameActionSetting.managedReferenceValue = newAuthSetting;
                        castedTarget.GameActionSettings.Add((GameActionSettingAuthBase)newAuthSetting);
                    }
                }

                for (int i = 0; i < _gameActionSettingsProp.arraySize; i++)
                {
                    EditorGUILayout.PropertyField(_gameActionSettingsProp.GetArrayElementAtIndex(i));
                }
            }
        }

        DrawLine(10);

        DrawPrimaryTitle("Presentation");

        EditorGUILayout.PropertyField(_sfxProp);
        EditorGUILayout.PropertyField(_animationProp);
        EditorGUILayout.PropertyField(_surveyProp);

        EditorGUILayout.PropertyField(_instigatorVFXProp);
        EditorGUILayout.PropertyField(_targetsVFXProp);

        if (EditorGUI.EndChangeCheck())
        {
            serializedObject.ApplyModifiedProperties();
        }
    }
Beispiel #25
0
        protected override IList DrawGUIInternal(IList target, string label = "", Type targetType = null,
                                                 FieldInfo fieldInfo        = null,
                                                 object context             = null)
        {
            var expandedKey = fieldInfo != null ? fieldInfo.Name : context + "list";
            var listType    = targetType.IsArray ? targetType.GetElementType() : targetType.GetGenericArguments()[0];
            ListGenericUIAttribute listAttribute = fieldInfo != null?fieldInfo.GetAttribute <ListGenericUIAttribute>() : null;

            if (!GenericEditor.ExpandedFieldCache.ContainsKey(expandedKey))
            {
                GenericEditor.ExpandedFieldCache[expandedKey] = false;
            }
            if (fieldInfo != null)
            {
                GenericEditor.ExpandedFieldCache[expandedKey] =
                    EditorGUILayout.Foldout(GenericEditor.ExpandedFieldCache[expandedKey], fieldInfo.Name, EditorStyles.boldFont);
            }

            if (fieldInfo == null || GenericEditor.ExpandedFieldCache[expandedKey])
            {
                for (var i = 0; i < target.Count; i++)
                {
                    EditorGUI.indentLevel++;
                    var o = target[i];
                    if (!GenericEditor.ExpandedFieldCache.ContainsKey(expandedKey + i))
                    {
                        GenericEditor.ExpandedFieldCache[expandedKey + i] = false;
                    }

                    if (typeof(UnityEngine.Object).IsAssignableFrom(listType))
                    {
                        EditorGUILayout.BeginHorizontal();
                        o = EditorGUILayout.ObjectField((UnityEngine.Object)o, listType, true);
                        if (GUILayout.Button(GenericEditor.DeleteContent, EditorStyles.label, GUILayout.Width(20)))
                        {
                            if (targetType.IsArray)
                            {
                                target = ((Array)target).Remove(i);
                            }
                            else
                            {
                                target.RemoveAt(i);
                            }
                            break;
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    else
                    {
                        EditorGUILayout.BeginHorizontal();

                        string objectLabel = "NULL";
                        if (o != null)
                        {
                            objectLabel = o.ToString();
                        }
                        EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
                        GenericEditor.ExpandedFieldCache[expandedKey + i] =
                            EditorGUILayout.Foldout(GenericEditor.ExpandedFieldCache[expandedKey + i], objectLabel);
                        EditorGUILayout.EndHorizontal();

                        if (o != null && typeof(IHelpLinkProvider).IsAssignableFrom(listType))
                        {
                            var helpURL = (o as IHelpLinkProvider).HelpURL;
                            if (!string.IsNullOrEmpty(helpURL))
                            {
                                EditorExtensions.HelpButton(helpURL);
                            }
                        }

                        if (GUILayout.Button(GenericEditor.DeleteContent, EditorStyles.label, GUILayout.Width(20)))
                        {
                            target.RemoveAt(i);
                            break;
                        }

                        var enableToggle = o as IShowEnableToggle;
                        if (enableToggle != null)
                        {
                            var lastIndent = EditorGUI.indentLevel;
                            EditorGUI.indentLevel       = 0;
                            enableToggle.Editor_Enabled = EditorGUILayout.Toggle(GUIContent.none, enableToggle.Editor_Enabled, GUILayout.Width(20));
                            EditorGUI.indentLevel       = lastIndent;
                        }

                        EditorGUILayout.EndHorizontal();

                        if (GenericEditor.ExpandedFieldCache[expandedKey + i])
                        {
                            if (o != null)
                            {
                                o = GenericEditor.DrawGUI(o, "", o.GetType(), fieldInfo, target);
                            }
                            else
                            {
                                o = GenericEditor.DrawGUI(null, "Null", listType, fieldInfo, target);
                            }
                        }
                    }
                    target[i] = o;
                    EditorGUI.indentLevel--;
                    EditorExtensions.Seperator();
                }

                if (!typeof(UnityEngine.Object).IsAssignableFrom(listType) && (listType.IsAbstract || listType.IsInterface || (fieldInfo != null && listAttribute != null && listAttribute.AllowDerived)))
                {
                    EditorGUILayoutX.DerivedTypeSelectButton(listType, (o) => target.Add(o));
                }
                else if (EditorGUILayoutX.IndentedButton("Add " + listType.Name))
                {
                    if (typeof(UnityEngine.Object).IsAssignableFrom(listType))
                    {
                        if (targetType.IsArray)
                        {
                            target = ((Array)target).Add(null);
                        }
                        else
                        {
                            target.Add(null);
                        }
                    }
                    else
                    {
                        var newInstance = Activator.CreateInstance(listType);
                        if (newInstance != null && !newInstance.Equals(null))
                        {
                            if (targetType.IsArray)
                            {
                                target = ((Array)target).Add(newInstance);
                            }
                            else
                            {
                                target.Add(newInstance);
                            }
                        }
                    }
                }
            }
            return(target);
        }
Beispiel #26
0
 private void RenderList()
 {
     EditorGUILayoutX.BeginVertical();
     treeView.OnGUILayout();
     EditorGUILayoutX.EndVertical();
 }