예제 #1
0
        public void ActivateIn(IEditorContainer newWindow)
        {
            container = newWindow;

            var knob = new KnobControl();

            knob.Location = new Point(0, 0);
            this.Controls.Add(knob);
            Adorn(knob);

            Adorn <Connector>(knob).Add("knobOut", new Point(12, 12), Color.SkyBlue);


            var oscillo = new Oscilloscope();

            oscillo.Location = new Point(400, 400);
            this.Controls.Add(oscillo);
            Adorn(oscillo);

            Adorn <Connector>(oscillo).Add("oscilloIn", new Point(12, 12), Color.Pink);


            var t = new TestGraph();

            t.Location = new Point(200, 200);
            this.Controls.Add(t);
            Adorn(t);
        }
예제 #2
0
        public void ActivateIn(IEditorContainer newWindow)
        {
            var surface = new Surface(newWindow);

            var ts      = new TimedSerie <int>();
            var oscillo = new Oscilloscope();
            var knob    = new KnobControl();

            oscillo.Location = new Point(200, 200);

            surface.Controls.Add(oscillo);
            surface.Controls.Add(knob);

            ts.ValuesSource = knob;
            //  oscillo.ValuesSource = ts;

            surface.AdornWith <Resizer>(oscillo);
            surface.AdornWith <Positioner>(oscillo);

            var connectorAdorner = surface.AdornWith <Connector>(oscillo);

            connectorAdorner.Add("Src", new Point(20, 20));

            surface.AdornWith <Resizer>(knob);
            surface.AdornWith <Positioner>(knob);

            this.Controls.Add(surface);
        }
예제 #3
0
 public int CompareTo(IEditorContainer other)
 {
     return SortOrder.CompareTo(other.SortOrder);
 }
예제 #4
0
        public static void BuildInspectorPropertiesElement(string elementPath, IEditorContainer editor, System.Collections.Generic.HashSet <System.Type> usedComponents, SerializedProperty obj, UnityEngine.UIElements.VisualElement container, bool noFields, System.Action <int, PropertyField> onBuild = null)
        {
            obj = obj.Copy();
            container.Clear();
            var source = obj.Copy();
            SerializedProperty iterator = obj;

            if (iterator.NextVisible(true) == false)
            {
                return;
            }
            if (iterator.NextVisible(true) == false)
            {
                return;
            }
            var depth        = iterator.depth;
            var i            = 0;
            var iteratorNext = iterator.Copy();

            do
            {
                if (string.IsNullOrEmpty(elementPath) == false)
                {
                    iterator = iteratorNext.FindPropertyRelative(elementPath);
                }
                else
                {
                    iterator = iteratorNext;
                }
                if (iterator.propertyType != SerializedPropertyType.ManagedReference)
                {
                    continue;
                }

                var element = new VisualElement();
                element.AddToClassList("element");

                var itCopy = iterator.Copy();
                GetTypeFromManagedReferenceFullTypeName(iterator.managedReferenceFullTypename, out var type);
                element.AddToClassList(i % 2 == 0 ? "even" : "odd");
                element.RegisterCallback <UnityEngine.UIElements.ContextClickEvent, int>((evt, idx) => {
                    var menu = new GenericMenu();
                    if (usedComponents != null)
                    {
                        menu.AddItem(new GUIContent("Delete"), false, () => {
                            RemoveComponent((DataConfigEditor)editor, usedComponents, source, type, noFields);
                            editor.Save();
                            BuildInspectorProperties(editor, usedComponents, source, container, noFields);
                        });

                        menu.AddItem(new GUIContent("Copy JSON"), false, () => {
                            var instance = itCopy.GetValue();
                            var json     = JsonUtility.ToJson(instance, true);
                            EditorGUIUtility.systemCopyBuffer = json;
                        });
                    }

                    editor.OnComponentMenu(menu, idx);
                    menu.ShowAsContext();
                }, i);

                if (type != null && usedComponents?.Contains(type) == false)
                {
                    usedComponents?.Add(type);
                }
                if (type == null)
                {
                    var label = new UnityEngine.UIElements.Label("MISSING: " + iterator.managedReferenceFullTypename);
                    element.name = "missing";
                    label.AddToClassList("inner-element");
                    label.AddToClassList("missing-label");
                    element.Add(label);
                }
                else if (iterator.hasVisibleChildren == false || noFields == true)
                {
                    var horizontal = new UnityEngine.UIElements.VisualElement();
                    horizontal.AddToClassList("inner-element");
                    horizontal.AddToClassList("no-fields-container");
                    element.name = type.Name;

                    var toggle = new UnityEngine.UIElements.Toggle();
                    toggle.AddToClassList("no-fields-toggle");
                    toggle.SetEnabled(false);
                    toggle.SetValueWithoutNotify(true);
                    horizontal.Add(toggle);

                    var label = new UnityEngine.UIElements.Label(GUILayoutExt.GetStringCamelCaseSpace(type.Name));
                    label.AddToClassList("no-fields-label");
                    horizontal.Add(label);

                    element.Add(horizontal);
                }
                else
                {
                    var label = GUILayoutExt.GetStringCamelCaseSpace(type.Name);
                    if (iterator.hasVisibleChildren == true)
                    {
                        var childs = iterator.Copy();
                        //var height = EditorUtilities.GetPropertyHeight(childs, true, new GUIContent(label));
                        var cnt = EditorUtilities.GetPropertyChildCount(childs);
                        if (cnt == 1 /*&& height <= 22f*/)
                        {
                            iterator.NextVisible(true);
                        }
                    }

                    var propertyField = new PropertyField(iterator.Copy(), label);
                    propertyField.BindProperty(iterator);
                    onBuild?.Invoke(i, propertyField);
                    propertyField.AddToClassList("property-field");
                    propertyField.AddToClassList("inner-element");
                    element.name = type.Name;
                    element.Add(propertyField);
                }

                if (type != null)
                {
                    var helps = type.GetCustomAttributes(typeof(ComponentHelpAttribute), false);
                    if (helps.Length > 0)
                    {
                        var label = new UnityEngine.UIElements.Label(((ComponentHelpAttribute)helps[0]).comment);
                        label.AddToClassList("comment");
                        element.Add(label);
                    }

                    if (typeof(IComponentStatic).IsAssignableFrom(type) == true)
                    {
                        var label = new UnityEngine.UIElements.Label("Static");
                        label.AddToClassList("static-component");
                        element.AddToClassList("has-static-component");
                        element.Add(label);
                    }

                    if (typeof(IComponentShared).IsAssignableFrom(type) == true)
                    {
                        var label = new UnityEngine.UIElements.Label("Shared");
                        label.AddToClassList("shared-component");
                        element.AddToClassList("has-shared-component");
                        element.Add(label);
                    }
                }

                container.Add(element);
                ++i;
            } while (iteratorNext.NextVisible(false) == true && depth <= iteratorNext.depth);
        }
예제 #5
0
 public static void BuildInspectorProperties(IEditorContainer editor, System.Collections.Generic.HashSet <System.Type> usedComponents, SerializedProperty obj,
                                             UnityEngine.UIElements.VisualElement container, bool noFields, System.Action <int, PropertyField> onBuild = null)
 {
     BuildInspectorPropertiesElement(string.Empty, editor, usedComponents, obj, container, noFields, onBuild);
 }