Esempio n. 1
0
        public static void OnApply_SetDimensionsTool(SetDimensionsTool tool, List <DMeshSO> targets)
        {
            tool.PushFinalChanges();
            foreach (var so in targets)
            {
                BakeScalingChangeOp change = new BakeScalingChangeOp(so);
                CC.ActiveScene.History.PushChange(change, false);
            }

            // should this be in history?
            CCActions.UpdateViewClippingBounds();

            CC.ActiveScene.History.PushInteractionCheckpoint();
        }
    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;
    }