Example #1
0
        private void SetUIActiveAtEnabled(bool enabled)
        {
            strictModeToggle.SetEnabled(enabled);
            disableUnityStrip.SetEnabled(enabled);
            orderIntField.SetEnabled(enabled);

            orderIntField.SetEnabled(enabled);
            executeOrderMinBtn.SetEnabled(enabled);
            executeOrderMaxBtn.SetEnabled(enabled);
        }
 void RefreshMatchGameViewToggle()
 {
     m_CanvasWidth.SetEnabled(!settings.MatchGameView);
     m_CanvasHeight.SetEnabled(!settings.MatchGameView);
     m_MatchGameViewToggle.SetValueWithoutNotify(settings.MatchGameView);
     m_MatchGameViewHelpBox.style.display = settings.MatchGameView
         ? DisplayStyle.Flex
         : DisplayStyle.None;
 }
        protected void BindBaseCreateElements(Button cancelButton, Button createButton, TextField nameField, IntegerField countField, Toggle maxCountToggle)
        {
            cancelButton.clickable.clicked += OnCancelClicked;
            createButton.clickable.clicked += OnCreateClicked;

            if (GetDefaultName != null)
            {
                m_CurrentName = GetDefaultName();
            }

            m_NameField           = nameField;
            m_NameField.isDelayed = true;
            m_NameField.SetValueWithoutNotify(m_CurrentName);
            m_NameIsCustom = false;
            m_NameField.RegisterValueChangedCallback(evt =>
            {
                if (evt.newValue.Length > 0)
                {
                    m_CurrentName  = evt.newValue;
                    m_NameIsCustom = true;
                }
                else if (GetDefaultName != null)
                {
                    m_CurrentName = GetDefaultName();
                    m_NameField?.SetValueWithoutNotify(m_CurrentName);
                    m_NameIsCustom = false;
                }

                if (NameChanged != null)
                {
                    NameChanged(m_CurrentName);
                }
            });

            maxCountToggle.RegisterValueChangedCallback(evt =>
            {
                m_CountField.value = evt.newValue ? 1 : 0;
                m_CountField.SetEnabled(evt.newValue);
            });

            m_CountField = countField;
            m_CountField.RegisterValueChangedCallback(evt =>
            {
                var newValue = evt.newValue;
                if (newValue < 0)
                {
                    newValue = 0;
                    m_CountField.SetValueWithoutNotify(newValue);
                }

                var maxEnabled = newValue > 0;
                maxCountToggle.SetValueWithoutNotify(maxEnabled);
                m_CountField.SetEnabled(maxEnabled);

                CountChanged?.Invoke(newValue);
            });
        }
        internal override void Apply(VisualElement container)
        {
            /// <sample>
            // Get a reference to the field from UXML and assign it its value.
            var uxmlField = container.Q <IntegerField>("the-uxml-field");

            uxmlField.value = 42;

            // Create a new field, disable it, and give it a style class.
            var csharpField = new IntegerField("C# Field");

            csharpField.SetEnabled(false);
            csharpField.AddToClassList("some-styled-field");
            csharpField.value = uxmlField.value;
            container.Add(csharpField);

            // Mirror value of uxml field into the C# field.
            uxmlField.RegisterCallback <ChangeEvent <int> >((evt) =>
            {
                csharpField.value = evt.newValue;
            });
            /// </sample>
        }
