Esempio n. 1
0
        public static void CreateButtonActions()
        {
            GameObject canvas   = CreateSceneObject.GetCanvasGameObject();
            GameObject buttonGO = DefaultControls.CreateButton(CreateSceneObject.GetStandardResources());

            buttonGO.transform.SetParent(canvas.transform, false);

            Button  button        = buttonGO.GetComponent <Button>();
            Graphic targetGraphic = button.targetGraphic;

            DestroyImmediate(button);
            ButtonActions buttonActions = buttonGO.AddComponent <ButtonActions>();

            buttonActions.targetGraphic = targetGraphic;
            Selection.activeGameObject  = buttonGO;
        }
Esempio n. 2
0
        public static void CreateToggleVariable()
        {
            GameObject canvas   = CreateSceneObject.GetCanvasGameObject();
            GameObject toggleGO = DefaultControls.CreateToggle(CreateSceneObject.GetStandardResources());

            toggleGO.transform.SetParent(canvas.transform, false);

            Toggle  toggle        = toggleGO.GetComponent <Toggle>();
            Graphic targetGraphic = toggle.targetGraphic;
            Graphic graphic       = toggle.graphic;

            DestroyImmediate(toggle);
            toggle = toggleGO.AddComponent <ToggleVariable>();
            toggle.targetGraphic       = targetGraphic;
            toggle.graphic             = graphic;
            Selection.activeGameObject = toggleGO;
        }
Esempio n. 3
0
        public static void CreateInputFieldVariable()
        {
            GameObject canvas  = CreateSceneObject.GetCanvasGameObject();
            GameObject inputGO = DefaultControls.CreateInputField(CreateSceneObject.GetStandardResources());

            inputGO.transform.SetParent(canvas.transform, false);

            InputField input                = inputGO.GetComponent <InputField>();
            Graphic    targetGraphic        = input.targetGraphic;
            Graphic    placeholderComponent = input.placeholder;
            Text       textComponent        = input.textComponent;

            DestroyImmediate(input);
            input = inputGO.AddComponent <InputFieldVariable>();
            input.targetGraphic        = targetGraphic;
            input.placeholder          = placeholderComponent;
            input.textComponent        = textComponent;
            Selection.activeGameObject = inputGO;
        }
        public static void CreateSliderVariable()
        {
            GameObject canvas   = CreateSceneObject.GetCanvasGameObject();
            GameObject sliderGO = DefaultControls.CreateSlider(CreateSceneObject.GetStandardResources());

            sliderGO.transform.SetParent(canvas.transform, false);

            Slider        slider        = sliderGO.GetComponent <Slider>();
            Graphic       targetGraphic = slider.targetGraphic;
            RectTransform rectFill      = slider.fillRect;
            RectTransform rectHandle    = slider.handleRect;

            DestroyImmediate(slider);
            slider = sliderGO.AddComponent <SliderVectorVariable>();
            slider.targetGraphic       = targetGraphic;
            slider.fillRect            = rectFill;
            slider.handleRect          = rectHandle;
            Selection.activeGameObject = sliderGO;
        }