예제 #1
0
        public static VisualElement CreateIntegerInput(string label, int minValue, int maxValue, Action <int> onValueChange, out Slider slider, out IntegerField field)
        {
            VisualElement container = new VisualElement();

            container.style.flexDirection = FlexDirection.Row;
            container.style.marginLeft    = container.style.marginRight = 5;

            var valueLabel = new Label(label);

            valueLabel.style.unityTextAlign = TextAnchor.MiddleLeft;
            container.Add(valueLabel);

            slider             = new Slider(minValue, maxValue);
            slider.style.width = 60;
            slider.RegisterCallback <ChangeEvent <float> >(e => onValueChange((int)e.newValue));
            slider.style.marginLeft = 5;

            field             = new IntegerField();
            field.style.width = 30;
            field.RegisterCallback <ChangeEvent <int> >(e => onValueChange(e.newValue));

            container.Add(SnapRightContainer(slider, field));

            return(container);
        }
예제 #2
0
 public void BindElements()
 {
     m_BoneNameField  = this.Q <TextField>("BoneNameField");
     m_BoneDepthField = this.Q <IntegerField>("BoneDepthField");
     m_BoneNameField.RegisterCallback <FocusOutEvent>(BoneNameFocusChanged);
     m_BoneDepthField.RegisterCallback <FocusOutEvent>(BoneDepthFocusChanged);
 }
예제 #3
0
        public IListElement()
        {
            Resources.Templates.ListElement.Clone(this);
            Resources.Templates.ListElementDefaultStyling.AddStyles(this);
            binding = this;

            m_Size = new IntegerField();
            m_Size.AddToClassList(UssClasses.ListElement.Size);
            m_Size.RegisterValueChangedCallback(CountChanged);
            m_Size.RegisterCallback <KeyDownEvent>(TrapKeys);
            m_Size.isDelayed = true;

            var toggle      = this.Q <Toggle>();
            var toggleInput = toggle.Q(className: UssClasses.Unity.ToggleInput);

            toggleInput.AddToClassList(UssClasses.ListElement.ToggleInput);
            toggle.Add(m_Size);

            m_AddItemButton = new Button(OnAddItem)
            {
                text = "+ Add Element"
            };
            m_AddItemButton.AddToClassList(UssClasses.ListElement.AddItemButton);

            m_ContentRoot       = new VisualElement();
            m_ContentRoot.name  = "properties-list-content";
            m_PaginationElement = new PaginationElement();
            Add(m_PaginationElement);
            Add(m_ContentRoot);
            Add(m_AddItemButton);
        }
        public override VisualElement Build()
        {
            var root = new Foldout {
                text = DisplayName
            };
            var majorField = new IntegerField
            {
                bindingPath = nameof(Version.Major),
                label       = ObjectNames.NicifyVariableName(nameof(Version.Major))
            };

            majorField.RegisterCallback <ChangeEvent <int>, IntegerField>(ClampEditingValue, majorField);
            majorField.RegisterValueChangedCallback(OnMajorChanged);
            root.Add(majorField);

            var minorField = new IntegerField
            {
                bindingPath = nameof(Version.Minor),
                label       = ObjectNames.NicifyVariableName(nameof(Version.Minor))
            };

            minorField.RegisterCallback <ChangeEvent <int>, IntegerField>(ClampEditingValue, minorField);
            minorField.RegisterValueChangedCallback(OnMinorChanged);
            root.Add(minorField);

            var usage = GetAttribute <SystemVersionUsageAttribute>();

            if (usage?.IncludeBuild ?? true)
            {
                var buildField = new IntegerField
                {
                    bindingPath = nameof(Version.Build),
                    label       = ObjectNames.NicifyVariableName(nameof(Version.Build))
                };
                buildField.RegisterCallback <ChangeEvent <int>, IntegerField>(ClampEditingValue, buildField);
                buildField.RegisterValueChangedCallback(OnBuildChanged);
                root.Add(buildField);
            }

            if (usage?.IncludeRevision ?? true)
            {
                var revisionField = new IntegerField
                {
                    bindingPath = nameof(Version.Revision),
                    label       = ObjectNames.NicifyVariableName(nameof(Version.Revision))
                };
                revisionField.RegisterCallback <ChangeEvent <int>, IntegerField>(ClampEditingValue, revisionField);
                revisionField.RegisterValueChangedCallback(OnRevisionChanged);
                root.Add(revisionField);
            }

            if (IsReadOnly)
            {
                root.contentContainer.SetEnabled(false);
            }

            return(root);
        }
예제 #5
0
        public TracingToolbar(GraphView graphView, Store store)
        {
            m_GraphView = graphView;
            m_Store     = store;

            name = "tracingToolbar";
            AddToClassList("gtf-toolbar");
            AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(PackageTransitionHelper.AssetPath + "VisualScripting/Editor/Plugins/Debugging/TracingToolbar.uxml").CloneTree(this);
            styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(PackageTransitionHelper.AssetPath + "VisualScripting/Editor/Menu/VseMenu.uss"));
            styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(PackageTransitionHelper.AssetPath + "VisualScripting/Editor/Plugins/Debugging/Tracing.uss"));

            m_PickTargetButton         = this.Q <Button>("pickTargetButton");
            m_PickTargetButton.tooltip = "Pick a target";
            m_PickTargetButton.clickable.clickedWithEventInfo += OnPickTargetButton;
            m_PickTargetLabel         = m_PickTargetButton.Q <Label>("pickTargetLabel");
            m_PickTargetLabel.tooltip = "Choose an entity trace to display";
            m_PickTargetIcon          = m_PickTargetButton.Q(null, "icon");

            m_FirstFrameTracingButton                    = this.Q <Button>("firstFrameTracingButton");
            m_FirstFrameTracingButton.tooltip            = "Go To First Frame";
            m_FirstFrameTracingButton.clickable.clicked += OnFirstFrameTracingButton;

            m_PreviousFrameTracingButton                    = this.Q <Button>("previousFrameTracingButton");
            m_PreviousFrameTracingButton.tooltip            = "Go To Previous Frame";
            m_PreviousFrameTracingButton.clickable.clicked += OnPreviousFrameTracingButton;

            m_PreviousStepTracingButton                    = this.Q <Button>("previousStepTracingButton");
            m_PreviousStepTracingButton.tooltip            = "Go To Previous Step";
            m_PreviousStepTracingButton.clickable.clicked += OnPreviousStepTracingButton;

            m_NextStepTracingButton                    = this.Q <Button>("nextStepTracingButton");
            m_NextStepTracingButton.tooltip            = "Go To Next Step";
            m_NextStepTracingButton.clickable.clicked += OnNextStepTracingButton;

            m_NextFrameTracingButton                    = this.Q <Button>("nextFrameTracingButton");
            m_NextFrameTracingButton.tooltip            = "Go To Next Frame";
            m_NextFrameTracingButton.clickable.clicked += OnNextFrameTracingButton;

            m_LastFrameTracingButton                    = this.Q <Button>("lastFrameTracingButton");
            m_LastFrameTracingButton.tooltip            = "Go To Last Frame";
            m_LastFrameTracingButton.clickable.clicked += OnLastFrameTracingButton;

            m_CurrentFrameTextField = this.Q <IntegerField>("currentFrameTextField");
            m_CurrentFrameTextField.AddToClassList("frameCounterLabel");
            m_CurrentFrameTextField.RegisterCallback <KeyDownEvent>(OnFrameCounterKeyDown);
            m_TotalFrameLabel = this.Q <Label>("totalFrameLabel");
            m_TotalFrameLabel.AddToClassList("frameCounterLabel");

            AddTracingTimeline();
        }
