public async void InitFromMetadata(IActionProvider actionProvider, Base.ActionMetadata actionMetadata, Base.ActionPoint actionPoint)
    {
        InitDialog(actionProvider, actionMetadata, actionPoint);
        actionParameters = await Base.Parameter.InitActionParameters(actionProvider.GetProviderId(), actionParametersMetadata.Values.ToList(), DynamicContent, OnChangeParameterHandler, DynamicContentLayout, CanvasRoot, CurrentActionPoint, false);

        nameInput.SetValue(Base.ProjectManager.Instance.GetFreeActionName(actionMetadata.Name));
    }
예제 #2
0
    public async void Init(InteractiveObject objectToRename, UnityAction updateVisibilityCallback, bool isNewObject = false, UnityAction cancelCallback = null, UnityAction confirmCallback = null, bool keepObjectLocked = false)
    {
        if (objectToRename == null)
        {
            return;
        }
        if (!await objectToRename.WriteLock(false))
        {
            return;
        }

        this.isNewObject          = isNewObject;
        _updateVisibilityCallback = updateVisibilityCallback;
        selectedObject            = objectToRename;


        Title.text            = "Rename " + selectedObject.GetObjectTypeName();
        this.keepObjectLocked = keepObjectLocked;

        nameInput.SetValue(objectToRename.GetName());
        nameInput.SetLabel("Name", "New name");
        nameInput.SetType("string");
        CloseBtn.Button.onClick.RemoveAllListeners();
        CloseBtn.Button.onClick.AddListener(Cancel);
        if (cancelCallback != null)
        {
            CloseBtn.Button.onClick.AddListener(cancelCallback);
        }
        this.confirmCallback = confirmCallback;
    }
예제 #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="metadata"></param>
 /// <param name="callback">Function to be called if adding action object was successful</param>
 public void InitFromMetadata(Base.ActionObjectMetadata metadata, System.Action callback = null)
 {
     InitDialog(metadata);
     actionParameters = Base.Parameter.InitParameters(parametersMetadata.Values.ToList(), DynamicContent, OnChangeParameterHandler, DynamicContentLayout, CanvasRoot, false, false, null);
     nameInput.SetValue(Base.SceneManager.Instance.GetFreeAOName(metadata.Type));
     this.callback = callback;
 }
 /// <summary>
 /// Updates values of joints (angles) in joints dynamic list (expert block)
 /// </summary>
 private void UpdateJointsValues()
 {
     foreach (IO.Swagger.Model.Joint joint in joints.Joints)
     {
         LabeledInput     labeledInput     = GetJointInput(joint.Name);
         NumberFormatInfo numberFormatInfo = new NumberFormatInfo();
         numberFormatInfo.NumberDecimalSeparator = ".";
         labeledInput.SetValue(joint.Value.ToString(numberFormatInfo));
     }
 }
예제 #5
0
 public void Open(string selectedScene = null)
 {
     base.Open();
     if (selectedScene != null)
     {
         SetSelectedValue(ToggleGroup, selectedScene);
     }
     NewProjectName.SetValue("");
     FieldChanged();
 }
예제 #6
0
 public void SetValue(object value)
 {
     IO.Swagger.Model.Pose pose = (IO.Swagger.Model.Pose)value;
     this.pose = pose;
     posX.SetValue(pose.Position.X);
     posY.SetValue(pose.Position.Y);
     posZ.SetValue(pose.Position.Z);
     orX.SetValue(pose.Orientation.X);
     orY.SetValue(pose.Orientation.Y);
     orZ.SetValue(pose.Orientation.Z);
     orW.SetValue(pose.Orientation.W);
 }
    /// <summary>
    /// Updates list of joints in expert block
    /// </summary>
    private void UpdateJointsList()
    {
        DestroyJointsFields();

        foreach (IO.Swagger.Model.Joint joint in joints.Joints)
        {
            LabeledInput labeledInput = Instantiate(GameManager.Instance.LabeledFloatInput, JointsDynamicList.transform).GetComponent <LabeledInput>();
            labeledInput.SetLabel(joint.Name, joint.Name);

            NumberFormatInfo numberFormatInfo = new NumberFormatInfo();
            numberFormatInfo.NumberDecimalSeparator = ".";
            labeledInput.SetValue(joint.Value.ToString(numberFormatInfo));
            //labeledInput.Input.placeholder.color = Color.white;
            // text object of TMP input cannot be accessed directly
            //labeledInput.Input.GetComponentsInChildren<TMPro.TextMeshProUGUI>()
            //      .First(c => c.gameObject.name == "Text").color = Color.white;
            labeledInput.SetDarkMode(false);
        }
    }