Example #5
0
        void UpdateTracingMenu(bool force = true)
        {
            var state = m_Store.GetState();

            if (EditorApplication.isPlaying && state.EditorDataModel.TracingEnabled && DebuggerTracer.AllGraphs != null)
            {
                m_PickTargetLabel.text   = state.currentTracingTarget.ToString();
                m_PickTargetIcon.visible = false;
                m_PickTargetButton.SetEnabled(true);
                if (EditorApplication.isPaused || !EditorApplication.isPlaying)
                {
                    m_FirstFrameTracingButton.SetEnabled(true);
                    m_PreviousFrameTracingButton.SetEnabled(true);
                    m_PreviousStepTracingButton.SetEnabled(true);
                    m_NextStepTracingButton.SetEnabled(true);
                    m_NextFrameTracingButton.SetEnabled(true);
                    m_LastFrameTracingButton.SetEnabled(true);
                    m_CurrentFrameTextField.SetEnabled(true);
                    m_TotalFrameLabel.SetEnabled(true);
                }
                else
                {
                    state.currentTracingFrame = Time.frameCount;
                    state.currentTracingStep  = -1;
                    m_FirstFrameTracingButton.SetEnabled(false);
                    m_PreviousFrameTracingButton.SetEnabled(false);
                    m_PreviousStepTracingButton.SetEnabled(false);
                    m_NextStepTracingButton.SetEnabled(false);
                    m_NextFrameTracingButton.SetEnabled(false);
                    m_LastFrameTracingButton.SetEnabled(false);
                    m_CurrentFrameTextField.SetEnabled(false);
                    m_TotalFrameLabel.SetEnabled(false);
                }

                if (!m_LastUpdate.IsRunning)
                {
                    m_LastUpdate.Start();
                }
                if (force || EditorApplication.isPaused || m_LastUpdate.ElapsedMilliseconds > k_UpdateIntervalMs)
                {
                    m_CurrentFrameTextField.value = state.currentTracingFrame;
                    m_TotalFrameLabel.text        = $"/{Time.frameCount.ToString()}";
                    if (state.currentTracingStep != -1)
                    {
                        m_TotalFrameLabel.text += $" [{state.currentTracingStep}/{state.maxTracingStep}]";
                    }

                    m_LastUpdate.Restart();
                }
            }
            else
            {
                m_LastUpdate.Stop();
                state.currentTracingFrame     = Time.frameCount;
                state.currentTracingStep      = -1;
                m_PickTargetLabel.text        = "";
                m_PickTargetIcon.visible      = true;
                m_CurrentFrameTextField.value = 0;
                m_PickTargetButton.SetEnabled(false);
                m_CurrentFrameTextField.SetEnabled(false);
                m_TotalFrameLabel.text = "/0";
                m_TotalFrameLabel.SetEnabled(false);
                m_FirstFrameTracingButton.SetEnabled(false);
                m_PreviousFrameTracingButton.SetEnabled(false);
                m_PreviousStepTracingButton.SetEnabled(false);
                m_NextStepTracingButton.SetEnabled(false);
                m_NextFrameTracingButton.SetEnabled(false);
                m_LastFrameTracingButton.SetEnabled(false);
            }
        }
