protected override void register_parameters()
    {
        reduceMode = base.RegisterDropDown("ReduceTypeDropDown", "target_mode",
                                           new List <string>()
        {
            "Triangles", "Vertices", "Min Length"
        },
                                           new List <int>()
        {
            (int)ReduceOp.TargetModes.TriangleCount,
            (int)ReduceOp.TargetModes.VertexCount,
            (int)ReduceOp.TargetModes.MinEdgeLength
        });

        triangleCount = base.RegisterIntInput("TriangleCountInput", "triangle_count", new Interval1i(0, int.MaxValue));
        trianglePanel = this.gameObject.FindChildByName("TriangleCountParam", true);

        vertexCount = base.RegisterIntInput("VertexCountInput", "vertex_count", new Interval1i(0, int.MaxValue));
        vertexPanel = this.gameObject.FindChildByName("VertexCountParam", true);

        minEdgeLength      = base.RegisterFloatInput("MinEdgeLengthInput", "min_edge_length", new Interval1d(0.0001, 100), "F8");
        minEdgeLengthPanel = this.gameObject.FindChildByName("MinEdgeLengthParam", true);

        reproject    = base.RegisterToggle("ReprojectToggle", "reproject");
        replaceInput = base.RegisterToggle("ReplaceInputToggle", "replace_input");

        statusText = UnityUIUtil.FindTextAndSet(this.gameObject, "StatusText", "");
    }
Exemple #2
0
        public static void ShowModalConfirmDialog(
            string title, string instructions,
            string confirmText, string cancelText,
            object target,
            Action <object> onAccept, Action <object> onCancel)
        {
            GameObject dialog = GameObject.Instantiate <GameObject>(Resources.Load <GameObject>("ModalConfirmCancelDialog"));

            UnityUIUtil.FindTextAndSet(dialog, "Title", title);
            UnityUIUtil.FindTextAndSet(dialog, "InfoText", instructions);
            UnityUIUtil.FindTextAndSet(dialog, "OKText", confirmText);
            UnityUIUtil.FindTextAndSet(dialog, "CancelText", cancelText);

            Button cancelButton = UnityUIUtil.FindButtonAndAddClickHandler(dialog, "Cancel", () => {
                if (onCancel != null)
                {
                    onCancel(target);
                }
                context.RegisterNextFrameAction(() => {
                    GameObject.Destroy(dialog);
                });
            });

            Button okButton = UnityUIUtil.FindButtonAndAddClickHandler(dialog, "OK", () => {
                onAccept(target);
                context.RegisterNextFrameAction(() => {
                    GameObject.Destroy(dialog);
                });
            });

            okButton.Select();

            MainUICanvas.AddChild(dialog, false);
        }
    protected override void register_parameters()
    {
        closingMode = base.RegisterDropDown("FillTypeDropDown", "fill_type",
                                            new List <string>()
        {
            "Trivial", "Minimal", "Smooth"
        },
                                            new List <int>()
        {
            (int)FillHolesTool.FillTypes.Trivial,
            (int)FillHolesTool.FillTypes.Minimal,
            (int)FillHolesTool.FillTypes.Smooth
        });

        showHidden = base.RegisterToggle("ShowHiddenToggle", "show_hidden");

        minimalPanel  = this.gameObject.FindChildByName("MinimalPanel", true);
        smoothPanel   = this.gameObject.FindChildByName("SmoothPanel", true);
        fillAllButton = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "FillAllButton", on_fill_all_clicked);

        minOptimizeTris     = base.RegisterToggle("MinimalOptimizeTrisToggle", "optimize_tris");
        minOptTrisTolerance = base.RegisterFloatInput("MinimalOptTrisTolInput", "optimize_tris_deviation_thresh", new Interval1d(0, 1));

        smoothAutoTargetEdgeLen = base.RegisterToggle("AutoEdgeLengthToggle", "auto_edge_length");
        smoothTargetEdgeLen     = base.RegisterFloatInput("TargetEdgeLenInput", "edge_length", new Interval1d(0.01, 100));
        smoothOptRounds         = base.RegisterIntInput("OptimizationRoundsInput", "smooth_opt_rounds", new Interval1i(1, 999));

        statusText = UnityUIUtil.FindTextAndSet(this.gameObject, "StatusText", "");
    }