예제 #6
0
        // Start is called before the first frame update
        void OnEnable()
        {
            this.name = "ShaderStrippingConfig";
            var tree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Packages/com.utj.stripvariant/Editor/UXML/ConfigUI.uxml");

            this.rootVisualElement.Add(tree.CloneTree());

            enableToggle      = this.rootVisualElement.Q <Toggle>("Enabled");
            logToggle         = this.rootVisualElement.Q <Toggle>("LogEnable");
            strictModeToggle  = this.rootVisualElement.Q <Toggle>("StrictVariantStripping");
            disableUnityStrip = this.rootVisualElement.Q <Toggle>("DisableUnityStrip");

            orderIntField      = this.rootVisualElement.Q <IntegerField>("ExecuteOrder");
            executeOrderMinBtn = this.rootVisualElement.Q <Button>("ExecOrderMinBtn");
            executeOrderMaxBtn = this.rootVisualElement.Q <Button>("ExecOrderMaxBtn");

            resetTimestampBtn = this.rootVisualElement.Q <Button>("ResetTimestampBtn");

            addExcludeBtn          = this.rootVisualElement.Q <Button>("AppendExcludeBtn");
            excludeVariantListView = this.rootVisualElement.Q <ListView>("ExcludeList");

            debugListViewBtn = this.rootVisualElement.Q <Button>("DebugListProcessorBtn");


            enableToggle.SetValueWithoutNotify(StripShaderConfig.IsEnable);
            logToggle.SetValueWithoutNotify(StripShaderConfig.IsLogEnable);
            strictModeToggle.SetValueWithoutNotify(StripShaderConfig.StrictVariantStripping);
            disableUnityStrip.SetValueWithoutNotify(StripShaderConfig.DisableUnityStrip);
            orderIntField.SetValueWithoutNotify(StripShaderConfig.Order);

            enableToggle.RegisterValueChangedCallback(OnChangeEnabbleToggle);
            logToggle.RegisterValueChangedCallback(OnChangeLogEnabbleToggle);
            strictModeToggle.RegisterValueChangedCallback(OnChangeStrictModeToggle);
            disableUnityStrip.RegisterValueChangedCallback(OnChangeDisableUnityStripToggle);

            resetTimestampBtn.clicked += OnClickResetTimestamp;

            debugListViewBtn.clicked += OnClickDebugListViewBtn;

            orderIntField.RegisterCallback <FocusOutEvent>(OnLostFocusIntField);
            executeOrderMinBtn.clicked += OnClickMinButton;
            executeOrderMaxBtn.clicked += OnClickMaxButton;
            addExcludeBtn.clicked      += OnClickAddExclude;

            SetUIActiveAtEnabled(enableToggle.value);
            SetUIActiveAtStrictMode(strictModeToggle.value);

            SetupExcludeRules();
            StrippingByVariantCollection.ResetData();
        }
예제 #7
0
 void Reload()
 {
     foldout.Clear();
     lengthField = new IntegerField("Count");
     lengthField.SetValueWithoutNotify(value.Count);
     lengthField.RegisterCallback <KeyDownEvent>(ChangeCount);
     foldout.Add(lengthField);
     for (int i = 0; i < value.Count; i++)
     {
         int j = i;
         foldout.Add(ElementExtension.DrawField("element " + j, typeof(E), value[j], _newValue =>
         {
             value[j] = (E)_newValue;
         }));
     }
 }
예제 #8
0
        public VFXIntSliderField()
        {
            m_Slider = new Slider(0, 1, ValueChanged, SliderDirection.Horizontal, 0.1f);
            m_Slider.AddToClassList("textfield");
            m_Slider.valueChanged += ValueChanged;

            var integerField = new IntegerField();

            integerField.RegisterCallback <ChangeEvent <int> >(ValueChanged);
            integerField.name = "Field";
            m_Field           = integerField;

            Add(m_Slider);
            Add(integerField);
            RegisterCallBack();
        }
        protected override void SetBaseVisualElement(VisualElement visualElement)
        {
            m_VerticesCountField = new IntegerField("Vertices Count: ")
            {
                value = Blueprint.VerticesAtTheBaseCount
            };
            m_VerticesCountField.RegisterCallback <ChangeEvent <int> >(evt => SetVerticesCount(evt.newValue));
            visualElement.Add(m_VerticesCountField);
            visualElement.Add(m_CantChangeVerticesCount);

            Vector3Field originField = new Vector3Field("Origin: ")
            {
                value = Blueprint.Origin
            };

            originField.RegisterCallback <ChangeEvent <Vector3> >(evt => Blueprint.SetOrigin(evt.newValue));
            visualElement.Add(originField);

            Vector3Field topVertex = new Vector3Field("Top Vertex: ")
            {
                value = Blueprint.TopVertex
            };

            topVertex.RegisterCallback <ChangeEvent <Vector3> >(evt => Blueprint.SetOffset(evt.newValue));
            visualElement.Add(topVertex);

            Label positionsLabel = new Label("Points Positions");

            positionsLabel.AddToClassList("sub-header");
            visualElement.Add(positionsLabel);

            m_PointsPositionsField = new VisualElement();
            visualElement.Add(m_PointsPositionsField);

            Label namesLabel = new Label("Points Names");

            namesLabel.AddToClassList("sub-header");
            visualElement.Add(namesLabel);

            m_PointNameFields = new VisualElement();
            visualElement.Add(m_PointNameFields);

            Blueprint.DependenciesUpdated.Subscribe(UpdateVerticesCountFieldAvailability);
            UpdateVerticesCountFieldAvailability();
            UpdatePointNameFields();
            UpdatePointPositionsField();
        }
