Esempio n. 1
0
        void Awake()
        {
            // create range sliders
            // slider
            GameObject rangeSliderPrefab = Resources.Load <GameObject>("VPET/Prefabs/RangeTemplate");

            if (rangeSliderPrefab == null)
            {
                Debug.LogError(string.Format("{0}: Cannot load: RangeTemplate.", this.GetType()));
            }
            else
            {
                // intensity
                GameObject sliderInstance = Instantiate(rangeSliderPrefab);
                sliderInstance.name = rangeSliderPrefab.name;
                sliderInstance.transform.SetParent(this.transform, false);
                sliderInstance.transform.localPosition = new Vector3(0, (-VPETSettings.Instance.canvasHalfHeight + 2 * UI.ButtonOffset) * VPETSettings.Instance.canvasAspectScaleFactor, 0);
                sliderInstance.transform.localScale    = Vector3.one;
                slider = sliderInstance.GetComponent <RangeSlider>();

                /*
                 *  // range
                 *  sliderInstance = Instantiate(rangeSliderPrefab);
                 *  sliderInstance.name = rangeSliderPrefab.name + "_range";
                 *  sliderInstance.transform.parent = this.transform;
                 *  sliderInstance.transform.localPosition = new Vector3(100, 0, 0);
                 *  sliderInstance.transform.localScale = Vector3.one;
                 *  rangeSlider = sliderInstance.GetComponent<RangeSlider>();
                 *  rangeSlider.Callback = this.updateRange;
                 *
                 *  // angle
                 *  sliderInstance = Instantiate(rangeSliderPrefab);
                 *  sliderInstance.name = rangeSliderPrefab.name + "_angle";
                 *  sliderInstance.transform.parent = this.transform;
                 *  sliderInstance.transform.localPosition = new Vector3(400, 0, 0);
                 *  sliderInstance.transform.localScale = Vector3.one;
                 *  angleSlider = sliderInstance.GetComponent<RangeSlider>();
                 *  angleSlider.MaxValue = 179f;
                 *  angleSlider.Callback = this.updateAngle;
                 */
            }

            // color wheel
            GameObject colorWheelPrefab = Resources.Load <GameObject>("VPET/ColorWheelTemplate");

            if (colorWheelPrefab == null)
            {
                Debug.LogError(string.Format("{0}: Cannot load: ColorWheelTemplate.", this.GetType()));
            }
            else
            {
                GameObject colorWheelInstance = Instantiate(colorWheelPrefab);
                colorWheelInstance.transform.SetParent(this.transform, false);
                colorWheelInstance.transform.localPosition = new Vector3(-VPETSettings.Instance.canvasHalfWidth + 250, (-VPETSettings.Instance.canvasHalfHeight + 250) * VPETSettings.Instance.canvasAspectScaleFactor, 0);
                colorWheelInstance.transform.localScale    = 4 * Vector3.one;
                colorWheel          = colorWheelInstance.GetComponent <ColorWheel>();
                colorWheel.Callback = this.updateColor;
            }
        }
Esempio n. 2
0
        //! setup function for all the slider UIs in scout view
        private void setupCameraSlider()
        {
            // check if slider prefab is available
            GameObject rangeSliderPrefab = Resources.Load <GameObject>("VPET/Prefabs/RangeTemplate");

            if (rangeSliderPrefab == null)
            {
                Debug.LogError(string.Format("{0}: Cannot load: RangeTemplate.", this.GetType()));
            }
            else
            {
                // create camera slider object
                GameObject cameraSlider = Instantiate(rangeSliderPrefab);
                cameraSlider.name = rangeSliderPrefab.name;
                cameraSlider.transform.SetParent(secondaryMenu.transform, false);
                cameraSlider.transform.localPosition = new Vector3(0, (-VPETSettings.Instance.canvasHalfHeight + 2 * UI.ButtonOffset) * VPETSettings.Instance.canvasAspectScaleFactor, 0);
                cameraSlider.transform.localScale    = Vector3.one;
                cameraSlider.SetActive(false);

                //! slider instance for camera paramenters
                slider = cameraSlider.GetComponent <RangeSlider>();
            }
        }