Example #6
0
        public void UpdateTracingMenu(bool force = true)
        {
            var state = m_Store.GetState();

            if (EditorApplication.isPlaying && state.EditorDataModel.TracingEnabled)
            {
                m_PickTargetLabel.text            = state.CurrentGraphModel?.Stencil?.Debugger?.GetTargetLabel(state.CurrentGraphModel, state.CurrentTracingTarget);
                m_PickTargetIcon.style.visibility = Visibility.Hidden;
                m_PickTargetButton.SetEnabled(true);
                if (EditorApplication.isPaused || !EditorApplication.isPlaying)
                {
                    m_FirstFrameTracingButton.SetEnabled(true);
                    m_PreviousFrameTracingButton.SetEnabled(true);
                    m_PreviousStepTracingButton.SetEnabled(true);
                    m_NextStepTracingButton.SetEnabled(true);
                    m_NextFrameTracingButton.SetEnabled(true);
                    m_LastFrameTracingButton.SetEnabled(true);
                    m_CurrentFrameTextField.SetEnabled(true);
                    m_TotalFrameLabel.SetEnabled(true);
                }
                else
                {
                    state.CurrentTracingFrame = Time.frameCount;
                    state.CurrentTracingStep  = -1;
                    m_FirstFrameTracingButton.SetEnabled(false);
                    m_PreviousFrameTracingButton.SetEnabled(false);
                    m_PreviousStepTracingButton.SetEnabled(false);
                    m_NextStepTracingButton.SetEnabled(false);
                    m_NextFrameTracingButton.SetEnabled(false);
                    m_LastFrameTracingButton.SetEnabled(false);
                    m_CurrentFrameTextField.SetEnabled(false);
                    m_TotalFrameLabel.SetEnabled(false);
                }

                if (!m_LastUpdate.IsRunning)
                {
                    m_LastUpdate.Start();
                }
                if (force || EditorApplication.isPaused || m_LastUpdate.ElapsedMilliseconds > k_UpdateIntervalMs)
                {
                    m_CurrentFrameTextField.value = state.CurrentTracingFrame;
                    m_TotalFrameLabel.text        = $"/{Time.frameCount.ToString()}";
                    if (state.CurrentTracingStep != -1)
                    {
                        m_TotalFrameLabel.text += $" [{state.CurrentTracingStep}/{state.MaxTracingStep}]";
                    }

                    m_LastUpdate.Restart();
                }
            }
            else
            {
                m_LastUpdate.Stop();
                m_PickTargetLabel.text            = "";
                m_PickTargetIcon.style.visibility = StyleKeyword.Null;
                m_CurrentFrameTextField.value     = 0;
                m_PickTargetButton.SetEnabled(false);
                m_CurrentFrameTextField.SetEnabled(false);
                m_TotalFrameLabel.text = "/0";
                m_TotalFrameLabel.SetEnabled(false);
                m_FirstFrameTracingButton.SetEnabled(false);
                m_PreviousFrameTracingButton.SetEnabled(false);
                m_PreviousStepTracingButton.SetEnabled(false);
                m_NextStepTracingButton.SetEnabled(false);
                m_NextFrameTracingButton.SetEnabled(false);
                m_LastFrameTracingButton.SetEnabled(false);
            }
        }
 private void UpdateVerticesCountFieldAvailability()
 {
     m_VerticesCountField.SetEnabled(!Blueprint.HaveDependencies);
     m_CantChangeVerticesCount.visible = Blueprint.HaveDependencies;
 }
    public SpeakEasyNode InitializeNode(SpeakEasyNode node, Vector2 position, NodeType nodeTypeChoice)
    {
        //Actual logic for the creation of the node
        //This is the UI layout

        //Set the color of the node so it's not super transparent.
        node.mainContainer.style.backgroundColor = new Color(0.25f, 0.25f, 0.25f, 0.75f);

        //Initialize the Label of the Node, determining if it's a SPEECH or RESPONSE node
        Label nodeTypeLabel = new Label();

        nodeTypeLabel.style.fontSize  = 15;
        nodeTypeLabel.style.alignSelf = Align.Center;
        if (node.nodeType == NodeType.speech)
        {
            nodeTypeLabel.text = "SPEECH";
            node.titleContainer.style.backgroundColor = speechColor;
        }

        else
        {
            nodeTypeLabel.text = "RESPONSE";
            node.titleContainer.style.backgroundColor = responseColor;
        }

        node.titleContainer.Add(nodeTypeLabel);

        //The integer field, this field references the index in the Localization file. It's a read only field.
        IntegerField stringIndexField = new IntegerField("String Index:");

        stringIndexField.SetEnabled(false); //We shouldn't be able to directly edit this value.
        node.mainContainer.Add(stringIndexField);

        //This is the "text preview" which we morphed into a auto-localization file. The editor on save stores this data back into the specified XML file.
        TextField textPreviewField = new TextField();

        textPreviewField.multiline        = true;
        textPreviewField.style.maxWidth   = 350;
        textPreviewField.style.whiteSpace = WhiteSpace.Normal;
        textPreviewField.SetEnabled(false);
        textPreviewField.isDelayed = true;
        node.mainContainer.Add(textPreviewField);


        //adds an ID reference so we can see the GUID
        Label idReference = new Label(node.nodeID);

        node.mainContainer.Add(idReference);
        idReference.style.color = new Color(0.75f, 0.75f, 0.75f);


        //This is the stringRefField, aka the identifier for our string. This is what we store in our file data.
        TextField stringRefField = new TextField("String Reference:");

        stringRefField.isDelayed = true;
        stringRefField.RegisterValueChangedCallback(evt =>
        {
            node.stringReference = evt.newValue;                       //set the node's string reference to the new Value
            Debug.Log("Saving localization data");
            SetLocalizationIdentifier(node.stringIndex, evt.newValue); //Sets the localization identifier for the index if one is specified.
        });
        node.mainContainer.Add(stringRefField);
        stringRefField.SetValueWithoutNotify(node.stringReference);
        stringIndexField.SetValueWithoutNotify(FindStringIndex(node.stringReference)); //Look up our string reference identifier and return the index if one exists.
        //We need to set the stringIndex of the node too.
        node.stringIndex = stringIndexField.value;                                     // set the node's internal value to the stringIndexField value.
        textPreviewField.SetValueWithoutNotify(GetStringIndex(node.stringIndex));      //Update the localized box auto match the .. you know what this does.

        textPreviewField.RegisterValueChangedCallback(evt =>
        {
            Debug.Log("Saving localization data");
            SetLocalizationText(node.stringIndex, evt.newValue); //If we change the text in this field, update the localization table to match our new entry.
        });

        //This button will give us a brand new spanking place in the localization file hashtag smiley face
        Button addNewTableEntryButton = null;  //I do not understand this logic...

        addNewTableEntryButton = new Button(() => AddNewTableEntry(addNewTableEntryButton, node, stringIndexField, textPreviewField))
        {
            text = "Add Table Entry"
        };

        if (localText == null)
        {
            addNewTableEntryButton.SetEnabled(false);
        }

        node.mainContainer.Add(addNewTableEntryButton);
        //Check if we already have this data
        if (CheckIfStringReferenceExists(node.stringReference))
        {
            //We already have our connection
            addNewTableEntryButton.SetEnabled(false);
            textPreviewField.SetEnabled(true);
        }

        //Serialize Save/Load for Audio Clips and Animation Trigger
        ObjectField audioField = new ObjectField("Audio Field");

        audioField.objectType        = typeof(AudioClip);
        audioField.allowSceneObjects = false;
        audioField.SetEnabled(false);
        node.mainContainer.Add(audioField);

        TextField animationTriggerField = new TextField("Animation Trigger");

        animationTriggerField.SetEnabled(false);
        node.mainContainer.Add(animationTriggerField);

        UnityEngine.UIElements.Toggle entryPointToggle = new UnityEngine.UIElements.Toggle("Entry Point");
        entryPointToggle.RegisterValueChangedCallback(evt =>
        {
            node.isEntryPoint = evt.newValue;
        });
        node.mainContainer.Add(entryPointToggle);

        entryPointToggle.SetValueWithoutNotify(node.isEntryPoint);

        IntegerField priorityField = new IntegerField("Priority:");

        priorityField.RegisterValueChangedCallback(evt =>
        {
            node.priority = evt.newValue;
        });
        priorityField.SetValueWithoutNotify(node.priority);
        node.mainContainer.Add(priorityField);

        /*
         * ObjectField testRef = new ObjectField("OnConditional");
         * testRef.objectType = typeof(SpeakEasyLogics_Test);
         * testRef.allowSceneObjects = false;
         * node.mainContainer.Add(testRef);
         *
         * ObjectField eventRef = new ObjectField("OnFire");
         * eventRef.objectType = typeof(SpeakEasyLogics_Event);
         * eventRef.allowSceneObjects = false;
         * node.mainContainer.Add(eventRef);
         */

        //adds a OnConditional reference
        ObjectField testRefField = new ObjectField("Test Script Ref:");

        testRefField.objectType        = typeof(SpeakEasyLogics_Test);
        testRefField.allowSceneObjects = false;
        testRefField.RegisterValueChangedCallback(evt =>
        {
            node.scriptTest = (evt.newValue as SpeakEasyLogics_Test);
            //SpeakEasyNode startNode = (startPort.node as SpeakEasyNode);
        });

        node.mainContainer.Add(testRefField);
        testRefField.SetValueWithoutNotify(node.scriptTest);

        //adds a OnFire reference
        ObjectField eventRefField = new ObjectField("Event Script Ref:");

        eventRefField.objectType        = typeof(SpeakEasyLogics_Event);
        eventRefField.allowSceneObjects = false;
        eventRefField.RegisterValueChangedCallback(evt =>
        {
            node.scriptEvent = (evt.newValue as SpeakEasyLogics_Event);
        });

        node.mainContainer.Add(eventRefField);
        eventRefField.SetValueWithoutNotify(node.scriptEvent);

        //This port is the IN connection, this is where we will lead the conversation TO. The Input can recieve a number of connections from conversation choices
        Port inputPort = GetPortInstance(node, Direction.Input, Port.Capacity.Multi);

        node.inputConnection = inputPort;
        inputPort.portName   = "Connections";
        node.inputContainer.Add(inputPort);


        Port outputPort = GetPortInstance(node, Direction.Output, Port.Capacity.Multi);

        node.outputConnection = outputPort;
        outputPort.portName   = "Responses";
        node.outputContainer.Add(outputPort);


        //
        //node.outputContainer.style.flexDirection <-- this is what I was looking for last night! controls the direction of the container?

        node.RefreshExpandedState();
        node.RefreshPorts();

        node.SetPosition(new Rect(position, defaultNodeSize));

        Button debugTestValues = new Button(() => PrintValues(node, inputPort, outputPort))
        {
            text = "Print Values"
        };

        node.mainContainer.Add(debugTestValues);

        return(node);
    }
        void OnPickTargetButton(EventBase eventBase)
        {
            State     state         = m_Store.GetState();
            IDebugger debugger      = state.CurrentGraphModel.Stencil.Debugger;
            var       targetIndices = debugger.GetDebuggingTargets(state.CurrentGraphModel);
            var       items         = targetIndices == null ? null : targetIndices.Select(x =>
                                                                                          (SearcherItem) new TargetSearcherItem(x, debugger.GetTargetLabel(state.CurrentGraphModel, x))).ToList();

            if (items == null || !items.Any())
            {
                items = new List <SearcherItem> {
                    new SearcherItem("<No Object found>")
                }
            }
            ;

            SearcherWindow.Show(EditorWindow.focusedWindow, items, "Entities", i =>
            {
                if (i == null || !(i is TargetSearcherItem targetSearcherItem))
                {
                    return(true);
                }
                state.CurrentTracingTarget = targetSearcherItem.Target;
                UpdateTracingMenu();
                return(true);
            }, eventBase.originalMousePosition);
            eventBase.StopPropagation();
            eventBase.PreventDefault();
        }

        void OnFrameCounterKeyDown(KeyDownEvent evt)
        {
            if (evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter)
            {
                int frame = m_CurrentFrameTextField.value;

                frame = Math.Max(0, Math.Min(frame, Time.frameCount));
                m_Store.GetState().CurrentTracingFrame = frame;
                m_Store.GetState().CurrentTracingStep  = -1;
                UpdateTracingMenu();
            }
        }

        void UpdateTracingMenu(bool force = true)
        {
            var state = m_Store.GetState();

            if (EditorApplication.isPlaying && state.EditorDataModel.TracingEnabled)
            {
                m_PickTargetLabel.text            = state.CurrentGraphModel?.Stencil?.Debugger?.GetTargetLabel(state.CurrentGraphModel, state.CurrentTracingTarget);
                m_PickTargetIcon.style.visibility = Visibility.Hidden;
                m_PickTargetButton.SetEnabled(true);
                if (EditorApplication.isPaused || !EditorApplication.isPlaying)
                {
                    m_FirstFrameTracingButton.SetEnabled(true);
                    m_PreviousFrameTracingButton.SetEnabled(true);
                    m_PreviousStepTracingButton.SetEnabled(true);
                    m_NextStepTracingButton.SetEnabled(true);
                    m_NextFrameTracingButton.SetEnabled(true);
                    m_LastFrameTracingButton.SetEnabled(true);
                    m_CurrentFrameTextField.SetEnabled(true);
                    m_TotalFrameLabel.SetEnabled(true);
                }
                else
                {
                    state.CurrentTracingFrame = Time.frameCount;
                    state.CurrentTracingStep  = -1;
                    m_FirstFrameTracingButton.SetEnabled(false);
                    m_PreviousFrameTracingButton.SetEnabled(false);
                    m_PreviousStepTracingButton.SetEnabled(false);
                    m_NextStepTracingButton.SetEnabled(false);
                    m_NextFrameTracingButton.SetEnabled(false);
                    m_LastFrameTracingButton.SetEnabled(false);
                    m_CurrentFrameTextField.SetEnabled(false);
                    m_TotalFrameLabel.SetEnabled(false);
                }

                if (!m_LastUpdate.IsRunning)
                {
                    m_LastUpdate.Start();
                }
                if (force || EditorApplication.isPaused || m_LastUpdate.ElapsedMilliseconds > k_UpdateIntervalMs)
                {
                    m_CurrentFrameTextField.value = state.CurrentTracingFrame;
                    m_TotalFrameLabel.text        = $"/{Time.frameCount.ToString()}";
                    if (state.CurrentTracingStep != -1)
                    {
                        m_TotalFrameLabel.text += $" [{state.CurrentTracingStep}/{state.MaxTracingStep}]";
                    }

                    m_LastUpdate.Restart();
                }
            }
            else
            {
                m_LastUpdate.Stop();
                state.CurrentTracingFrame         = Time.frameCount;
                state.CurrentTracingStep          = -1;
                m_PickTargetLabel.text            = "";
                m_PickTargetIcon.style.visibility = StyleKeyword.Null;
                m_CurrentFrameTextField.value     = 0;
                m_PickTargetButton.SetEnabled(false);
                m_CurrentFrameTextField.SetEnabled(false);
                m_TotalFrameLabel.text = "/0";
                m_TotalFrameLabel.SetEnabled(false);
                m_FirstFrameTracingButton.SetEnabled(false);
                m_PreviousFrameTracingButton.SetEnabled(false);
                m_PreviousStepTracingButton.SetEnabled(false);
                m_NextStepTracingButton.SetEnabled(false);
                m_NextFrameTracingButton.SetEnabled(false);
                m_LastFrameTracingButton.SetEnabled(false);
            }
        }

        void OnFirstFrameTracingButton()
        {
            m_Store.GetState().CurrentTracingFrame = 0;
            m_Store.GetState().CurrentTracingStep  = -1;
            UpdateTracingMenu();
        }

        void OnPreviousFrameTracingButton()
        {
            if (m_Store.GetState().CurrentTracingFrame > 0)
            {
                m_Store.GetState().CurrentTracingFrame--;
                m_Store.GetState().CurrentTracingStep = -1;
                UpdateTracingMenu();
            }
        }

        void OnPreviousStepTracingButton()
        {
            if (m_Store.GetState().CurrentTracingStep > 0)
            {
                m_Store.GetState().CurrentTracingStep--;
            }
            else
            {
                if (m_Store.GetState().CurrentTracingStep == -1)
                {
                    m_Store.GetState().CurrentTracingStep = m_Store.GetState().MaxTracingStep;
                }
                else
                {
                    if (m_Store.GetState().CurrentTracingFrame > 0)
                    {
                        m_Store.GetState().CurrentTracingFrame--;
                        m_Store.GetState().CurrentTracingStep = m_Store.GetState().MaxTracingStep;
                    }
                }
            }

            UpdateTracingMenu();
        }

        void OnNextStepTracingButton()
        {
            if (m_Store.GetState().CurrentTracingStep < m_Store.GetState().MaxTracingStep&& m_Store.GetState().CurrentTracingStep >= 0)
            {
                m_Store.GetState().CurrentTracingStep++;
            }
            else
            {
                if (m_Store.GetState().CurrentTracingStep == -1 && (m_Store.GetState().CurrentTracingFrame < Time.frameCount))
                {
                    m_Store.GetState().CurrentTracingStep = 0;
                }
                else
                {
                    if (m_Store.GetState().CurrentTracingFrame < Time.frameCount)
                    {
                        m_Store.GetState().CurrentTracingFrame++;
                        m_Store.GetState().CurrentTracingStep = 0;
                    }
                }
            }

            UpdateTracingMenu();
        }

        void OnNextFrameTracingButton()
        {
            if (m_Store.GetState().CurrentTracingFrame < Time.frameCount)
            {
                m_Store.GetState().CurrentTracingFrame++;
                m_Store.GetState().CurrentTracingStep = -1;
                UpdateTracingMenu();
            }
        }

        void OnLastFrameTracingButton()
        {
            m_Store.GetState().CurrentTracingFrame = Time.frameCount;
            m_Store.GetState().CurrentTracingStep  = -1;
            UpdateTracingMenu();
        }
    }
        // PF FIXME should probably be an observer
        public void UpdateTracingMenu(TracingControlStateComponent.StateUpdater updater, bool force = true)
        {
            var state = m_CommandDispatcher.State;
            var tracingStatusState  = state.TracingStatusState;
            var tracingControlState = state.TracingControlState;
            var tracingDataState    = state.TracingDataState;

            if (EditorApplication.isPlaying && tracingStatusState.TracingEnabled)
            {
                m_PickTargetLabel.text            = ((Stencil)state.WindowState.GraphModel?.Stencil)?.Debugger?.GetTargetLabel(state.WindowState.GraphModel, tracingControlState.CurrentTracingTarget);
                m_PickTargetIcon.style.visibility = Visibility.Hidden;
                m_PickTargetButton.SetEnabled(true);
                if (EditorApplication.isPaused || !EditorApplication.isPlaying)
                {
                    m_FirstFrameTracingButton.SetEnabled(true);
                    m_PreviousFrameTracingButton.SetEnabled(true);
                    m_PreviousStepTracingButton.SetEnabled(true);
                    m_NextStepTracingButton.SetEnabled(true);
                    m_NextFrameTracingButton.SetEnabled(true);
                    m_LastFrameTracingButton.SetEnabled(true);
                    m_CurrentFrameTextField.SetEnabled(true);
                    m_TotalFrameLabel.SetEnabled(true);
                }
                else
                {
                    updater.CurrentTracingFrame = Time.frameCount;
                    updater.CurrentTracingStep  = -1;
                    m_FirstFrameTracingButton.SetEnabled(false);
                    m_PreviousFrameTracingButton.SetEnabled(false);
                    m_PreviousStepTracingButton.SetEnabled(false);
                    m_NextStepTracingButton.SetEnabled(false);
                    m_NextFrameTracingButton.SetEnabled(false);
                    m_LastFrameTracingButton.SetEnabled(false);
                    m_CurrentFrameTextField.SetEnabled(false);
                    m_TotalFrameLabel.SetEnabled(false);
                }

                if (!m_LastUpdate.IsRunning)
                {
                    m_LastUpdate.Start();
                }
                if (force || EditorApplication.isPaused || m_LastUpdate.ElapsedMilliseconds > k_UpdateIntervalMs)
                {
                    m_CurrentFrameTextField.value = tracingControlState.CurrentTracingFrame;
                    m_TotalFrameLabel.text        = $"/{Time.frameCount.ToString()}";
                    var currentTracingStep = tracingControlState.CurrentTracingStep;
                    if (currentTracingStep >= 0 && currentTracingStep < tracingDataState.MaxTracingStep)
                    {
                        m_TotalFrameLabel.text += $" [{currentTracingStep}/{tracingDataState.MaxTracingStep}]";
                    }

                    m_LastUpdate.Restart();
                }
            }
            else
            {
                m_LastUpdate.Stop();
                m_PickTargetLabel.text            = "";
                m_PickTargetIcon.style.visibility = StyleKeyword.Null;
                m_CurrentFrameTextField.value     = 0;
                m_PickTargetButton.SetEnabled(false);
                m_CurrentFrameTextField.SetEnabled(false);
                m_TotalFrameLabel.text = "/0";
                m_TotalFrameLabel.SetEnabled(false);
                m_FirstFrameTracingButton.SetEnabled(false);
                m_PreviousFrameTracingButton.SetEnabled(false);
                m_PreviousStepTracingButton.SetEnabled(false);
                m_NextStepTracingButton.SetEnabled(false);
                m_NextFrameTracingButton.SetEnabled(false);
                m_LastFrameTracingButton.SetEnabled(false);
            }
        }