예제 #10
0
        protected override void SetBaseVisualElement(VisualElement visualElement)
        {
            m_VerticesCountField = new IntegerField("Vertices Count: ")
            {
                value = Blueprint.VerticesAtTheBaseCount
            };
            m_VerticesCountField.RegisterCallback <ChangeEvent <int> >(evt => SetVerticesCount(evt.newValue));
            visualElement.Add(m_VerticesCountField);
            visualElement.Add(m_CantChangeVerticesCount);

            Vector3Field originField = new Vector3Field("Origin: ")
            {
                value = Blueprint.Origin
            };

            originField.RegisterCallback <ChangeEvent <Vector3> >(evt => Blueprint.SetOrigin(evt.newValue));
            visualElement.Add(originField);

            Vector3Field offsetField = new Vector3Field("Offset: ")
            {
                value = Blueprint.Offset
            };

            offsetField.RegisterCallback <ChangeEvent <Vector3> >(evt => Blueprint.SetOffset(evt.newValue));
            visualElement.Add(offsetField);

            FloatField radiusField = new FloatField("Radius: ")
            {
                value = Blueprint.Radius
            };

            radiusField.RegisterCallback <ChangeEvent <float> >(evt => Blueprint.SetRadius(evt.newValue));
            visualElement.Add(radiusField);
            // visualElement.Add(new ValidatorField(Blueprint.NonZeroVolumeValidator));

            Label namesLabel = new Label("Points Names");

            namesLabel.AddToClassList("sub-header");
            visualElement.Add(namesLabel);

            m_PointNameFields = new VisualElement();
            visualElement.Add(m_PointNameFields);

            Blueprint.DependenciesUpdated.Subscribe(UpdateVerticesCountFieldAvailability);
            UpdateVerticesCountFieldAvailability();
            UpdatePointNameFields();
        }
        public TracingToolbar(GraphView graphView, CommandDispatcher commandDispatcher) : base(commandDispatcher, graphView)
        {
            name = "tracingToolbar";
            AddToClassList(ussClassName);
            AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(AssetHelper.AssetPath + "Plugins/Debugging/TracingToolbar.uxml").CloneTree(this);
            styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(AssetHelper.AssetPath + "Plugins/Debugging/Tracing.uss"));

            m_PickTargetButton         = this.SafeQ <Button>("pickTargetButton");
            m_PickTargetButton.tooltip = "Pick a target";
            m_PickTargetButton.clickable.clickedWithEventInfo += OnPickTargetButton;
            m_PickTargetLabel         = m_PickTargetButton.SafeQ <Label>("pickTargetLabel");
            m_PickTargetLabel.tooltip = "Choose an entity trace to display";
            m_PickTargetIcon          = m_PickTargetButton.SafeQ(null, "icon");

            m_FirstFrameTracingButton                    = this.SafeQ <Button>("firstFrameTracingButton");
            m_FirstFrameTracingButton.tooltip            = "Go To First Frame";
            m_FirstFrameTracingButton.clickable.clicked += OnFirstFrameTracingButton;

            m_PreviousFrameTracingButton                    = this.SafeQ <Button>("previousFrameTracingButton");
            m_PreviousFrameTracingButton.tooltip            = "Go To Previous Frame";
            m_PreviousFrameTracingButton.clickable.clicked += OnPreviousFrameTracingButton;

            m_PreviousStepTracingButton                    = this.SafeQ <Button>("previousStepTracingButton");
            m_PreviousStepTracingButton.tooltip            = "Go To Previous Step";
            m_PreviousStepTracingButton.clickable.clicked += OnPreviousStepTracingButton;

            m_NextStepTracingButton                    = this.SafeQ <Button>("nextStepTracingButton");
            m_NextStepTracingButton.tooltip            = "Go To Next Step";
            m_NextStepTracingButton.clickable.clicked += OnNextStepTracingButton;

            m_NextFrameTracingButton                    = this.SafeQ <Button>("nextFrameTracingButton");
            m_NextFrameTracingButton.tooltip            = "Go To Next Frame";
            m_NextFrameTracingButton.clickable.clicked += OnNextFrameTracingButton;

            m_LastFrameTracingButton                    = this.SafeQ <Button>("lastFrameTracingButton");
            m_LastFrameTracingButton.tooltip            = "Go To Last Frame";
            m_LastFrameTracingButton.clickable.clicked += OnLastFrameTracingButton;

            m_CurrentFrameTextField = this.SafeQ <IntegerField>("currentFrameTextField");
            m_CurrentFrameTextField.AddToClassList("frameCounterLabel");
            m_CurrentFrameTextField.RegisterCallback <KeyDownEvent>(OnFrameCounterKeyDown);
            m_TotalFrameLabel = this.SafeQ <Label>("totalFrameLabel");
            m_TotalFrameLabel.AddToClassList("frameCounterLabel");

            AddTracingTimeline();
        }