Esempio n. 3
0
        //!
        //! Use this for initialization
        //!
        void Start()
        {
            arKeyVideoPlane = GameObject.Find("GUI/Canvas/ARVideoPlane");

            try
            {
                //cache reference to main Controller
                mainController = GameObject.Find("MainController").GetComponent <MainController>();


                //cache reference to animation Controller
                animationController = GameObject.Find("AnimationController").GetComponent <AnimationController>();
            }
            catch
            {
                print("Fix Me");
            }


            // get range slider
            rangeSlider = canvas.GetComponentInChildren <RangeSlider>(true);
            if (rangeSlider == null)
            {
                Debug.LogError(string.Format("{0}: Cant Find Component in Canvas: RangeSlider.", this.GetType()));
            }
            rangeSlider.OnValueChanged.AddListener(onRangeSliderChanged);

            // get light settings widget
            lightSettingsWidget = canvas.GetComponentInChildren <LightSettingsWidget>(true);
            if (lightSettingsWidget == null)
            {
                Debug.LogError(string.Format("{0}: Cant Find Component in Canvas: LightSettingsWidget.", this.GetType()));
            }


            //initalize main Menu
            GameObject mainMenuObject = new GameObject("mainMenuObject");

            mainMenuObject.transform.SetParent(this.transform.parent, false);
            mainMenu = mainMenuObject.AddComponent <MainMenu>();

            //initalize secondary Menu
            GameObject secondaryMenuObj = new GameObject("secondaryMenuObject");

            secondaryMenuObj.transform.SetParent(this.transform, false);
            secondaryMenu = secondaryMenuObj.AddComponent <SecondaryMenu>();

            //initalize center Menu
            GameObject centerMenuObj = new GameObject("centerMenuObject");

            centerMenuObj.transform.SetParent(this.transform, false);
            centerMenu = centerMenuObj.AddComponent <CenterMenu>();

            helpContext = GameObject.Find("GUI/Canvas/HelpScreen");

            //initalize paramter Menu
            GameObject paramterMenuObj = new GameObject("paramterMenuObj");

            paramterMenuObj.transform.SetParent(this.transform, false);
            parameterMenu = paramterMenuObj.AddComponent <SubMenu>();

            //store scene scale lable reference
            scaleLable = GameObject.Find("GUI/Canvas/ARConfigWidget/scale_value").GetComponent <Text>();

            // initalize ConfigWidget
            GameObject refObject = GameObject.Find("GUI/Canvas/ConfigWidget");

            if (refObject == null)
            {
                Debug.LogWarning(string.Format("{0}: No GUI/Canvas/ConfigWidget Object found. Load From Resource.", this.GetType()));
                GameObject refObjectPrefab = Resources.Load <GameObject>("VPET/Prefabs/ConfigWidget");
                refObject      = Instantiate(refObjectPrefab);
                refObject.name = refObjectPrefab.name;
                GameObject refParent = GameObject.Find("GUI/Canvas");
                refObject.transform.SetParent(refParent.transform, false);
            }
            configWidget = refObject.GetComponent <ConfigWidget>();
            if (configWidget == null)
            {
                Debug.LogWarning(string.Format("{0}: No ConfigWidget Component found. Create", this.GetType()));
                configWidget = refObject.AddComponent <ConfigWidget>();
            }
            // Submit listener
            configWidget.SubmitEvent.AddListener(mainController.configWidgetSubmit);
            // Ambient light listener
            configWidget.AmbientChangedEvent.AddListener(mainController.setAmbientIntensity);

#if USE_AR
            configWidget.ToggleAREvent.AddListener(mainController.ToggleArMode);
            // ar key connects
            configWidget.KeyDepthChangedEvent.AddListener(mainController.setARKeyDepth);
            configWidget.KeyColorChangedEvent.AddListener(mainController.setARKeyColor);
            configWidget.KeyRadiusChangedEvent.AddListener(mainController.setARKeyRadius);
            configWidget.KeyThresholdChangedEvent.AddListener(mainController.setARKeyThreshold);
            configWidget.ToggleARMatteEvent.AddListener(mainController.ToggleARMatteMode);
            configWidget.ToggleARKeyEvent.AddListener(mainController.ToggleARKeyMode);
            // add other ar managers here or change a global variable like VPET.Settings.sceneScale!
#endif


            //initalise mainMenu button
            IMenuButton iMainMenuButton = Elements.MenuButtonToggle();
            mainMenuButton      = ((Button)iMainMenuButton).gameObject;
            mainMenuButton.name = "MainMenuButton";
            mainMenuButton.transform.SetParent(this.transform.parent, false);
            mainMenuButton.GetComponent <RectTransform>().localPosition = new Vector2(VPETSettings.Instance.canvasHalfWidth - UI.ButtonOffset, (VPETSettings.Instance.canvasHalfHeight - UI.ButtonOffset) * VPETSettings.Instance.canvasAspectScaleFactor);
            iMainMenuButton.AddAction(GeneralMenu_Main_sel, GeneralMenu_Main_nrm, () => mainMenuToggle());
            mainMenuButton.SetActive(false);
            iMainMenuButton.Menu = mainMenu;

            //call setup function for all available menues
            setupMainMenu();
            setupSecondaryMenu();
            setupCenterMenu();
            setupParameterMenu();
        }