Exemple #4
0
    // Use this for initialization
    public void Start()
    {
        saveButton   = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "Save", on_save_clicked);
        cancelButton = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "Cancel", on_cancel_clicked);

        UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "CloseButton", destroy_dialog);

        GameObject textfieldGO = this.gameObject.FindChildByName("TextArea", true);

        settingsText = textfieldGO.GetComponent <TMP_InputField>();

        titleText = UnityUIUtil.FindTextAndSet(this.gameObject, "Title", "Edit Preset");
        errorText = UnityUIUtil.FindTextAndSet(this.gameObject, "ErrorMessage", " ");

        CC.OnPresetSelectionModified  += CC_OnPresetSelectionModified;
        CC.OnPrinterSelectionModified += CC_OnPrinterSelectionModified;
    }
Exemple #5
0
    void populate_list()
    {
        GameObject rowPrefab = Resources.Load <GameObject>("ManufacturerListItem");

        manufacturers = KnownManufacturerInfo.LoadManufacturers();
        foreach (var mfgInfo in manufacturers)
        {
            GameObject row = GameObject.Instantiate <GameObject>(rowPrefab);
            UnityUIUtil.FindTextAndSet(row, "Label", mfgInfo.name);
            Manufacturer mfg       = CC.PrinterDB.FindManufacturerByUUID(mfgInfo.uuid);
            bool         is_active = (mfg != null && CC.PrinterDB.IsDisabledManufacturer(mfg) == false);
            //UnityUIUtil.FindToggleAndSet(row, "ManufacturerListItem", is_active);
            UnityUIUtil.FindToggleAndSet(row, is_active);
            MfgListView.AddChild(row, false);

            mfgToRow[mfgInfo.uuid] = row;
        }
    }
Exemple #6
0
        public static void GetStringFromDialog(string title, string instructions, object target,
                                               Func <string, bool> ValidatorF, Action <string, object> onAccept, Action onCancel)
        {
            GameObject dialog = GameObject.Instantiate <GameObject>(Resources.Load <GameObject>("GetStringDialog"));

            UnityUIUtil.FindTextAndSet(dialog, "Title", title);
            UnityUIUtil.FindTextAndSet(dialog, "InfoText", instructions);

            Button cancelButton = UnityUIUtil.FindButtonAndAddClickHandler(dialog, "Cancel", () => {
                if (onCancel != null)
                {
                    onCancel();
                }
                context.RegisterNextFrameAction(() => {
                    GameObject.Destroy(dialog);
                });
            });

            var input = UnityUIUtil.FindInput(dialog, "TextEntry");

            Button okButton = UnityUIUtil.FindButtonAndAddClickHandler(dialog, "OK", () => {
                if (input.text.Length == 0)
                {
                    return;
                }
                if (ValidatorF != null && ValidatorF(input.text) == false)
                {
                    return;
                }

                onAccept(input.text, target);
                context.RegisterNextFrameAction(() => {
                    GameObject.Destroy(dialog);
                });
            });

            input.Select();

            MainUICanvas.AddChild(dialog, false);
        }