예제 #12
0
        void CreateTracingMenu()
        {
            m_EnableTracingButton         = this.MandatoryQ <ToolbarToggle>("enableTracingButton");
            m_EnableTracingButton.tooltip = "Toggle Tracing For Current Instance";
            m_EnableTracingButton.SetValueWithoutNotify(m_Store.GetState().EditorDataModel.TracingEnabled);
            m_EnableTracingButton.RegisterValueChangedCallback(e => OnToggleTracing?.Invoke(e));

            m_PickTargetButton         = this.Q <Button>("pickTargetButton");
            m_PickTargetButton.tooltip = "Pick a target";
            m_PickTargetButton.clickable.clickedWithEventInfo += OnPickTargetButton;
            m_PickTargetLabel         = m_PickTargetButton.Q <Label>("pickTargetLabel");
            m_PickTargetLabel.tooltip = "Choose an entity trace to display";
            m_PickTargetIcon          = m_PickTargetButton.Q(null, "icon");

            m_FirstFrameTracingButton                    = this.Q <Button>("firstFrameTracingButton");
            m_FirstFrameTracingButton.tooltip            = "Go To First Frame";
            m_FirstFrameTracingButton.clickable.clicked += OnFirstFrameTracingButton;

            m_PreviousFrameTracingButton                    = this.Q <Button>("previousFrameTracingButton");
            m_PreviousFrameTracingButton.tooltip            = "Go To Previous Frame";
            m_PreviousFrameTracingButton.clickable.clicked += OnPreviousFrameTracingButton;

            m_PreviousStepTracingButton                    = this.Q <Button>("previousStepTracingButton");
            m_PreviousStepTracingButton.tooltip            = "Go To Previous Step";
            m_PreviousStepTracingButton.clickable.clicked += OnPreviousStepTracingButton;

            m_NextStepTracingButton                    = this.Q <Button>("nextStepTracingButton");
            m_NextStepTracingButton.tooltip            = "Go To Next Step";
            m_NextStepTracingButton.clickable.clicked += OnNextStepTracingButton;

            m_NextFrameTracingButton                    = this.Q <Button>("nextFrameTracingButton");
            m_NextFrameTracingButton.tooltip            = "Go To Next Frame";
            m_NextFrameTracingButton.clickable.clicked += OnNextFrameTracingButton;

            m_LastFrameTracingButton                    = this.Q <Button>("lastFrameTracingButton");
            m_LastFrameTracingButton.tooltip            = "Go To Last Frame";
            m_LastFrameTracingButton.clickable.clicked += OnLastFrameTracingButton;

            m_CurrentFrameTextField = this.Q <IntegerField>("currentFrameTextField");
            m_CurrentFrameTextField.AddToClassList("frameCounterLabel");
            m_CurrentFrameTextField.RegisterCallback <KeyDownEvent>(OnFrameCounterKeyDown);
            m_TotalFrameLabel = this.Q <Label>("totalFrameLabel");
            m_TotalFrameLabel.AddToClassList("frameCounterLabel");
        }
        public static VisualElement CreateFieldBasedOnType(ConfiguratorValueType _valueType, object _initialValue, string _label, System.Action _changeEventCallback)
        {
            switch (_valueType)
            {
            case ConfiguratorValueType.BOOL:
                Toggle newToggle = new Toggle(_label)
                {
                    value = _initialValue.StructConvertTo <bool>()
                };
                newToggle.RegisterCallback <ChangeEvent <bool> >(_event => _changeEventCallback?.Invoke());
                return(newToggle);

            case ConfiguratorValueType.INT:
                IntegerField newIntegerField = new IntegerField(_label)
                {
                    value = _initialValue.StructConvertTo <int>()
                };
                newIntegerField.RegisterCallback <ChangeEvent <int> >(_event => _changeEventCallback?.Invoke());
                return(newIntegerField);

            case ConfiguratorValueType.FLOAT:
                FloatField newFloatField = new FloatField(_label)
                {
                    value = _initialValue.StructConvertTo <float>()
                };
                newFloatField.RegisterCallback <ChangeEvent <float> >(_event => _changeEventCallback?.Invoke());
                return(newFloatField);

            case ConfiguratorValueType.STRING:
                string    castValue    = _initialValue.TryConvertTo <string>();
                TextField newTextField = new TextField(_label)
                {
                    value = castValue ?? string.Empty
                };
                newTextField.RegisterCallback <ChangeEvent <string> >(_event => _changeEventCallback?.Invoke());
                return(newTextField);

            case ConfiguratorValueType.VECTOR2:
                Vector2Field newVector2Field = new Vector2Field(_label)
                {
                    value = _initialValue.StructConvertTo <Vector2>()
                };
                newVector2Field.RegisterCallback <ChangeEvent <Vector2> >(_event => _changeEventCallback?.Invoke());
                return(newVector2Field);

            case ConfiguratorValueType.VECTOR3:
                Vector3Field newVector3Field = new Vector3Field(_label)
                {
                    value = _initialValue.StructConvertTo <Vector3>()
                };
                newVector3Field.RegisterCallback <ChangeEvent <Vector3> >(_event => _changeEventCallback?.Invoke());
                return(newVector3Field);

            case ConfiguratorValueType.VECTOR2INT:
                Vector2IntField newVector2IntField = new Vector2IntField(_label)
                {
                    value = _initialValue.StructConvertTo <Vector2Int>()
                };
                newVector2IntField.RegisterCallback <ChangeEvent <Vector2Int> >(_event => _changeEventCallback?.Invoke());
                return(newVector2IntField);

            case ConfiguratorValueType.VECTOR3INT:
                Vector3IntField newVector3IntField = new Vector3IntField(_label)
                {
                    value = _initialValue.StructConvertTo <Vector3Int>()
                };
                newVector3IntField.RegisterCallback <ChangeEvent <Vector3Int> >(_event => _changeEventCallback?.Invoke());
                return(newVector3IntField);

            default:
                return(null);
            }
        }
