Beispiel #1
0
        void UpdateUiAspects()
        {
            m_ManualLabelingContainer.SetEnabled(!m_AutoLabelingToggle.value);
            m_AutoLabelingContainer.SetEnabled(m_AutoLabelingToggle.value);

            m_AddManualLabelsTitle.style.display      = m_AutoLabelingToggle.value ? DisplayStyle.None : DisplayStyle.Flex;
            m_FromLabelConfigsContainer.style.display = m_AutoLabelingToggle.value ? DisplayStyle.None : DisplayStyle.Flex;
            m_SuggestedLabelsContainer.style.display  = m_AutoLabelingToggle.value ? DisplayStyle.None : DisplayStyle.Flex;

            m_CurrentLabelsListView.style.minHeight = m_AutoLabelingToggle.value ? 70 : 120;

            if (!m_AutoLabelingToggle.value || serializedObject.targetObjects.Length > 1 ||
                !SerializedObjectHasValidLabelingScheme(new SerializedObject(serializedObject.targetObjects[0])))
            {
                m_CurrentAutoLabel.style.display = DisplayStyle.None;
                m_AddAutoLabelToConfButton.SetEnabled(false);
            }
            else
            {
                m_CurrentAutoLabel.style.display = DisplayStyle.Flex;
                m_AddAutoLabelToConfButton.SetEnabled(true);
            }

            if (m_AutoLabelingToggle.value && serializedObject.targetObjects.Length > 1 && m_ItIsPossibleToAddMultipleAutoLabelsToConfig)
            {
                m_AddAutoLabelToConfButton.SetEnabled(true);
            }


            if (serializedObject.targetObjects.Length == 1)
            {
                m_AutoLabelingToggle.text = "Use Automatic Labeling";
            }
            else
            {
                m_CurrentAutoLabelTitle.text = "Select assets individually to inspect their automatic labels.";
                m_AutoLabelingToggle.text    = "Use Automatic Labeling for All Selected Items";
            }
        }
    private void AddNewTableEntry(Button pressedButton, SpeakEasyNode node, IntegerField indexField, TextField textField)
    {
        //Check if we by any chance already have a reference.
        for (int i = 0; i < localText.localizedText.Count; i++)
        {
            if (node.stringReference == "" || node.stringReference == System.String.Empty)
            {
                EditorUtility.DisplayDialog("Oops!", "Sorry, cannot add a new entry without a proper Identifier.", "OK");
                return;
            }

            if (node.stringReference == localText.localizedText[i].id)
            {
                //We already have a point of reference
                pressedButton.SetEnabled(false);
                node.stringIndex = i;
                indexField.SetValueWithoutNotify(node.stringIndex);
                textField.SetValueWithoutNotify(GetStringIndex(node.stringIndex));
                textField.SetEnabled(true);

                return;
            }
        }

        pressedButton.SetEnabled(false); //We no longer need a new reference point.

        //Give this node a new string ID
        node.stringIndex = localText.localizedText.Count; //the Count is always +1 which means it will place the new reference at the right index.. right?
        localText.localizedText.Add(new LocalizedText()
        {
            id = node.stringReference
        });                                                                           //we add the new address for the list.

        //Now we need to connect the three fields
        indexField.SetValueWithoutNotify(node.stringIndex);
        textField.SetValueWithoutNotify(GetStringIndex(node.stringIndex));
        textField.SetEnabled(true);
    }
            void AddBuildTarget(VisualElement targetsContainer, Dictionary <string, JSONValue> buildEntry)
            {
                if (buildEntry[k_JsonNodeNameEnabled].AsBool())
                {
                    ServicesConfiguration.instance.RequestCloudBuildApiUrl(cloudBuildApiUrl =>
                    {
                        var buildTargetName = buildEntry[k_JsonNodeNameName].AsString();
                        var buildTargetId   = buildEntry[k_JsonNodeNameBuildTargetId].AsString();
                        var buildTargetUrls = buildEntry[k_JsonNodeNameLinks].AsDict();
                        var startBuildUrl   = cloudBuildApiUrl + buildTargetUrls[k_JsonNodeNameStartBuilds].AsDict()[k_JsonNodeNameHref].AsString();

                        var targetContainer = new VisualElement();
                        targetContainer.AddToClassList(k_ClassNameTargetEntry);
                        var buildNameTextElement = new TextElement();
                        buildNameTextElement.AddToClassList(k_ClassNameTitle);
                        buildNameTextElement.text = buildTargetName;
                        targetContainer.Add(buildNameTextElement);
                        var buildButton  = new Button();
                        buildButton.name = k_BuildButtonNamePrefix + buildTargetId;
                        buildButton.AddToClassList(k_ClassNameBuildButton);
                        if (m_BillingPlanLabel.ToLower() == k_SubscriptionPersonal ||
                            k_SubscriptionTeamsBasic.ToLower() == k_SubscriptionPersonal)
                        {
                            buildButton.SetEnabled(false);
                        }
                        buildButton.text     = L10n.Tr(k_LabelBuildButton);
                        buildButton.clicked += () =>
                        {
                            var uploadHandler          = new UploadHandlerRaw(Encoding.UTF8.GetBytes(k_LaunchBuildPayload));
                            var launchBuildPostRequest = new UnityWebRequest(startBuildUrl,
                                                                             UnityWebRequest.kHttpVerbPOST)
                            {
                                downloadHandler = new DownloadHandlerBuffer(), uploadHandler = uploadHandler
                            };
                            launchBuildPostRequest.suppressErrorsToConsole = true;
                            launchBuildPostRequest.SetRequestHeader("AUTHORIZATION", $"Bearer {UnityConnect.instance.GetUserInfo().accessToken}");
                            launchBuildPostRequest.SetRequestHeader("Content-Type", "application/json;charset=utf-8");
                            m_Provider.m_BuildRequests.Add(launchBuildPostRequest);
                            var launchingMessage = string.Format(L10n.Tr(k_MessageLaunchingBuild), buildTargetName);

                            Debug.Log(launchingMessage);
                            NotificationManager.instance.Publish(
                                Notification.Topic.BuildService,
                                Notification.Severity.Info,
                                launchingMessage);

                            EditorAnalytics.SendLaunchCloudBuildEvent(new BuildPostInfo()
                            {
                                targetName = buildTargetName
                            });

                            var operation        = launchBuildPostRequest.SendWebRequest();
                            operation.completed += asyncOperation =>
                            {
                                try
                                {
                                    if (ServicesUtils.IsUnityWebRequestReadyForJsonExtract(launchBuildPostRequest))
                                    {
                                        try
                                        {
                                            if (launchBuildPostRequest.responseCode == k_HttpResponseCodeAccepted)
                                            {
                                                var jsonLaunchedBuildParser = new JSONParser(launchBuildPostRequest.downloadHandler.text);
                                                var launchedBuildJson       = jsonLaunchedBuildParser.Parse();
                                                var launchedBuilds          = launchedBuildJson.AsList();

                                                foreach (var rawLaunchedBuild in launchedBuilds)
                                                {
                                                    var launchedBuild = rawLaunchedBuild.AsDict();
                                                    if (launchedBuild.ContainsKey(k_JsonNodeNameBuild))
                                                    {
                                                        var buildNumber = launchedBuild[k_JsonNodeNameBuild].AsFloat().ToString();
                                                        var message     = string.Format(L10n.Tr(k_MessageLaunchedBuildSuccess), buildNumber, buildTargetName);
                                                        Debug.Log(message);
                                                        NotificationManager.instance.Publish(
                                                            Notification.Topic.BuildService,
                                                            Notification.Severity.Info,
                                                            message);
                                                    }
                                                    else if (launchedBuild.ContainsKey(k_JsonNodeNameError))
                                                    {
                                                        var message = string.Format(L10n.Tr(k_MessageLaunchedBuildFailedWithMsg), buildTargetName, launchedBuild[k_JsonNodeNameError].ToString());
                                                        Debug.LogError(message);
                                                        NotificationManager.instance.Publish(
                                                            Notification.Topic.BuildService,
                                                            Notification.Severity.Error,
                                                            message);
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                var message = L10n.Tr(k_MessageLaunchedBuildFailure);
                                                Debug.LogError(message);
                                                NotificationManager.instance.Publish(
                                                    Notification.Topic.BuildService,
                                                    Notification.Severity.Error,
                                                    message);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            NotificationManager.instance.Publish(
                                                Notification.Topic.BuildService,
                                                Notification.Severity.Error,
                                                L10n.Tr(k_MessageErrorForBuildLaunch));
                                            Debug.LogException(ex);
                                        }
                                    }
                                }
                                finally
                                {
                                    m_Provider.m_BuildRequests.Remove(launchBuildPostRequest);
                                    launchBuildPostRequest.Dispose();
                                    launchBuildPostRequest = null;
                                }
                            };
                        };
                        targetContainer.Add(buildButton);
                        targetsContainer.Add(targetContainer);

                        var separator = new VisualElement();
                        separator.AddToClassList(k_ClassNameSeparator);
                        targetsContainer.Add(separator);
                    });
                }
            }
Beispiel #4
0
 void OnOverlayEnabledChanged(bool visibility)
 {
     m_Toggle.SetValueWithoutNotify(visibility);
     m_Dropdown.SetEnabled(visibility);
 }
    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);
    }