Beispiel #1
0
        // internal api

        public InputField RegisterFloatInput(string inputName, string toolParamName, Interval1d validRange, string formatString = null)
        {
            InputField input = UnityUIUtil.FindInputAndAddFloatHandlers(this.gameObject, inputName,
                                                                        () => { return((float)ActiveParameterSet.GetValueDouble(toolParamName)); },
                                                                        (floatValue) => { ActiveParameterSet.SetValue <double>(toolParamName, floatValue); update_values_from_tool(); },
                                                                        (float)validRange.a, (float)validRange.b);

            TabOrder.Add(input);

            float_params.Add(new FloatInputParam()
            {
                widget = input, paramName = toolParamName, formatString = formatString
            });

            return(input);
        }
    void update_from_tool()
    {
        track_changes = false;

        dimension_x.text = ActiveParameterSet.GetValueDouble("dimension_x").ToString();
        dimension_y.text = ActiveParameterSet.GetValueDouble("dimension_y").ToString();
        dimension_z.text = ActiveParameterSet.GetValueDouble("dimension_z").ToString();

        scale_x.text = ActiveParameterSet.GetValueDouble("scale_x").ToString();
        scale_y.text = ActiveParameterSet.GetValueDouble("scale_y").ToString();
        scale_z.text = ActiveParameterSet.GetValueDouble("scale_z").ToString();

        uniform.isOn = ActiveParameterSet.GetValueBool("uniform");

        track_changes = true;
    }
    public void Start()
    {
        ITool curTool = CC.ActiveContext.ToolManager.ActiveRightTool;

        if (curTool == null)
        {
            return;
        }
        Tool = curTool as SetDimensionsTool;
        if (Tool == null)
        {
            return;
        }
        ActiveParameterSet = Tool.Parameters;

        dimension_x = UnityUIUtil.FindInputAndAddFloatHandlers(this.gameObject, "WidthInput",
                                                               () => { return((float)ActiveParameterSet.GetValueDouble("dimension_x")); },
                                                               (floatValue) => { set_value("dimension_x", floatValue); update_from_tool(); },
                                                               0, 9999999.0f);
        dimension_y = UnityUIUtil.FindInputAndAddFloatHandlers(this.gameObject, "HeightInput",
                                                               () => { return((float)ActiveParameterSet.GetValueDouble("dimension_y")); },
                                                               (floatValue) => { set_value("dimension_y", floatValue); update_from_tool(); },
                                                               0, 9999999.0f);
        dimension_z = UnityUIUtil.FindInputAndAddFloatHandlers(this.gameObject, "DepthInput",
                                                               () => { return((float)ActiveParameterSet.GetValueDouble("dimension_z")); },
                                                               (floatValue) => { set_value("dimension_z", floatValue); update_from_tool(); },
                                                               0, 9999999.0f);
        tabber.Add(dimension_x); tabber.Add(dimension_z); tabber.Add(dimension_y);

        scale_x = UnityUIUtil.FindInputAndAddFloatHandlers(this.gameObject, "WidthXInput",
                                                           () => { return((float)ActiveParameterSet.GetValueDouble("scale_x")); },
                                                           (floatValue) => { set_value("scale_x", floatValue); update_from_tool(); },
                                                           0, 9999999.0f);
        scale_y = UnityUIUtil.FindInputAndAddFloatHandlers(this.gameObject, "HeightXInput",
                                                           () => { return((float)ActiveParameterSet.GetValueDouble("scale_y")); },
                                                           (floatValue) => { set_value("scale_y", floatValue); update_from_tool(); },
                                                           0, 9999999.0f);
        scale_z = UnityUIUtil.FindInputAndAddFloatHandlers(this.gameObject, "DepthXInput",
                                                           () => { return((float)ActiveParameterSet.GetValueDouble("scale_z")); },
                                                           (floatValue) => { set_value("scale_z", floatValue); update_from_tool(); },
                                                           0, 9999999.0f);
        tabber.Add(scale_x); tabber.Add(scale_z); tabber.Add(scale_y);


        uniform = UnityUIUtil.FindToggleAndConnectToSource(this.gameObject, "UniformToggle",
                                                           () => { return(ActiveParameterSet.GetValueBool("uniform")); },
                                                           (boolValue) => { set_value("uniform", boolValue); });
        tabber.Add(uniform);

        objectFrame = UnityUIUtil.FindToggleAndConnectToSource(this.gameObject, "ObjectFrameToggle",
                                                               () => { return(ActiveParameterSet.GetValueBool("use_object_frame")); },
                                                               (boolValue) => { set_value("use_object_frame", boolValue); });
        tabber.Add(objectFrame);
        objectFrameRow = objectFrame.transform.parent.gameObject;

        // this doesn't work yet because we need to also change the visible dimensions...
        //objectFrameRow.SetVisible(Tool.Targets.Count() == 1);
        objectFrameRow.SetVisible(false);

        update_from_tool();

        curTool.Parameters.OnParameterModified += on_parameter_modified;
    }