예제 #14
0
        private void Init(SimulatorJsonSerialization states)
        {
            InitPlayerSettings(states);

            bool overrideDefaultPlayerSettings = (states != null) ? states.overrideDefaultPlayerSettings : false;

            m_OverrideDefaultPlayerSettings = m_RootElement.Q <Toggle>("override-default-player-settings");
            m_OverrideDefaultPlayerSettings.RegisterValueChangedCallback(SetOverridePlayerSettings);
            m_OverrideDefaultPlayerSettings.SetValueWithoutNotify(overrideDefaultPlayerSettings);
            UpdateOverridePlayerSettingsStatus();

            m_CustomizedPlayerSettingsElement = m_RootElement.Q <VisualElement>("customized-player-settings");

            m_StartInFullscreen = m_RootElement.Q <Toggle>("android-start-in-fullscreen");
            m_StartInFullscreen.SetValueWithoutNotify(m_CustomizedPlayerSettings.androidStartInFullscreen);
            m_StartInFullscreen.RegisterValueChangedCallback((evt) => { m_CustomizedPlayerSettings.androidStartInFullscreen = evt.newValue; });

            m_ResolutionScalingMode = m_RootElement.Q <EnumField>("resolution-scaling-mode");
            m_ResolutionScalingMode.Init(ResolutionScalingMode.Disabled);
            m_ResolutionScalingMode.RegisterValueChangedCallback(SetResolutionScalingMode);
            m_ResolutionScalingMode.SetValueWithoutNotify(m_CustomizedPlayerSettings.resolutionScalingMode);

            #region DPI
            m_DpiContainer = m_RootElement.Q <VisualElement>("dpi-container");

            m_DpiSlider = m_DpiContainer.Q <SliderInt>("dpi-slider");
            m_DpiSlider.RegisterValueChangedCallback(SyncDpiField);
            m_DpiSlider.SetValueWithoutNotify(m_CustomizedPlayerSettings.targetDpi);

            m_DpiField = m_DpiContainer.Q <IntegerField>("dpi-field");
            m_DpiField.RegisterValueChangedCallback(SyncDpiSlider);
            m_DpiField.RegisterCallback <KeyDownEvent>(OnDpiFieldKeyDown);
            m_DpiField.SetValueWithoutNotify(m_CustomizedPlayerSettings.targetDpi);
            #endregion

            #region Orientation
            m_DefaultOrientation = m_RootElement.Q <EnumField>("default-screen-orientation");
            m_DefaultOrientation.Init(UIOrientation.AutoRotation);
            m_DefaultOrientation.RegisterValueChangedCallback(SetDefaultOrientation);
            m_DefaultOrientation.SetValueWithoutNotify(m_CustomizedPlayerSettings.defaultOrientation);

            m_AllowedOrienations = m_RootElement.Q <Foldout>("allowed-orientations");

            m_AllowedPortrait = m_AllowedOrienations.Q <Toggle>("orientation-allow-portrait");
            m_AllowedPortrait.SetValueWithoutNotify(m_CustomizedPlayerSettings.allowedPortrait);
            m_AllowedPortrait.RegisterValueChangedCallback((evt) => { m_CustomizedPlayerSettings.allowedPortrait = evt.newValue; });

            m_AllowedPortraitUpsideDown = m_AllowedOrienations.Q <Toggle>("orientation-allow-portrait-upside-down");
            m_AllowedPortraitUpsideDown.SetValueWithoutNotify(m_CustomizedPlayerSettings.allowedPortraitUpsideDown);
            m_AllowedPortraitUpsideDown.RegisterValueChangedCallback((evt) => { m_CustomizedPlayerSettings.allowedPortraitUpsideDown = evt.newValue; });

            m_AllowedLandscapeLeft = m_AllowedOrienations.Q <Toggle>("orientation-allow-landscape-left");
            m_AllowedLandscapeLeft.SetValueWithoutNotify(m_CustomizedPlayerSettings.allowedLandscapeLeft);
            m_AllowedLandscapeLeft.RegisterValueChangedCallback((evt) => { m_CustomizedPlayerSettings.allowedLandscapeLeft = evt.newValue; });

            m_AllowedLandscapeRight = m_AllowedOrienations.Q <Toggle>("orientation-allow-landscape-right");
            m_AllowedLandscapeRight.SetValueWithoutNotify(m_CustomizedPlayerSettings.allowedLandscapeRight);
            m_AllowedLandscapeRight.RegisterValueChangedCallback((evt) => { m_CustomizedPlayerSettings.allowedLandscapeRight = evt.newValue; });
            #endregion

            #region Graphics API
            m_AutoGraphicsAPI = m_RootElement.Q <Toggle>("auto-graphics-api");
            m_AutoGraphicsAPI.SetValueWithoutNotify(m_CustomizedPlayerSettings.autoGraphicsAPI);
            m_AutoGraphicsAPI.RegisterValueChangedCallback(SetAutoGraphicsAPI);

            m_GraphicsAPIPlaceholder = m_RootElement.Q <VisualElement>("graphics-api-placeholder");
            m_GraphicsAPIPlaceholder.SetEnabled(!m_CustomizedPlayerSettings.autoGraphicsAPI);
            #endregion

            UpdateCustomizedPlayerSettings(m_OverrideDefaultPlayerSettings.value);
            UpdateStartInFullScreen();
            UpdateResolutionScalingMode(m_CustomizedPlayerSettings.resolutionScalingMode);
            UpdateAllowedOrientations(m_CustomizedPlayerSettings.defaultOrientation);
            UpdateGraphicsAPI();
        }