Exemple #7
0
        public static void ShowModalMessageDialog(
            string title, string message,
            string confirmText,
            object target,
            Action <object> onAccept)
        {
            GameObject dialog = GameObject.Instantiate <GameObject>(Resources.Load <GameObject>("ModalMessageDialog"));

            UnityUIUtil.FindTextAndSet(dialog, "Title", title);
            UnityUIUtil.FindTextAndSet(dialog, "InfoText", message);
            UnityUIUtil.FindTextAndSet(dialog, "OKText", confirmText);

            Button okButton = UnityUIUtil.FindButtonAndAddClickHandler(dialog, "OK", () => {
                onAccept?.Invoke(target);
                context.RegisterNextFrameAction(() => {
                    GameObject.Destroy(dialog);
                });
            });

            okButton.Select();
            MainUICanvas.AddChild(dialog, false);
        }
    // Use this for initialization
    public void Start()
    {
        dismissButton = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "DismissButton", on_dismiss);
        UnityUIUtil.FindTextAndSet(this.gameObject, "VersionText", string.Format("v{0}.{1}.{2}",
                                                                                 CotangentVersion.CurrentVersion.a, CotangentVersion.CurrentVersion.b, CotangentVersion.CurrentVersion.c));

        prefsTabButton   = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "PreferencesButton", on_prefs_tab);
        prefsTab         = this.gameObject.FindChildByName("PreferencesPanel", true);
        privacyTabButton = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "PrivacyButton", on_privacy_tab);
        privacyTab       = this.gameObject.FindChildByName("PrivacyPanel", true);
        aboutTabButton   = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "AboutButton", on_about_tab);
        aboutTab         = this.gameObject.FindChildByName("AboutPanel", true);



        startupWorkspace = new MappedDropDown(
            this.gameObject.FindChildByName("StartupWorkspaceDropDown", true).GetComponent <Dropdown>(),
            () => { return((int)CCPreferences.StartupWorkspace); },
            (intValue) => { CCPreferences.StartupWorkspace = (AppViewMode)intValue; });
        startupWorkspace.SetOptions(
            new List <string>()
        {
            "Print", "Repair", "Model"
        },
            new List <int>()
        {
            (int)AppViewMode.PrintView,
            (int)AppViewMode.RepairView,
            (int)AppViewMode.ModelView
        });
        startupWorkspace.SetFromId((int)CCPreferences.StartupWorkspace);


        graphicsQuality = new MappedDropDown(
            this.gameObject.FindChildByName("GraphicsQualityDropDown", true).GetComponent <Dropdown>(),
            () => { return((int)CCPreferences.GraphicsQuality); },
            (intValue) => { CCPreferences.GraphicsQuality = (CCPreferences.GraphicsQualityLevels)intValue; });
        graphicsQuality.SetOptions(
            new List <string>()
        {
            "Maximum", "High", "Medium", "Low", "Fastest"
        },
            new List <int>()
        {
            (int)CCPreferences.GraphicsQualityLevels.Max,
            (int)CCPreferences.GraphicsQualityLevels.High,
            (int)CCPreferences.GraphicsQualityLevels.Medium,
            (int)CCPreferences.GraphicsQualityLevels.Low,
            (int)CCPreferences.GraphicsQualityLevels.Fastest
        });
        graphicsQuality.SetFromId((int)CCPreferences.GraphicsQuality);


        cameraMode = new MappedDropDown(
            this.gameObject.FindChildByName("CameraModeDropDown", true).GetComponent <Dropdown>(),
            () => { return((int)CCPreferences.CameraMode); },
            (intValue) => { CCPreferences.CameraMode = (CCPreferences.CameraModes)intValue; });
        cameraMode.SetOptions(
            new List <string>()
        {
            "Perspective", "Orthographic"
        },
            new List <int>()
        {
            (int)CCPreferences.CameraModes.Perspective,
            (int)CCPreferences.CameraModes.Orthographic
        });
        cameraMode.SetFromId((int)CCPreferences.CameraMode);



        importXFormMode = new MappedDropDown(
            this.gameObject.FindChildByName("ImportXFormDropdown", true).GetComponent <Dropdown>(),
            () => { return((int)CCPreferences.ImportTransformMode); },
            (intValue) => { CCPreferences.ImportTransformMode = (CCPreferences.ImportTransformModes)intValue; });
        importXFormMode.SetOptions(
            new List <string>()
        {
            "Auto-Center First", "Auto-Center All", "No Transformations"
        },
            new List <int>()
        {
            (int)CCPreferences.ImportTransformModes.AutoCenterFirst,
            (int)CCPreferences.ImportTransformModes.AutoCenterAll,
            (int)CCPreferences.ImportTransformModes.NoAutoCenter
        });
        importXFormMode.SetFromId((int)CCPreferences.ImportTransformMode);


        importAssistantMode = new MappedDropDown(
            this.gameObject.FindChildByName("ImportAssistantModeDropdown", true).GetComponent <Dropdown>(),
            () => { return((int)CCPreferences.ImportAssistantMode); },
            (intValue) => { CCPreferences.ImportAssistantMode = (CCPreferences.ImportAssistantModes)intValue; });
        importAssistantMode.SetOptions(
            new List <string>()
        {
            "All Assistants", "Mesh Size Only", "Dimensions Only", "Disabled"
        },
            new List <int>()
        {
            (int)CCPreferences.ImportAssistantModes.All,
            (int)CCPreferences.ImportAssistantModes.MeshSizeOnly,
            (int)CCPreferences.ImportAssistantModes.PhysicalSizeOnly,
            (int)CCPreferences.ImportAssistantModes.Disabled
        });
        importAssistantMode.SetFromId((int)CCPreferences.ImportAssistantMode);


        largeMeshSizeInput = UnityUIUtil.FindInputAndAddIntHandlers(this.gameObject, "LargeMeshSizeInput",
                                                                    () => { return(CCPreferences.LargeMeshImportThreshold); },
                                                                    (intValue) => { CCPreferences.LargeMeshImportThreshold = intValue; },
                                                                    10000, 999999999);
        largeMeshSizeInput.text = CCPreferences.LargeMeshImportThreshold.ToString();


        unityPolicyButton = UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "PrivacyPolicyButton", on_unity_privacy_policy);


        // about dialog
        UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "GradientspaceWebButton", on_open_gradientspace_site);
        UnityUIUtil.FindButtonAndAddClickHandler(this.gameObject, "CotangentWebButton", on_open_cotangent_site);


        on_prefs_tab();
    }