Esempio n. 1
0
        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)]);
        }
Esempio n. 2
0
 public override void OnGUI(Rect position, ReflectedProperty property, GUIContent label)
 {
     guiRect.SetRect(position);
     EditorGUIX.PropertyField(guiRect, property[nameof(AIBehavior.name)]);
     EditorGUIX.PropertyField(guiRect, property[nameof(AIBehavior.considerations)]);
     EditorGUIX.PropertyField(guiRect, property[nameof(AIBehavior.actions)]);
 }
Esempio n. 3
0
        public override void OnGUI(Rect position, ReflectedProperty property, GUIContent label)
        {
            position = EditorGUI.IndentedRect(position);
            GUIRect guiRect = new GUIRect(position);

            string goalName = property.Type.Name.Replace("Goal", "");

            goalName = $"[{ObjectNames.NicifyVariableName(goalName)}]";

            GUIContent content = EditorGUIX.TempLabel(goalName);

            Rect rect = guiRect.GetFieldRect();

            rect.width *= 0.25f;
            EditorGUIX.Foldout(rect, property, content);
            rect.x    += rect.width;
            rect.width = rect.width * 3f;

            EditorGUIX.PropertyField(rect, property[NameField], GUIContent.none);

            if (property.IsExpanded)
            {
                EditorGUIX.DrawProperties(guiRect, property, SkipList);
                ReorderableListGUI.ListFieldAbsolute(EditorGUI.IndentedRect(guiRect.GetRect()), adapter);
            }
        }
Esempio n. 4
0
        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]);
        }
Esempio n. 5
0
        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]);
        }
Esempio n. 6
0
        public override void OnGUI(Rect position, ReflectedProperty property, GUIContent label)
        {
            guiRect.SetRect(position);

            string     typeName = $"[{StringUtil.NicifyName(property.Type.Name, "Action")}]";
            GUIContent content  = EditorGUIX.TempLabel(typeName);

            Rect rect = guiRect.GetFieldRect();

            rect.width *= 0.25f;
            EditorGUIX.Foldout(rect, property, content);
            rect.x    += rect.width;
            rect.width = rect.width * 3f;

            EditorGUIX.PropertyField(rect, property[NameField], GUIContent.none);

            if (property.IsExpanded)
            {
                EditorGUIX.DrawProperties(guiRect, property, SkipList);
                EditorGUIX.PropertyField(guiRect, property[nameof(AIAction.considerations)]);
            }
        }
Esempio n. 7
0
        public override void OnGUI(Rect position, ReflectedProperty property, GUIContent label = null)
        {
            if (property[EvaluatorField].Value == null)
            {
                // todo -- context should match the decisions context
                property[EvaluatorField].Value = new Evaluator <EntityContext>();
            }

            GUIRect guiRect = new GUIRect(position);

            EditorGUIX.PropertyField(guiRect, property[NameField]);
            EditorGUIX.TypePopup <DecisionContext>(guiRect, EditorGUIX.TempLabel("Context Type"), property[ContextTypeField]);
            EditorGUIX.PropertyField(guiRect, property[ActionField]);
            EditorGUIX.PropertyField(guiRect, property[ContextCreatorField]);
            EditorGUIX.PropertyField(guiRect, property[EvaluatorField]);

            if (property[ContextTypeField].DidChange)
            {
                property.ApplyChanges();
                Type newContextType = (Type)property[ContextTypeField].Value;
                if (!AssertCompatible(property[ActionField], newContextType))
                {
                    property[ActionField].Value = null;
                }
                if (!AssertCompatible(property[ContextCreatorField], newContextType))
                {
                    property[ContextCreatorField].Value = null;
                }
                if (!AssertCompatible(property[EvaluatorField], newContextType))
                {
                    property[EvaluatorField].SetValueAndCopyCompatibleProperties(
                        EditorReflector.CreateGenericInstance(typeof(Evaluator <>), newContextType)
                        );
                    // todo -- for each consideration, make sure its compatible with new context type
                }
            }
        }
        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--;
            }
        }
Esempio n. 9
0
        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>());
        }
Esempio n. 10
0
        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();
        }
Esempio n. 11
0
 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" });
 }
Esempio n. 12
0
 /// <inheritdoc/>
 public virtual void DrawItem(Rect position, int index)
 {
     EditorGUIX.PropertyField(position, this[index]);
 }
Esempio n. 13
0
 public override void OnGUI(Rect position, ReflectedProperty property, GUIContent label)
 {
     EditorGUIX.PropertyField(position, property[nameof(BehaviorSet.name)]);
 }