예제 #8
0
    /// <summary>
    /// Updates values (angles) of joints in expert block
    /// </summary>
    public void UpdateJointsList()
    {
        foreach (RectTransform o in JointsDynamicList.GetComponentsInChildren <RectTransform>())
        {
            if (!o.gameObject.CompareTag("Persistent"))
            {
                Destroy(o.gameObject);
            }
        }

        foreach (IO.Swagger.Model.Joint joint in joints.Joints)
        {
            LabeledInput labeledInput = Instantiate(GameManager.Instance.LabeledFloatInput, JointsDynamicList.transform).GetComponent <LabeledInput>();
            labeledInput.SetLabel(joint.Name, joint.Name);

            NumberFormatInfo numberFormatInfo = new NumberFormatInfo();
            numberFormatInfo.NumberDecimalSeparator = ".";
            labeledInput.SetValue(joint.Value.ToString(numberFormatInfo));
        }
    }
예제 #9
0
    private bool cancelCallbackInvoked; //flag: only cancel callback should be invoked if canceled

    /// <summary>
    ///
    /// </summary>
    /// <param name="projectParameter"></param>
    public async Task <bool> Init(System.Action <string> onCloseCallback, System.Action onCancelCallback, ProjectParameter projectParameter = null, string ofType = null)
    {
        this.projectParameter = projectParameter;
        isNewConstant         = projectParameter == null;
        this.onCloseCallback  = onCloseCallback;
        this.onCancelCallback = onCancelCallback;
        cancelCallbackInvoked = false;

        dropdown.Dropdown.dropdownItems.Clear();
        foreach (string type in Enum.GetNames(typeof(ProjectParameterTypes)))
        {
            CustomDropdown.Item item = new CustomDropdown.Item {
                itemName        = type,
                OnItemSelection = new UnityEvent()
            };
            item.OnItemSelection.AddListener(() => OnTypeSelected(type));
            dropdown.Dropdown.dropdownItems.Add(item);
        }


        if (isNewConstant)
        {
            Title.text = "New project parameter";
            removeButton.SetActive(false);
            nameInput.SetValue("");
            valueInput.SetValue("");
            OnTypeSelected(ofType == null ? ProjectParameterTypes.integer : ProjectParametersHelper.ConvertStringParameterTypeToEnum(ofType));
            dropdown.Dropdown.selectedItemIndex = (int)selectedType;
            dropdown.Dropdown.SetupDropdown();
            dropdown.Dropdown.GetComponent <Button>().interactable = ofType == null;
        }
        else     //editing constant
        {
            try {
                await WebsocketManager.Instance.WriteLock(projectParameter.Id, false);

                Title.text = "Edit project parameter";
                removeButton.SetActive(true);
                nameInput.SetValue(projectParameter.Name);
                OnTypeSelected(projectParameter.Type);
                dropdown.Dropdown.selectedItemIndex = (int)selectedType;
                dropdown.Dropdown.SetupDropdown();
                dropdown.Dropdown.GetComponent <Button>().interactable = false;

                object value = ProjectParametersHelper.GetValue(projectParameter.Value, selectedType);
                if (selectedType == ProjectParameterTypes.boolean)
                {
                    trueToggle.isOn = (bool)value;
                }
                else
                {
                    valueInput.SetValue(value);
                }
            } catch (RequestFailedException e) {
                Notifications.Instance.ShowNotification("Failed to lock " + projectParameter.Name, e.Message);
                this.projectParameter = null;
                return(false);
            }
        }
        return(true);
    }