Example #11
0
    public override VisualElement CreateInspectorGUI()
    {
        m_Root = new VisualElement();
        // root.Bind(serializedObject);
        // SerializedProperty property = serializedObject.GetIterator();
        // if (property.NextVisible(true)) // Expand first child.
        // {
        //     do
        //     {
        //         var field = new PropertyField(property);
        //         field.name = "PropertyField:" + property.propertyPath;
        //         if (property.propertyPath == "m_Script" && serializedObject.targetObject != null)
        //             field.SetEnabled(false);
        //         if (property.propertyPath != "CanvasOps")
        //             m_Root.Add(field);
        //     }
        //     while (property.NextVisible(false));
        // }
        var paletteProp = serializedObject.FindProperty("Palette");
        var palette     = new ObjectField("Palette");

        palette.objectType = typeof(Palette);
        palette.BindProperty(paletteProp);
        if (paletteProp.objectReferenceValue == null)
        {
            paletteProp.objectReferenceValue = AssetDatabase.LoadAssetAtPath <Palette>(AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("t:Palette").First()));
        }
        m_Root.Add(palette);
        var size = new Vector2IntField("Size");

        size.value = serializedObject.FindProperty("Size").vector2IntValue;
        m_Root.Add(size);
        var button = new Button(() => ResizeCanvas(size.value));

        button.text = "Resize Canvas";
        m_Root.Add(button);
        int frameCount  = serializedObject.FindProperty("Frames").arraySize;
        var frameSlider = new SliderInt("Frame", 0, frameCount - 1);

        frameSlider.BindProperty(serializedObject.FindProperty("FrameIndex"));
        frameSlider.RegisterValueChangedCallback(ChangeFrame);
        m_Root.Add(frameSlider);
        var frameIndex = new IntegerField("Frame");

        frameIndex.BindProperty(serializedObject.FindProperty("FrameIndex"));
        frameIndex.RegisterValueChangedCallback(ChangeFrame);
        frameIndex.SetEnabled(false);
        m_Root.Add(frameIndex);

        var importFrameButton = new Button(() => ImportFrame());

        importFrameButton.text = "Import Image";
        m_Root.Add(importFrameButton);

        m_Image       = new Image();
        m_Image.image = m_Texture;
        var desiredSize = 128f;

        if (m_Texture.width >= m_Texture.height)
        {
            m_Image.style.width  = desiredSize;
            m_Image.style.height = desiredSize * (m_Texture.height / (float)m_Texture.width);
        }
        else
        {
            m_Image.style.height = desiredSize;
            m_Image.style.width  = desiredSize * (m_Texture.width / (float)m_Texture.height);
        }
        // m_Image.RegisterCallback<MouseDownEvent>(RandomisePixels);
        var spacer = new VisualElement();

        spacer.style.height = 10;
        m_Root.Add(spacer);
        m_Root.Add(m_Image);
        return(m_Root);
    }