예제 #15
0
    public DelegateEntryEditor(ExposedDelegateEditor exposedDelegateEditor, DelegateEntry delegateEntry)
    {
        this.exposedDelegateEditor = exposedDelegateEditor;
        this.delegateEntry         = delegateEntry;

        VisualTreeAsset visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/UtilityAI/Scripts/Editor/Delegate Entry Editor/DelegateEntryEditor.uxml");

        visualTree.CloneTree(this);

        StyleSheet stylesheet = AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/UtilityAI/Scripts/Editor/Delegate Entry Editor/DelegateEntryEditor.uss");

        this.styleSheets.Add(stylesheet);

        this.AddToClassList("delegateEntryEditor");
        if (exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor.GetType() == typeof(UtilityAIAgentEditor))
        {
            UtilityAIAgentEditor editorWindow = (UtilityAIAgentEditor)exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor;
            if (delegateEntry.TargetGO != editorWindow.utilityAIAgent.gameObject)
            {
                delegateEntry.TargetGO = editorWindow.utilityAIAgent.gameObject;
            }
        }

        delegateEntryFoldout = this.Query <Foldout>("delegateEntry");

        delegateEntryFoldout.Query <Toggle>().First().AddToClassList("delegateEntryFoldout");

        Button moveUpButton = this.Query <Button>("moveUpButton").First();

        moveUpButton.BringToFront();
        moveUpButton.clickable.clicked += MoveEntryUp;

        Button moveDownButton = this.Query <Button>("moveDownButton").First();

        moveDownButton.BringToFront();
        moveDownButton.clickable.clicked += MoveEntryDown;

        Button deleteButton = this.Query <Button>("deleteButton").First();

        deleteButton.BringToFront();
        deleteButton.clickable.clicked += DeleteEntry;
        List <Component> components = new List <Component>();

        if (exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor is UtilityAIAgentEditor)
        {
            components = delegateEntry.TargetGO.GetComponents <Component>().ToList();
        }
        else if (exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor is UtilityAIActionSetEditor)
        {
            if (((UtilityAIActionSetEditor)exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor).utilityAIAgent.inheritingGameObject != null)
            {
                components = ((UtilityAIActionSetEditor)exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor).utilityAIAgent.inheritingGameObject.GetComponents <Component>().ToList();
            }
        }
        if (components.Count > 0)
        {
            int index = 0;
            if (delegateEntry.Target != null)
            {
                List <Component> sharedComponents = components.Where(o => o.GetType() == delegateEntry.Target.GetType()).ToList();
                if (sharedComponents.Count > 0)
                {
                    index = components.IndexOf(sharedComponents[0]);
                }
                else
                {
                    if (exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor is UtilityAIAgentEditor && ((UtilityAIAgentEditor)exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor).utilityAIAgent.actionSet != null)
                    {
                        ((UtilityAIAgentEditor)exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor).utilityAIAgent.MakeActionsSetUnique();
                        ((UtilityAIAgentEditor)exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor).CreateInspectorGUI();
                        return;
                    }
                }
            }
            PopupField <Component> targetComponentField = new PopupField <Component>("Component: ", components, index);

            delegateEntry.Target = targetComponentField.value;
            targetComponentField.RegisterCallback <ChangeEvent <Component> >(
                e =>
            {
                delegateEntry.Target = (Component)e.newValue;
                exposedDelegateEditor.UpdateDelegateEntries();
            }
                );
            delegateEntryFoldout.Add(targetComponentField);
            if (delegateEntry.Target != null)
            {
                Type         selectedComponentType = delegateEntry.Target.GetType();
                BindingFlags flags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly;
                //Get a list of methods attached to the component, and create a dropdown menu:
                List <MethodInfo>       methods           = selectedComponentType.GetMethods(flags).ToList();
                PopupField <MethodInfo> targetMethodField = new PopupField <MethodInfo>("Method: ", methods, methods.Contains(delegateEntry.Method) ? methods.IndexOf(delegateEntry.Method) : 0);
                if (delegateEntry.Method == null || delegateEntry.Method.Name != targetMethodField.value.Name)
                {
                    delegateEntry.SetMethod(selectedComponentType, targetMethodField.value.Name);
                }
                targetMethodField.RegisterCallback <ChangeEvent <MethodInfo> >(
                    e =>
                {
                    delegateEntry.SetMethod(selectedComponentType, e.newValue.Name);
                    exposedDelegateEditor.UpdateDelegateEntries();
                }
                    );
                delegateEntryFoldout.Add(targetMethodField);
                if (delegateEntry.Method != null && delegateEntry.Parameters.Length > 0)
                {
                    Foldout parametersFoldout = new Foldout();
                    parametersFoldout.text = "Parameters: ";

                    foreach (SerializableObject parameter in delegateEntry.Parameters)
                    {
                        if (parameter.obj is int)
                        {
                            IntegerField parameterField = new IntegerField();
                            parameterField.value = (int)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <int> >(
                                e =>
                            {
                                parameter.obj = (int)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                        else if (parameter.obj is float)
                        {
                            FloatField parameterField = new FloatField();
                            parameterField.value = (float)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <float> >(
                                e =>
                            {
                                parameter.obj = (float)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                        else if (parameter.obj is bool)
                        {
                            Toggle parameterField = new Toggle();
                            parameterField.value = (bool)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <bool> >(
                                e =>
                            {
                                parameter.obj = (bool)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                        else if (parameter.obj is string)
                        {
                            TextField parameterField = new TextField();
                            parameterField.value = (string)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <string> >(
                                e =>
                            {
                                parameter.obj = (string)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                        else if (parameter.obj is Vector3)
                        {
                            Vector3Field parameterField = new Vector3Field();
                            parameterField.value = (Vector3)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <Vector3> >(
                                e =>
                            {
                                parameter.obj = (Vector3)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                        else if (parameter.obj is Vector2)
                        {
                            Vector2Field parameterField = new Vector2Field();
                            parameterField.value = (Vector2)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <Vector2> >(
                                e =>
                            {
                                parameter.obj = (Vector2)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                        else if (parameter.obj is Bounds)
                        {
                            BoundsField parameterField = new BoundsField();
                            parameterField.value = (Bounds)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <Bounds> >(
                                e =>
                            {
                                parameter.obj = (Bounds)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                        else if (parameter.obj is Rect)
                        {
                            RectField parameterField = new RectField();
                            parameterField.value = (Rect)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <Rect> >(
                                e =>
                            {
                                parameter.obj = (Rect)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                        else if (parameter.obj is Color)
                        {
                            ColorField parameterField = new ColorField();
                            parameterField.value = (Color)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <Color> >(
                                e =>
                            {
                                parameter.obj = (Color)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                        else if (parameter.obj is UnityEngine.Object)
                        {
                            ObjectField parameterField = new ObjectField();
                            parameterField.value = (UnityEngine.Object)parameter.obj;
                            parameterField.RegisterCallback <ChangeEvent <UnityEngine.Object> >(
                                e =>
                            {
                                parameter.obj = (UnityEngine.Object)e.newValue;
                            }
                                );
                            parametersFoldout.Add(parameterField);
                        }
                    }

                    delegateEntryFoldout.Add(parametersFoldout);
                }
            }
        }

        if (delegateEntry.TargetGO != null)
        {
            delegateEntryFoldout.text += delegateEntry.TargetGO.name;
            if (delegateEntry.Target != null)
            {
                delegateEntryFoldout.text += "(" + delegateEntry.Target.GetType() + ") ";
                if (delegateEntry.Method != null)
                {
                    delegateEntryFoldout.text += delegateEntry.Method.Name;
                }
            }
            delegateEntryFoldout.text += ": ";
        }
        else
        {
            delegateEntryFoldout.text = "New Delegate Entry:";
        }
        if (exposedDelegateEditor.utilityAIActionEditor.utilityAIAgentEditor is UtilityAIActionSetEditor && components.Count <= 0)
        {
            delegateEntryFoldout.text = "No inheriting object selected!";
        }
    }
예제 #16
0
        protected sealed override void SetupUI()
        {
            var replicatorRowAsset = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(k_ReplicatorRowPath);

            replicatorRowAsset.CloneTree(this);

            base.SetupUI();

            m_ContentContainer = this.Q <VisualElement>(k_ContentContainerName);

            m_Foldout = this.Q <Foldout>(k_RowFoldoutName);
            m_Foldout.RegisterValueChangedCallback(evt =>
            {
                var expanded = evt.newValue;
                m_ContentContainer.style.display = expanded ? DisplayStyle.Flex : DisplayStyle.None;
                if (expanded)
                {
                    RulesModule.CollapsedNodes.Remove(BackingObject);
                }
                else
                {
                    RulesModule.CollapsedNodes.Add(BackingObject);
                }

                RulesDrawer.BuildReplicatorsList();
            });

            m_Foldout.RegisterCallback <ExecuteCommandEvent>(RulesModule.PickObject);

            if (IsGroup)
            {
                m_Foldout.visible = false;
            }
            else
            {
                var expanded = !RulesModule.CollapsedNodes.Contains(BackingObject);
                m_Foldout.value = expanded;
                m_ContentContainer.style.display = expanded ? DisplayStyle.Flex : DisplayStyle.None;
            }

            m_MatchCountEnum = this.Q <EnumField>(k_MatchCountEnum);
            m_MatchCountEnum.Init(RulesModule.ReplicatorCountOption.Every);
            m_MatchCountEnum.RegisterCallback <ChangeEvent <System.Enum> >(OnChangeMatchCountDropdown);

            m_MaxCountField = this.Q <IntegerField>(k_MaxInstancesName);
            m_MaxCountField.RegisterValueChangedCallback(OnMaxInstanceChanged);

            m_MaxCountField.RegisterCallback <ExecuteCommandEvent>(RulesModule.PickObject);

            SetupProxyPresetUI(m_Entity);

            m_GroupDrillInButton          = this.Q <Button>(k_GroupDrillIn);
            m_GroupDrillInButton.clicked += () =>
            {
                var ruleSet = m_Entity.GetComponent <ProxyRuleSet>();
                RulesModule.RuleSetInstance = ruleSet;
                RulesDrawer.BuildReplicatorsList();
            };

            if (!IsGroup)
            {
                m_GroupDrillInButton.style.display = DisplayStyle.None;
            }

            m_SimMatchCount = this.Q <Label>(k_SimMatchCountName);

            SetupReplicatorRow();

            if (IsGroup)
            {
                m_AddButtonHoverElement.SetEnabled(false);
            }

            CreateAddContentButton();

            RegisterCallback <KeyDownEvent>(OnKeyDown);
        }
예제 #17
0
 void SetupIntegerField(IntegerField field, EventCallback <FocusOutEvent> onFocusOutEvent, EventCallback <ChangeEvent <int> > onChangeEvent)
 {
     field.RegisterCallback(onFocusOutEvent);
     field.RegisterValueChangedCallback(onChangeEvent);
 }
예제 #18
0
        public void OnEnable()
        {
            VisualElement root = rootVisualElement;
            VisualElement vt   = Resources.Load <VisualTreeAsset>("Editor/SDFWizardMarkup").Instantiate();

            vt.styleSheets.Add(Resources.Load <StyleSheet>("Editor/SDFWizardStyle"));
            root.Add(vt);
            Label        dLabel         = vt.Q <Label>         (null, "dLabel");
            Image        dropBox        = vt.Q <Image>         ("DropBox");
            SliderInt    sizeSlider     = vt.Q <SliderInt>     ("SizeSlider");
            IntegerField sizeField      = vt.Q <IntegerField>  ("SizeField");
            Slider       tresholdSlider = vt.Q <Slider>        ("TresholdSlider");
            FloatField   tresholdField  = vt.Q <FloatField>    ("TresholdField");
            SliderInt    sampleSlider   = vt.Q <SliderInt>     ("SampleSlider");
            IntegerField sampleField    = vt.Q <IntegerField>  ("SampleField");
            EnumField    channelSelect  = vt.Q <EnumField>     ("ChannelSelect");
            Box          channelDisplay = vt.Q <Box>           ("ChannelDisplay");
            EnumField    modeSelect     = vt.Q <EnumField>     ("RenderingSelect");
            EnumField    tilingSelect   = vt.Q <EnumField>     ("TilingSelect");

            channelSelect.Init(WizardUtils.ColorChannel.Alpha);
            modeSelect.Init(SDFConverter.RenderingMode.DistanceOnly);
            tilingSelect.Init(TextureWrapMode.Repeat);
            bool validated = false;

            dropBox.RegisterCallback <DragEnterEvent>((e) =>
            {
                foreach (var item in DragAndDrop.objectReferences)
                {
                    if (item.GetType() == typeof(Texture2D))
                    {
                        validated = true;
                    }
                }
                dropBox.tintColor  = validated ? new Color(.6f, .94f, .2f) : new Color(.94f, .3f, .2f);
                dLabel.style.color = validated ? new Color(.6f, .94f, .2f) : new Color(.94f, .3f, .2f);
            });

            dropBox.RegisterCallback <DragUpdatedEvent>((e) =>
            {
                if (validated)
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                }
            });

            dropBox.RegisterCallback <DragPerformEvent>((e) =>
            {
                if (validated)
                {
                    for (int i = 0; i < DragAndDrop.objectReferences.Length; i++)
                    {
                        var item    = (UnityEngine.Object)DragAndDrop.objectReferences[i];
                        string path = DragAndDrop.paths[i];
                        if (item.GetType() == typeof(Texture2D))
                        {
                            string newPath    = path.Substring(0, path.LastIndexOf(".")) + "_SDF.png";
                            string systemPath = Application.dataPath.Substring(0, Application.dataPath.Length - 6) + newPath;
                            var texture       = item as Texture2D;
                            texture.wrapMode  = (TextureWrapMode)tilingSelect.value;
                            var outData       = SDFConverter.RenderSDF(texture, sizeField.value, tresholdField.value, sampleField.value, channelSelect.value, modeSelect.value);
                            System.IO.File.WriteAllBytes(systemPath, outData.EncodeToPNG());
                            AssetDatabase.Refresh();
                            var importer         = (TextureImporter)AssetImporter.GetAtPath(newPath);
                            var importerSettings = new TextureImporterSettings();
                            ((TextureImporter)AssetImporter.GetAtPath(path)).ReadTextureSettings(importerSettings);
                            importer.SetTextureSettings(importerSettings);
                            importer.sRGBTexture       &= modeSelect.value.Equals(SDFConverter.RenderingMode.RGBDistance);
                            importer.textureCompression = TextureImporterCompression.Uncompressed;
                            importer.SaveAndReimport();
                            AssetDatabase.ImportAsset(newPath);
                        }
                    }
                }
            });

            dropBox.RegisterCallback <DragExitedEvent>((e) =>
            {
                validated          = false;
                dropBox.tintColor  = Color.white;
                dLabel.style.color = Color.white;
            });

            dropBox.RegisterCallback <DragLeaveEvent>((e) =>
            {
                validated          = false;
                dropBox.tintColor  = Color.white;
                dLabel.style.color = Color.white;
            });

            sizeSlider.RegisterCallback <ChangeEvent <int> >((e) =>
            {
                sizeField.value = 2 << e.newValue;
            });

            sizeField.RegisterCallback <ChangeEvent <int> >((e) =>
            {
                int c = 0;
                int v = e.newValue;
                while (v > 2)
                {
                    c++; v >>= 1;
                }
                sizeSlider.value = c;
                sizeField.value  = 2 << c;
            });

            tresholdSlider.RegisterCallback <ChangeEvent <float> >((e) =>
            {
                tresholdField.value = 1f - e.newValue;
            });

            tresholdField.RegisterCallback <ChangeEvent <float> >((e) =>
            {
                tresholdSlider.value = 1f - e.newValue;
            });
            sampleSlider.RegisterCallback <ChangeEvent <int> >((e) =>
            {
                sampleField.value = e.newValue;
            });

            sampleField.RegisterCallback <ChangeEvent <int> >((e) =>
            {
                sampleSlider.value = e.newValue;
            });

            channelSelect.RegisterCallback <ChangeEvent <Enum> >((e) =>
            {
                switch (e.newValue)
                {
                case WizardUtils.ColorChannel.Red:
                    channelDisplay.style.backgroundColor = new Color(.94f, .3f, .2f);
                    break;

                case WizardUtils.ColorChannel.Green:
                    channelDisplay.style.backgroundColor = new Color(.6f, .94f, .2f);
                    break;

                case WizardUtils.ColorChannel.Blue:
                    channelDisplay.style.backgroundColor = new Color(.2f, .6f, .94f);
                    break;

                case WizardUtils.ColorChannel.Alpha:
                    channelDisplay.style.backgroundColor = Color.grey;
                    break;

                default:
                    channelDisplay.style.backgroundColor = Color.white;
                    break;
                }
            });
        }
예제 #19
0
    public OrbitLineSubEditor(StarSystemEditor starSystemEditor, OrbitLine orbitLine)
    {
        this.starSystemEditor = starSystemEditor;
        this.orbitLine        = orbitLine;

        VisualTreeAsset visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Examples/StarSystemScene/Scripts/Editor/StarSystemEditor/OrbitLineSubEditor.uxml");

        visualTree.CloneTree(this);

        StyleSheet stylesheet = AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/Examples/StarSystemScene/Scripts/Editor/StarSystemEditor/OrbitLineSubEditor.uss");

        this.styleSheets.Add(stylesheet);

        this.AddToClassList("orbitLineSubEditor");

        // Store visual element that will contain the planet sub-inspectors.
        planetList = this.Query <VisualElement>("planetList").First();
        UpdatePlanets();

        noteList = this.Query <VisualElement>("noteList").First();
        UpdateNotes();


        #region Fields
        TextField stringField = this.Query <TextField>("orbitName").First();
        stringField.value = orbitLine.name;
        stringField.RegisterCallback <ChangeEvent <string> >(
            e =>
        {
            orbitLine.name = (string)e.newValue;
            EditorUtility.SetDirty(orbitLine);
        }
            );

        Slider distanceField = this.Query <Slider>("orbitDistance").First();
        distanceField.value = orbitLine.orbitDistance;
        distanceField.label = "Orbit Distance " + distanceField.value.ToString("F2");
        distanceField.RegisterCallback <ChangeEvent <float> >(
            e =>
        {
            orbitLine.orbitDistance = e.newValue;
            distanceField.label     = "Orbit Distance " + e.newValue.ToString("F2");
            EditorUtility.SetDirty(orbitLine);
        }
            );


        Slider thicknessField = this.Query <Slider>("thickness").First();
        thicknessField.value = orbitLine.thickness;
        thicknessField.label = "Thickness " + thicknessField.value.ToString("F3");
        thicknessField.RegisterCallback <ChangeEvent <float> >(
            e =>
        {
            orbitLine.thickness  = e.newValue;
            thicknessField.label = "Thickness " + e.newValue.ToString("F3");
            EditorUtility.SetDirty(orbitLine);
        }
            );

        IntegerField segmentsField = this.Query <IntegerField>("segments").First();
        segmentsField.value = orbitLine.segments;
        segmentsField.RegisterCallback <ChangeEvent <int> >(
            e =>
        {
            orbitLine.segments = e.newValue;
            EditorUtility.SetDirty(orbitLine);
        }
            );

        ColorField colorField = this.Query <ColorField>("color").First();
        colorField.value = orbitLine.color;
        colorField.RegisterCallback <ChangeEvent <Color> >(
            e =>
        {
            orbitLine.color = e.newValue;
            EditorUtility.SetDirty(orbitLine);
        }
            );

        Toggle waypointField = this.Query <Toggle>("useWaypoints").First();
        waypointField.value = orbitLine.useWaypoints;
        waypointField.RegisterCallback <ChangeEvent <bool> >(
            e =>
        {
            orbitLine.useWaypoints = e.newValue;
            EditorUtility.SetDirty(orbitLine);
        }
            );

        #endregion

        #region Buttons
        // Assign methods to the click events of the two buttons.
        Button btnAddPlanet = this.Query <Button>("btnAddNewPlanet").First();
        btnAddPlanet.clickable.clicked += AddPlanet;

        Button btnRemoveAllPlanets = this.Query <Button>("btnRemoveAllPlanets").First();
        btnRemoveAllPlanets.clickable.clicked += RemoveAllPlanets;

        // Assign methods to the click events of the two buttons.
        Button btnAddNote = this.Query <Button>("btnAddNewNote").First();
        btnAddNote.clickable.clicked += AddNote;

        Button btnRemoveAllNotes = this.Query <Button>("btnRemoveAllNotes").First();
        btnRemoveAllNotes.clickable.clicked += RemoveAllNotes;



        Button btnRemoveOrbit = this.Query <Button>("btnRemoveOrbitLine").First();
        btnRemoveOrbit.clickable.clicked += RemoveOrbitLine;
        #endregion
    }