//! //! 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(); }
//! //! 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"); } // initialize light settings widget GameObject ciLightSettingsObject = new GameObject("ciLightSettingsObject"); ciLightSettingsObject.AddComponent <RectTransform>(); ciLightSettingsObject.transform.SetParent(canvas, false); // ciLightSettingsObject.transform.localPosition = new Vector3(0, -canvasHeight/2+UI.ButtonOffset, 0); lightSettingsWidget = ciLightSettingsObject.AddComponent <LightSettingsWidget>(); //initalize main Menu GameObject mainMenuObject = new GameObject("mainMenuObject"); mainMenuObject.transform.SetParent(this.transform, 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 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"); startButton.transform.localPosition = new Vector3(0f, -670f, 0.0f); 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); #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, 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(); // initialize camera slider widget setupCameraSlider(); }