예제 #1
0
        override protected void Awake()
        {
            base.Awake();
            telloManager = transform.Find("Tello Manager").GetComponent <TelloManager>();
            autoPilot    = GetComponent <TelloAutoPilot>();

            if (!telloManager)
            {
                Debug.LogError("No Tello Manager Found");
            }

            //so we can roll/pitch tello model without the camera moving on those axis
            var trackingCamObject = transform.Find("Tracking Camera (Display 2)");

            if (trackingCamObject)
            {
                display2Cam = trackingCamObject.GetComponent <Camera>();
            }
            if (sceneType != SceneType.SimOnly)
            {
                telloManager.CustomAwake();
                if (display2Cam)
                {
                    display2Cam.transform.SetParent(telloManager.transform);
                }
            }
            else
            {
                telloManager.gameObject.SetActive(false);
            }

            inputController = FindObjectOfType <InputController>();
            if (!inputController)
            {
                Debug.LogError("Missing an input controller");
            }
            else
            {
                inputController.CustomAwake(this);
            }

            //Simulator
            simulator = FindObjectOfType <DroneSimulator>();
            if (!simulator)
            {
                Debug.Log("No tello simulator found");
            }
            if (sceneType == SceneType.FlyOnly)
            {
                if (simulator)
                {
                    simulator.gameObject.SetActive(false);
                }
                activeDrone = telloManager.gameObject.transform;
            }
            else if (sceneType == SceneType.SimOnly)
            {
                Debug.Log("Begin Sim");
                activeDrone = simulator.gameObject.transform;
                display2Cam.transform.SetParent(simulator.transform);
            }
        }