예제 #10
0
    private void OnProjectOrSceneLoaded(bool project)
    {
        foreach (GameObject obj in ProjectRelatedSettings)
        {
            obj.SetActive(project);
        }
        if (project)
        {
            APSizeSlider.gameObject.SetActive(true);
            APOrientationsVisibility.gameObject.SetActive(true);
            APSizeSlider.value = ProjectManager.Instance.APSize;
            APOrientationsVisibility.SetValue(Base.ProjectManager.Instance.APOrientationsVisible);

            SwitchToProjectParametersBtn.SetInteractivity(true);
            SwitchToProjectParametersBtnImage.color = Color.white;
            GenerateParameterButtons();
            WebsocketManager.Instance.OnProjectParameterAdded   += OnProjectParameterAdded;
            WebsocketManager.Instance.OnProjectParameterRemoved += OnProjectParameterRemoved;
        }
        else
        {
            APSizeSlider.gameObject.SetActive(false);
            APOrientationsVisibility.gameObject.SetActive(false);
            SwitchToProjectParametersBtn.SetInteractivity(false, "Project parameters are available only in project editor.");
            SwitchToProjectParametersBtnImage.color = Color.gray;
        }

        Interactibility.SetValue(Base.SceneManager.Instance.ActionObjectsInteractive);
        RobotsEEVisible.SetValue(Base.SceneManager.Instance.RobotsEEVisible, false);
        ActionObjectsVisibilitySlider.SetValueWithoutNotify(SceneManager.Instance.ActionObjectsVisibility * 100f);

#if UNITY_ANDROID && AR_ON
        recalibrationTime.SetValue(CalibrationManager.Instance.AutoRecalibrateTime);
        Trackables.SetValue(PlayerPrefsHelper.LoadBool("control_box_display_trackables", false));
        CalibrationElements.Interactable = false;
        CalibrationElements.SetValue(true);
        CalibrationElementsTooltip.DisplayAlternativeDescription = true;


        bool useAutoCalib = PlayerPrefsHelper.LoadBool("control_box_autoCalib", true);

        AutoCalibTooltip.DisplayAlternativeDescription = useAutoCalib;


        AutoCalibration.SetValue(useAutoCalib);
        // If the toggle is unchanged, we need to manually call the EnableAutoReCalibration function.
        // If the toggle has changed, the function will be called automatically. So we need to avoid calling it twice.
        if (((bool)AutoCalibration.GetValue() && useAutoCalib) || (!(bool)AutoCalibration.GetValue() && !useAutoCalib))
        {
            EnableAutoReCalibration(useAutoCalib);
        }
#endif
        ConnectionsSwitch.SetValue(PlayerPrefsHelper.LoadBool("control_box_display_connections", true));
        recalibrationTime.SetValue(PlayerPrefsHelper.LoadString("/autoCalib/recalibrationTime", "120"));
        string uri = PlayerPrefsHelper.LoadString("ProjectServiceURI", "");
        ProjectServiceURI.Input.SetValue(GetProjectServiceURI(false));
        if (string.IsNullOrEmpty(uri))
        {
            ResetProjectServiceURIButton.SetInteractivity(false, "Default value is already set");
        }
        else
        {
            ResetProjectServiceURIButton.SetInteractivity(true);
        }
    }
예제 #11
0
    public override void SetType(string type, bool linkable, bool switchBtnClicked)
    {
        base.SetType(type, linkable, switchBtnClicked);

        if (type == "link")
        {
            //Input.gameObject.SetActive(false);
            //Input.Input.onValueChanged.
            //Input.Input.onValueChanged.RemoveAllListeners();
        }
        else if (type == ProjectParameterText)
        {
            //Input.gameObject.SetActive(false);
            //Input.Input.onValueChanged.RemoveAllListeners();
        }
        else
        {
            //Input.gameObject.SetActive(true);
            //Input.Input.onValueChanged.RemoveAllListeners();
            Input.SetType(type);
            switch (ParameterMetadata.Type)
            {
            case "integer":
                if (string.IsNullOrEmpty(Input.Input.text))
                {
                    Input.SetValue(ParameterMetadata.GetDefaultValue <int>());
                }

                if (switchBtnClicked)
                {
                    Input.Input.onValueChanged.Invoke(Input.Input.text);
                }
                else
                {
                    Input.Input.onValueChanged.AddListener((string value) => OnChangeInt(value, type));
                }
                break;

            case "double":
                if (string.IsNullOrEmpty(Input.Input.text))
                {
                    Input.SetValue(ParameterMetadata.GetDefaultValue <double>());
                }
                if (switchBtnClicked)
                {
                    Input.Input.onValueChanged.Invoke(Input.Input.text);
                }
                else
                {
                    Input.Input.onValueChanged.AddListener((string value) => OnChangeDouble(value, type));
                }
                break;

            case "string":
                if (string.IsNullOrEmpty(Input.Input.text))
                {
                    Input.SetValue(ParameterMetadata.GetDefaultValue <string>());
                }
                if (switchBtnClicked)
                {
                    Input.Input.onValueChanged.Invoke(Input.Input.text);
                }
                else
                {
                    Input.Input.onValueChanged.AddListener((string value) => onChangeParameterHandler(Input.GetName(), value, type));
                }
                break;
            }
        }
    }