コード例 #1
0
//    private float _previewCamFov;

    private void OnEnable()
    {
        _animator     = (CameraPathAnimator)target;
        _cameraPath   = _animator.GetComponent <CameraPath>();
        _colouredText = new GUIStyle();
        _colouredText.normal.textColor = _cameraPath.textColour;
    }
コード例 #2
0
    private void OnEnable()
    {
        _animator   = (CameraPathAnimator)target;
        _cameraPath = _animator.GetComponent <CameraPath>();

        //Preview Camera
        if (_animator.editorPreview != null)
        {
            DestroyImmediate(_animator.editorPreview);
        }
        if (CameraPathPreviewSupport.previewSupported)
        {
            _animator.editorPreview           = new GameObject("Animtation Preview Cam");
            _animator.editorPreview.hideFlags = HideFlags.HideAndDontSave;
            _animator.editorPreview.AddComponent <Camera>();
            _animator.editorPreview.GetComponent <Camera>().fieldOfView = 60;
            _animator.editorPreview.GetComponent <Camera>().depth       = -1;
            //Retreive camera settings from the main camera
            Camera[] cams              = Camera.allCameras;
            bool     sceneHasCamera    = cams.Length > 0;
            Camera   sceneCamera       = null;
            Skybox   sceneCameraSkybox = null;
            if (Camera.main)
            {
                sceneCamera = Camera.main;
            }
            else if (sceneHasCamera)
            {
                sceneCamera = cams[0];
            }

            if (sceneCamera != null)
            {
                sceneCameraSkybox = sceneCamera.GetComponent <Skybox>();
            }
            if (sceneCamera != null)
            {
                _animator.editorPreview.GetComponent <Camera>().backgroundColor = sceneCamera.backgroundColor;
                if (sceneCameraSkybox != null)
                {
                    _animator.editorPreview.AddComponent <Skybox>().material = sceneCameraSkybox.material;
                }
                else if (RenderSettings.skybox != null)
                {
                    _animator.editorPreview.AddComponent <Skybox>().material = RenderSettings.skybox;
                }

                _animator.editorPreview.GetComponent <Camera>().orthographic = sceneCamera.orthographic;
            }
            _animator.editorPreview.GetComponent <Camera>().enabled = false;
        }

        if (EditorApplication.isPlaying && _animator.editorPreview != null)
        {
            _animator.editorPreview.SetActive(false);
        }
    }
コード例 #3
0
    private void OnEnable()
    {
        _animator = (CameraPathAnimator)target;
        _cameraPath = _animator.GetComponent<CameraPath>();

        //Preview Camera
        if(_animator.editorPreview != null)
            DestroyImmediate(_animator.editorPreview);
        if (CameraPathPreviewSupport.previewSupported)
        {
            _animator.editorPreview = new GameObject("Animtation Preview Cam");
            _animator.editorPreview.hideFlags = HideFlags.HideAndDontSave;
            _animator.editorPreview.AddComponent<Camera>();
            _animator.editorPreview.GetComponent<Camera>().fieldOfView = 60;
            _animator.editorPreview.GetComponent<Camera>().depth = -1;
            //Retreive camera settings from the main camera
            Camera[] cams = Camera.allCameras;
            bool sceneHasCamera = cams.Length > 0;
            Camera sceneCamera = null;
            Skybox sceneCameraSkybox = null;
            if(Camera.main)
            {
                sceneCamera = Camera.main;
            }
            else if(sceneHasCamera)
            {
                sceneCamera = cams[0];
            }

            if(sceneCamera != null)
                sceneCameraSkybox = sceneCamera.GetComponent<Skybox>();
            if(sceneCamera != null)
            {
                _animator.editorPreview.GetComponent<Camera>().backgroundColor = sceneCamera.backgroundColor;
                if(sceneCameraSkybox != null)
                    _animator.editorPreview.AddComponent<Skybox>().material = sceneCameraSkybox.material;
                else if(RenderSettings.skybox != null)
                    _animator.editorPreview.AddComponent<Skybox>().material = RenderSettings.skybox;

                _animator.editorPreview.GetComponent<Camera>().orthographic = sceneCamera.orthographic;
            }
            _animator.editorPreview.GetComponent<Camera>().enabled = false;
        }

        if(EditorApplication.isPlaying && _animator.editorPreview != null)
            _animator.editorPreview.SetActive(false);
    }