Esempio n. 4
0
        //!
        //! Use this for initialization
        //!
        void Start()
        {
            try
            {
                //cache reference to main Controller
                mainController = GameObject.Find("MainController").GetComponent <MainController>();


                //cache reference to animation Controller
                animationController = GameObject.Find("AnimationController").GetComponent <AnimationController>();

#if USE_TANGO
                //cache reference to tango Controller
                tangoController = GameObject.Find("Tango").GetComponent <TangoController>();
#endif
            }
            catch
            {
                print("Fix Me");
            }


            // get range slider
            rangeSlider = canvas.GetComponentInChildren <RangeSlider>(true);
            if (rangeSlider == null)
            {
                Debug.LogError(string.Format("{0}: Cant Find Component in Canvas: RangeSlider.", this.GetType()));
            }
            rangeSlider.OnValueChanged.AddListener(onRangeSliderChanged);

            // get light settings widget
            lightSettingsWidget = canvas.GetComponentInChildren <LightSettingsWidget>(true);
            if (lightSettingsWidget == null)
            {
                Debug.LogError(string.Format("{0}: Cant Find Component in Canvas: LightSettingsWidget.", this.GetType()));
            }


            //initalize main Menu
            GameObject mainMenuObject = new GameObject("mainMenuObject");
            mainMenuObject.transform.SetParent(this.transform.parent, false);
            mainMenu = mainMenuObject.AddComponent <MainMenu>();

            //initalize secondary Menu
            GameObject secondaryMenuObj = new GameObject("secondaryMenuObject");
            secondaryMenuObj.transform.SetParent(this.transform, false);
            secondaryMenu = secondaryMenuObj.AddComponent <SecondaryMenu>();

            //initalize center Menu
            GameObject centerMenuObj = new GameObject("centerMenuObject");
            centerMenuObj.transform.SetParent(this.transform, false);
            centerMenu = centerMenuObj.AddComponent <CenterMenu>();

            //initalize paramter Menu
            GameObject paramterMenuObj = new GameObject("paramterMenuObj");
            paramterMenuObj.transform.SetParent(this.transform, false);
            parameterMenu = paramterMenuObj.AddComponent <SubMenu>();

            // initalize ConfigWidget
            GameObject refObject = GameObject.Find("GUI/Canvas/ConfigWidget");
            if (refObject == null)
            {
                Debug.LogWarning(string.Format("{0}: No GUI/Canvas/ConfigWidget Object found. Load From Resource.", this.GetType()));
                GameObject refObjectPrefab = Resources.Load <GameObject>("VPET/Prefabs/ConfigWidget");
                refObject      = Instantiate(refObjectPrefab);
                refObject.name = refObjectPrefab.name;
                GameObject refParent = GameObject.Find("GUI/Canvas");
                refObject.transform.SetParent(refParent.transform, false);
            }
            configWidget = refObject.GetComponent <ConfigWidget>();
            if (configWidget == null)
            {
                Debug.LogWarning(string.Format("{0}: No ConfigWidget Component found. Create", this.GetType()));
                configWidget = refObject.AddComponent <ConfigWidget>();
            }
            // Submit listener
            configWidget.SubmitEvent.AddListener(mainController.configWidgetSubmit);
            // Ambient light listener
            configWidget.AmbientChangedEvent.AddListener(mainController.setAmbientIntensity);

#if USE_TANGO
            // Show Tango Scale UI objects
            GameObject tangoScaleSliderUI = GameObject.Find("GUI/Canvas/ConfigWidget/TangoScale_slider");
            // tangoScaleSliderUI.transform.localPosition = new Vector3(31.0f, -560.0f, 0.0f);
            GameObject tangoScaleLabelUI = GameObject.Find("GUI/Canvas/ConfigWidget/TangoScale_label");
            //tangoScaleLabelUI.transform.localPosition = new Vector3(-105.0f, 530.0f, 0.0f);
            GameObject startButton     = GameObject.Find("GUI/Canvas/ConfigWidget/Start_button");
            GameObject sliderValueText = GameObject.Find("GUI/Canvas/ConfigWidget/TangoScale_Value");
            sliderValueText.gameObject.SetActive(true);
            tangoScaleLabelUI.gameObject.SetActive(true);
            tangoScaleSliderUI.gameObject.SetActive(true);
            // Tango Scale Listener
            configWidget.TangoScaleChangedEvent.AddListener(tangoController.setTangoScaleIntensity);
            configWidget.OnSceneScaleChanged.AddListener(tangoController.scaleMovement);
#endif


            /*
             *  //initalize undo buttons
             *  undoButton = Instantiate(GameObject.Find("ButtonTemplate"));
             *  undoButton.transform.SetParent(this.transform,false);
             *  //undoButton.GetComponent<RectTransform>().sizeDelta = SpriteSize;
             *  undoButton.GetComponent<RectTransform>().position = new Vector2(Screen.height / 16 + 10, ((Screen.height / 3) * 2) - (Screen.height / 8 + 10));
             *  undoButton.GetComponent<Image>().sprite =   GeneralMenu_Undo_nrm;
             *  SpriteState undoSprites = new SpriteState();
             *  undoSprites.disabledSprite = GeneralMenu_Undo_nrm;
             *  undoSprites.highlightedSprite = GeneralMenu_Undo_nrm;
             *  undoSprites.pressedSprite = GeneralMenu_Undo_sel;
             *  undoButton.GetComponent<Button>().spriteState = undoSprites;
             *  undoButton.GetComponent<Button>().interactable = false;
             *  undoButton.GetComponent<Button>().onClick.AddListener(() => undoButtonClicked());
             *  // temp hide it
             *  undoButton.GetComponent<Image>().enabled = false;
             *
             *  //initalize redo buttons
             *  redoButton = Instantiate(GameObject.Find("ButtonTemplate"));
             *  redoButton.transform.SetParent(this.transform, false);
             *  //redoButton.GetComponent<RectTransform>().sizeDelta = SpriteSize;
             *  redoButton.GetComponent<RectTransform>().position = new Vector2(Screen.width - (Screen.height / 16 + 10), ((Screen.height / 3) * 2) - (Screen.height / 8 + 10));
             *  redoButton.GetComponent<Image>().sprite = GeneralMenu_Redo_nrm;
             *  SpriteState redoSprites = new SpriteState();
             *  redoSprites.disabledSprite = GeneralMenu_Redo_nrm;
             *  redoSprites.highlightedSprite = GeneralMenu_Redo_nrm;
             *  redoSprites.pressedSprite = GeneralMenu_Redo_sel;
             *  redoButton.GetComponent<Button>().spriteState = redoSprites;
             *  redoButton.GetComponent<Button>().interactable = false;
             *  redoButton.GetComponent<Button>().onClick.AddListener(() => redoButtonClicked());
             *  // temp hide it
             *  redoButton.GetComponent<Image>().enabled = false;
             */

            //initalise mainMenu button
            IMenuButton iMainMenuButton = Elements.MenuButtonToggle();
            mainMenuButton      = ((Button)iMainMenuButton).gameObject;
            mainMenuButton.name = "MainMenuButton";
            mainMenuButton.transform.SetParent(this.transform.parent, false);
            mainMenuButton.GetComponent <RectTransform>().localPosition = new Vector2(VPETSettings.Instance.canvasHalfWidth - UI.ButtonOffset, (VPETSettings.Instance.canvasHalfHeight - UI.ButtonOffset) * VPETSettings.Instance.canvasAspectScaleFactor);
            iMainMenuButton.AddAction(GeneralMenu_Main_sel, GeneralMenu_Main_nrm, () => mainMenuToggle());
            mainMenuButton.SetActive(false);
            iMainMenuButton.Menu = mainMenu;

            //call setup function for all available menues
            setupMainMenu();
            setupSecondaryMenu();
            setupCenterMenu();
            setupParameterMenu();
        }