public ConfigWidget drawConfigWidget() { //if user clicks on config icon while in AR setup, accept setup (same as ok button) acceptARConfig(); mainController.deselect(); // get radial menu // get ProgressWidget GameObject radialrefObject = GameObject.Find("GUI/Canvas/ProgressWidget"); if (radialrefObject != null) { radialrefObject.gameObject.SetActive(false); } // copy values from global settings to config widget TODO: load it directly, see next line VPETSettings.mapValuesToObject(configWidget); // map values from preferences to config widget VPETSettings.mapValuesFromPreferences(configWidget); configWidget.Show(); configWidget.initConfigWidget(); UI.OnUIChanged.Invoke(); return(configWidget); }
//! //! Use this for pre initialization //! void Awake() { // read settings from inspector values VPETSettings.mapValuesFromObject(this); // read settings from config file if wanted if (!ignoreConfig) { string filePath = Application.dataPath + "/VPET/editing_tool.cfg"; if (!File.Exists(filePath)) { filePath = Application.persistentDataPath + "/editing_tool.cfg"; } VPETSettings.mapValuesFromConfigFile(filePath); } // read settings from user preferences VPETSettings.mapValuesFromPreferences(); // check if scene dump file available if (Directory.Exists(Application.dataPath + "/Resources/VPET/SceneDumps")) { VPETSettings.Instance.sceneDumpFolderEmpty = (Directory.GetFiles(Application.dataPath + "/Resources/VPET/SceneDumps", "*.bytes").Length == 0); // print("PETSettings.Instance.sceneDumpFolderEmpty " + VPETSettings.Instance.sceneDumpFolderEmpty); } VPETSettings.Instance.sceneDumpFolderEmpty = false; // get all adapters and add them if missing // // get scene adapter GameObject refObject = GameObject.Find("SceneAdapter"); if (refObject == null) { Debug.LogWarning(string.Format("{0}: No SceneAdapter Object found. Create.", this.GetType())); refObject = new GameObject("SceneAdapter"); } sceneAdapter = refObject.GetComponent <SceneLoader>(); if (sceneAdapter == null) { Debug.LogWarning(string.Format("{0}: No SceneAdapter Component found. Create", this.GetType())); sceneAdapter = refObject.AddComponent <SceneLoader>(); } // get server adapter refObject = GameObject.Find("ServerAdapter"); if (refObject == null) { Debug.LogWarning(string.Format("{0}: No ServerAdapter Object found. Create.", this.GetType())); refObject = new GameObject("ServerAdapter"); } serverAdapter = refObject.GetComponent <ServerAdapter>(); if (serverAdapter == null) { Debug.LogWarning(string.Format("{0}: No ServerAdapter Component found. Create", this.GetType())); serverAdapter = refObject.AddComponent <ServerAdapter>(); } // set properties serverAdapter.SceneLoader = sceneAdapter; // get animation adapter refObject = GameObject.Find("AnimationController"); if (refObject == null) { Debug.LogWarning(string.Format("{0}: No AnimationController Object found. Create.", this.GetType())); refObject = new GameObject("AnimationAdapter"); } animationController = refObject.GetComponent <AnimationController>(); if (animationController == null) { Debug.LogWarning(string.Format("{0}: No AnimationController Component found. Create", this.GetType())); animationController = refObject.AddComponent <AnimationController>(); } // get JoystickAdapter adapter refObject = GameObject.Find("JoystickAdapter"); if (refObject == null) { Debug.LogWarning(string.Format("{0}: No JoystickAdapter Object found. Create.", this.GetType())); refObject = new GameObject("JoystickAdapter"); } joystickAdapter = refObject.GetComponent <JoystickInput>(); if (joystickAdapter == null) { Debug.LogWarning(string.Format("{0}: No JoystickAdapter Component found. Create", this.GetType())); joystickAdapter = refObject.AddComponent <JoystickInput>(); } // get InputAdapter adapter refObject = GameObject.Find("InputAdapter"); if (refObject == null) { Debug.LogWarning(string.Format("{0}: No InputAdapter Object found. Create.", this.GetType())); refObject = new GameObject("InputAdapter"); } inputAdapter = refObject.GetComponent <InputAdapter>(); if (inputAdapter == null) { Debug.LogWarning(string.Format("{0}: No InputAdapter Component found. Create", this.GetType())); inputAdapter = refObject.AddComponent <InputAdapter>(); } // inputAdapter.MainController = this; // get ui adapter refObject = GameObject.Find("GUI/Canvas/UI"); if (refObject == null) { Debug.LogWarning(string.Format("{0}: No GUI/Canvas/UI Object found. Create.", this.GetType())); refObject = new GameObject("UI"); GameObject refParent = GameObject.Find("GUI/Canvas"); refObject.transform.SetParent(refParent.transform, false); } ui = refObject.GetComponent <UI>(); if (ui == null) { Debug.LogWarning(string.Format("{0}: No UI Component found. Create", this.GetType())); ui = refObject.AddComponent <UI>(); } // get move camera component camera Adapter cameraAdapter = Camera.main.GetComponent <MoveCamera>(); if (cameraAdapter == null) { Debug.LogWarning(string.Format("{0}: No CameraAdapter Component found. Create", this.GetType())); cameraAdapter = Camera.main.gameObject.AddComponent <MoveCamera>(); } #if USE_TANGO GameObject tangoObject = GameObject.Find("Tango Manager"); if (tangoObject) { tangoApplication = tangoObject.GetComponent <Tango.TangoApplication>(); } #endif }
//! //! Use this for pre initialization //! void Awake() { QualitySettings.vSyncCount = 0; Application.targetFrameRate = 30; Resolution res = Screen.currentResolution; //Screen.SetResolution(res.width/2, res.height/2, true); // read settings from inspector values VPETSettings.mapValuesFromObject(this); // read settings from config file if wanted if (!ignoreConfig) { string filePath = Application.dataPath + "/VPET/editing_tool.cfg"; if (!File.Exists(filePath)) { filePath = Application.persistentDataPath + "/editing_tool.cfg"; } VPETSettings.mapValuesFromConfigFile(filePath); } // read settings from user preferences VPETSettings.mapValuesFromPreferences(); // check if scene dump file available if (Directory.Exists(Application.dataPath + "/Resources/VPET/SceneDumps")) { VPETSettings.Instance.sceneDumpFolderEmpty = (Directory.GetFiles(Application.dataPath + "/Resources/VPET/SceneDumps", "*.bytes").Length == 0); // print("PETSettings.Instance.sceneDumpFolderEmpty " + VPETSettings.Instance.sceneDumpFolderEmpty); } VPETSettings.Instance.sceneDumpFolderEmpty = false; // Register plugins VPETRegister.RegisterNodeParser(); VPETRegister.RegisterNodeBuilder(); VPETRegister.RegisterObjectSender(); // get all adapters and add them if missing // // get scene adapter GameObject refObject = GameObject.Find("SceneAdapter"); if (refObject == null) { Debug.LogWarning(string.Format("{0}: No SceneAdapter Object found. Create.", this.GetType())); refObject = new GameObject("SceneAdapter"); } sceneAdapter = refObject.GetComponent <SceneLoader>(); if (sceneAdapter == null) { Debug.LogWarning(string.Format("{0}: No SceneAdapter Component found. Create", this.GetType())); sceneAdapter = refObject.AddComponent <SceneLoader>(); } // get server adapter refObject = GameObject.Find("ServerAdapter"); if (refObject == null) { Debug.LogWarning(string.Format("{0}: No ServerAdapter Object found. Create.", this.GetType())); refObject = new GameObject("ServerAdapter"); } serverAdapter = refObject.GetComponent <ServerAdapter>(); if (serverAdapter == null) { Debug.LogWarning(string.Format("{0}: No ServerAdapter Component found. Create", this.GetType())); serverAdapter = refObject.AddComponent <ServerAdapter>(); } // copy cache name to settings VPETSettings.Instance.sceneFileName = serverAdapter.sceneFileName; // set properties serverAdapter.SceneLoader = sceneAdapter; // get animation adapter refObject = GameObject.Find("AnimationController"); if (refObject == null) { Debug.LogWarning(string.Format("{0}: No AnimationController Object found. Create.", this.GetType())); refObject = new GameObject("AnimationAdapter"); } animationController = refObject.GetComponent <AnimationController>(); if (animationController == null) { Debug.LogWarning(string.Format("{0}: No AnimationController Component found. Create", this.GetType())); animationController = refObject.AddComponent <AnimationController>(); } // get JoystickAdapter adapter refObject = GameObject.Find("JoystickAdapter"); if (refObject == null) { Debug.LogWarning(string.Format("{0}: No JoystickAdapter Object found. Create.", this.GetType())); refObject = new GameObject("JoystickAdapter"); } #if !SCENE_HOST joystickAdapter = refObject.GetComponent <JoystickInput>(); if (joystickAdapter == null) { Debug.LogWarning(string.Format("{0}: No JoystickAdapter Component found. Create", this.GetType())); joystickAdapter = refObject.AddComponent <JoystickInput>(); } #endif // get InputAdapter adapter refObject = GameObject.Find("InputAdapter"); if (refObject == null) { Debug.LogWarning(string.Format("{0}: No InputAdapter Object found. Create.", this.GetType())); refObject = new GameObject("InputAdapter"); } inputAdapter = refObject.GetComponent <InputAdapter>(); if (inputAdapter == null) { Debug.LogWarning(string.Format("{0}: No InputAdapter Component found. Create", this.GetType())); inputAdapter = refObject.AddComponent <InputAdapter>(); } // inputAdapter.MainController = this; // get ui adapter refObject = GameObject.Find("GUI/Canvas/UI"); if (refObject == null) { Debug.LogWarning(string.Format("{0}: No GUI/Canvas/UI Object found. Create.", this.GetType())); refObject = new GameObject("UI"); GameObject refParent = GameObject.Find("GUI/Canvas"); refObject.transform.SetParent(refParent.transform, false); } ui = refObject.GetComponent <UI>(); if (ui == null) { Debug.LogWarning(string.Format("{0}: No UI Component found. Create", this.GetType())); ui = refObject.AddComponent <UI>(); } // get move camera component camera Adapter cameraAdapter = Camera.main.GetComponent <MoveCamera>(); if (cameraAdapter == null) { Debug.LogWarning(string.Format("{0}: No CameraAdapter Component found. Create", this.GetType())); cameraAdapter = Camera.main.gameObject.AddComponent <MoveCamera>(); } }