Пример #1
0
        //!
        //! Use this for initialization
        //!
        void Start()
        {
            timeleft = updateInterval;
            //initialize the sensor reading for the current platform
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
            initalizeSensorReading();
#elif (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
            // SensorHelper.ActivateRotation();
#endif
            //sync renderInFront camera to mainCamera
            Camera frontCamera = this.transform.GetChild(0).GetComponent <Camera>();
            if (frontCamera)
            {
                frontCamera.fieldOfView   = this.GetComponent <Camera>().fieldOfView;
                frontCamera.farClipPlane  = this.GetComponent <Camera>().farClipPlane;
                frontCamera.nearClipPlane = this.GetComponent <Camera>().nearClipPlane;
            }

            //sync Outline camera to mainCamera
            if (frontCamera.transform.childCount > 0)
            {
                Camera outlineCamera = frontCamera.transform.GetChild(0).GetComponent <Camera>();
                outlineCamera.fieldOfView   = this.GetComponent <Camera>().fieldOfView;
                outlineCamera.farClipPlane  = this.GetComponent <Camera>().farClipPlane;
                outlineCamera.nearClipPlane = this.GetComponent <Camera>().nearClipPlane;
            }

            scene = GameObject.Find("Scene").transform;

            // get server adapter
            GameObject refObject = GameObject.Find("ServerAdapter");
            if (refObject != null)
            {
                serverAdapter = refObject.GetComponent <ServerAdapter>();
            }
            if (serverAdapter == null)
            {
                Debug.LogError(string.Format("{0}: No ServerAdapter found.", this.GetType()));
            }

            // get joystick adapter
            refObject = GameObject.Find("JoystickAdapter");
            if (refObject != null)
            {
                joystickAdapter = refObject.GetComponent <JoystickInput>();
            }
            if (joystickAdapter == null)
            {
                Debug.LogError(string.Format("{0}: No JoystickInput found.", this.GetType()));
            }

            // get mainController
            refObject = GameObject.Find("MainController");
            if (refObject != null)
            {
                mainController = refObject.GetComponent <MainController>();
            }
            if (mainController == null)
            {
                Debug.LogError(string.Format("{0}: No MainController found.", this.GetType()));
            }

#if USE_TANGO
            trackingTransform = GameObject.Find("Tango").transform;
#elif USE_ARKIT
            trackingTransform = GameObject.Find("ARKit").transform;
#else
            Camera.main.transform.parent.transform.Rotate(Vector3.right, 90);
#endif
        }
Пример #2
0
        //!
        //! 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
        }
Пример #3
0
        //!
        //! 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>();
            }
        }