コード例 #1
0
    void ResourceListener(AssetPtr ptr)
    {
        if (ptr == null || ptr.Data == null)
        {
            return;
        }

        if (!ptr.Data.url.Contains(mCurnAnimatorame))
        {
            return;
        }

        GameObject         cameraanimator = new GameObject(mCurnAnimatorame);
        CameraPath         cPath          = cameraanimator.AddComponent <CameraPath>();
        CameraPathAnimator animator       = cameraanimator.AddComponent <CameraPathAnimator>();
        XmlDocument        xml            = new XmlDocument();

        xml.LoadXml(ptr.Data.text);
        cPath.FromXML(xml);
        if (Camera.main != null)
        {
            animator.animationObject = Camera.main.transform;
        }


        BaseScene scene = SceneManager.Instance.GetCurScene();

        if (scene != null)
        {
            animator.AnimationCustomEvent   += scene.GetCameraPathManager().OnCustomEvent;
            animator.AnimationFinishedEvent += animator_AnimationFinishedEvent;
        }
        FollowAnimator = animator;
        animator.Play();
    }
コード例 #2
0
    private void UpdateCalculations()
    {
        animators = FindObjectsOfType <CameraPathAnimator>();
        int numberOfPaths = animators.Length;

        pathTimes = new float[numberOfPaths];
//        percentages = new Dictionary<int, float[]>();
        for (int p = 0; p < numberOfPaths; p++)
        {
            CameraPathAnimator animator = animators[p];
            CameraPath         path     = animator.cameraPath;
            float pathStoredResoltion   = path.storedPointResolution;
            int   storedPointsSize      = path.storedValueArraySize;
            float pathTime = 0;
            for (int i = 0; i < storedPointsSize; i++)
            {
                float pathSpeed = animator.pathSpeed;
                if (path.speedList.listEnabled)
                {
                    float perc = pathStoredResoltion * i;
                    pathSpeed = path.GetPathSpeed(perc);
                }
                pathTime += pathStoredResoltion / pathSpeed;
            }
            pathTimes[p] = pathTime;


//            percentages.Add();
        }
    }
コード例 #3
0
    private void SetTransform(Transform transform, CameraPathAnimator animator)
    {
        CameraPath path = animator.cameraPath;

        transform.position = path.GetPathPosition(editorPercentage);
        transform.rotation = animator.GetAnimatedOrientation(editorPercentage, false);
    }
コード例 #4
0
//    private float _previewCamFov;

    private void OnEnable()
    {
        _animator     = (CameraPathAnimator)target;
        _cameraPath   = _animator.GetComponent <CameraPath>();
        _colouredText = new GUIStyle();
        _colouredText.normal.textColor = _cameraPath.textColour;
    }
コード例 #5
0
    public static void ImportCameraPath()
    {
        string filefolder = PlayerPrefs.GetString("camerapath");

        if (!Directory.Exists(filefolder))
        {
            return;
        }

        string path = EditorUtility.OpenFilePanel("打开摄像机文件", filefolder, "xml");

        string filename = Path.GetFileNameWithoutExtension(path);

        string[] arr = filename.Split(new string[] { "_^_^_" }, StringSplitOptions.None);
        if (arr.Length != 2)
        {
            EditorUtility.DisplayDialog("提示", "打开文件错误", "确定");
            return;
        }

        GameObject newCameraPath = new GameObject(arr[1]);

        Undo.RegisterCreatedObjectUndo(newCameraPath, "Import Camera Path");
        CameraPath         cPath    = newCameraPath.AddComponent <CameraPath>();
        CameraPathAnimator animator = newCameraPath.AddComponent <CameraPathAnimator>();

        cPath.FromXML(path);
        if (Camera.main != null)
        {
            animator.animationObject = Camera.main.transform;
        }
        Selection.objects = new Object[] { newCameraPath };
        SceneView.lastActiveSceneView.FrameSelected();
        EditorUtility.SetDirty(newCameraPath);
    }
コード例 #6
0
    public void SetControlCamera(GameObject camera, CameraPathAnimator animator)
    {
        mFollowPath = null;
        if (animator != null)
        {
            mFollowPath = animator.cameraPath;
        }

        mCameraObj = camera;

        mCameraTest = mCameraObj.GetComponent <CameraTest>();
        if (mCameraTest == null)
        {
            mCameraTest = mCameraObj.AddComponent <CameraTest>();
        }
        mCamera          = mCameraObj.GetComponent <Camera>();
        mCameraTransform = mCameraObj.transform;
        mCameraObj.GetComponent <AudioListener>().enabled = false;
        int layer2DUI    = LayerMask.NameToLayer("2D UI");
        int layer3DUI    = LayerMask.NameToLayer("3D UI");
        int layerPreview = LayerMask.NameToLayer("UIPreview");

        int layerMask = (1 << layer2DUI) | (1 << layer3DUI) | (1 << layerPreview);

        int oldCullingMask = mCamera.cullingMask;

        mCamera.cullingMask = oldCullingMask & (~layerMask);
    }
コード例 #7
0
 public void Clear()
 {
     mAnimatorPath    = null;
     mFollowPath      = null;
     LockCamera       = false;
     mCurnAnimatorame = null;
 }
コード例 #8
0
    public static void AlignPathPoint()
    {
        GameObject         selected = Selection.activeGameObject;
        CameraPath         camPath  = selected.GetComponent <CameraPath>();
        CameraPathAnimator animator = selected.GetComponent <CameraPathAnimator>();

        Undo.RecordObject(camPath, "Align Camera Path Point to View");
        if (camPath != null && animator != null)
        {
            switch (animator.orientationMode)
            {
            case CameraPathAnimator.orientationModes.custom:
                if (camPath.pointMode == CameraPath.PointModes.Orientations)
                {
                    int selectedPoint           = camPath.selectedPoint;
                    CameraPathOrientation point = camPath.orientationList[selectedPoint];
                    Camera     sceneCam         = SceneView.GetAllSceneCameras()[0];
                    Quaternion lookRotation     = Quaternion.LookRotation(sceneCam.transform.forward);
                    point.rotation = lookRotation;
                    if (point.positionModes == CameraPathPoint.PositionModes.FixedToPoint)
                    {
                        CameraPathControlPoint cPoint = point.point;
                        cPoint.worldPosition = sceneCam.transform.position;
                    }

                    camPath.RecalculateStoredValues();
                }

                if (camPath.pointMode == CameraPath.PointModes.Transform || camPath.pointMode == CameraPath.PointModes.ControlPoints)
                {
                    int selectedPoint             = camPath.selectedPoint;
                    CameraPathControlPoint cPoint = camPath[selectedPoint];
                    Camera sceneCam = SceneView.GetAllSceneCameras()[0];
                    cPoint.worldPosition = sceneCam.transform.position;
                    CameraPathOrientation point = (CameraPathOrientation)camPath.orientationList.GetPoint(cPoint);
                    if (point != null)
                    {
                        Quaternion lookRotation = Quaternion.LookRotation(sceneCam.transform.forward);
                        point.rotation = lookRotation;
                    }
                    camPath.RecalculateStoredValues();
                }
                break;

            default:
                if (camPath.pointMode == CameraPath.PointModes.Transform || camPath.pointMode == CameraPath.PointModes.ControlPoints)
                {
                    int selectedPoint            = camPath.selectedPoint;
                    CameraPathControlPoint point = camPath[selectedPoint];
                    Camera sceneCam         = SceneView.GetAllSceneCameras()[0];
                    float  forwardArcLength = camPath.StoredArcLength(selectedPoint);
                    point.forwardControlPointLocal = sceneCam.transform.forward * (Mathf.Max(forwardArcLength, 0.1f) * 0.33f);
                    point.worldPosition            = sceneCam.transform.position;
                    camPath.RecalculateStoredValues();
                }
                break;
            }
        }
    }
コード例 #9
0
 public void AddPath(string name, CameraPathAnimator path)
 {
     if (mCameraPaths.ContainsKey(name))
     {
         return;
     }
     mCameraPaths.Add(name, path);
 }
コード例 #10
0
    IEnumerator ToHide(CameraPathAnimator cpa, GameObject boat)
    {
        yield return(new WaitForSeconds(20));

        cpa.Stop();
        GameObject.Destroy(boat);
        GameObject.Destroy(cpa.gameObject);
    }
コード例 #11
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);
        }
    }
コード例 #12
0
 private void Start()
 {
     animator          = path.GetComponent <CameraPathAnimator>();
     fpsCamera         = playerFPSController.GetComponentInChildren <Camera>();
     fpsCamera.enabled = false;
     playerModel.SetActive(true);
     Invoke("SetValuesOnFPSControllerSettled", 1.0f);
     path.orientationList[path.realNumberOfPoints - 1].rotation = fpsCamera.transform.rotation;
     playerFPSController.GetComponent <CPEMouseLook>().enabled  = false;
 }
コード例 #13
0
    private void SceneLoadeComplete()
    {
        GameObject obj = GameObject.Find("CameraPath");

        if (obj == null)
        {
            return;
        }
        cameraPath = obj.GetComponent <CameraPathAnimator>();
    }
コード例 #14
0
    //=====================================================

    private void OnPostCutsceneFadeOutCompleteEvent()
    {
        ScreenManager.FadeOutCompleteEvent -= OnPostCutsceneFadeOutCompleteEvent;

        _isFadeCompelete = true;

        // Stop and clear cameraPathAnimator reference
        if (_cameraPathAnimator)
        {
            _cameraPathAnimator.Stop();
            _cameraPathAnimator = null;
        }

        // Returning to same scene - fade-in
        if (_currentCutscene == eCutsceneType.CRAWL_DOOR ||
            _currentCutscene == eCutsceneType.OBLIVION_PORTAL ||
            _currentCutscene == eCutsceneType.SWITCH_OPENS_DOOR_BOLT_01 ||
            _currentCutscene == eCutsceneType.SWITCH_OPENS_DOOR_BOLT_02 ||
            _currentCutscene == eCutsceneType.SWITCH_OPENS_DOOR_BOLT_03 ||
            _currentCutscene == eCutsceneType.SWITCH_OPENS_DOOR ||
            _currentCutscene == eCutsceneType.SWITCH_ACTIVATES_PLATFORM ||
            _currentCutscene == eCutsceneType.OPEN_CHEST ||
            _currentCutscene == eCutsceneType.DEATH_RESPAWN ||
            _currentCutscene == eCutsceneType.FLY_THRU ||
            _currentCutscene == eCutsceneType.BOSS_ROOM_START)
        {
            // Switch cameras
            _camera.GetComponent <AudioListener>().enabled = false;
            _camera.enabled = false;
            _mainCamera.GetComponent <AudioListener>().enabled = true;
            _mainCamera.enabled = true;
            _mainCamera.transform.FindChild("CameraInGameGui").GetComponent <Camera>().enabled = true;
            _mainCamera.GetComponent <CameraMovement>().InitWithPlayer(false);

            // Fade in - include short pause if necessary for fairy aniamtions
            var delay = (_currentCutscene == eCutsceneType.CRAWL_DOOR ||
                         _currentCutscene == eCutsceneType.OBLIVION_PORTAL) ? 0.3f : 0.0f;
            StartCoroutine(DelayPostCutsceneFadeIn(delay));
        }

        // Reset for next cutscene
        _currentCutscene = eCutsceneType.NULL;
        _cutsceneObject  = null;

        if (CutsceneCompleteEvent != null)
        {
            CutsceneCompleteEvent();
        }

        // Un-block player input
        if (InputManager.Instance != null)
        {
            InputManager.Instance.OnBlockInput(false);
        }
    }
コード例 #15
0
    private void RenderPreviews()
    {
        int        numberOfPaths = animators.Length;
        GameObject previewGO     = new GameObject();

        previewGO.hideFlags = HideFlags.HideAndDontSave;
        Camera previewCam = previewGO.AddComponent <Camera>();

        previewCam.orthographic = Camera.main.orthographic;
        GUILayout.BeginHorizontal();
        for (int p = 0; p < numberOfPaths; p++)
        {
            CameraPathAnimator animator = animators[p];
            CameraPath         path     = animator.cameraPath;

            if (path.realNumberOfPoints < 2 || !animator.showPreview)
            {
                continue;
            }

            if (CameraPathPreviewSupport.previewSupported && !EditorApplication.isPlaying)
            {
                RenderTexture rt = RenderTexture.GetTemporary(previewResolution, Mathf.RoundToInt(previewResolution / aspect), 24, RenderTextureFormat.Default, RenderTextureReadWrite.Default, 1);

                if (previewCam.orthographic)
                {
                    previewCam.orthographicSize = path.GetPathOrthographicSize(animator.editorPercentage);
                }
                else
                {
                    previewCam.fieldOfView = path.GetPathFOV(animator.editorPercentage);
                }

                SetTransform(previewCam.transform, animator);
                previewCam.enabled       = true;
                previewCam.targetTexture = rt;
                previewCam.Render();
                previewCam.targetTexture = null;
                previewCam.enabled       = false;

                GUILayout.BeginVertical();
                GUILayout.Label(animator.name);
                GUILayout.Label(rt, GUILayout.Width(200), GUILayout.Height(150));
                GUILayout.EndVertical();
                RenderTexture.ReleaseTemporary(rt);
            }
            else
            {
                string errorMsg = CameraPathPreviewSupport.previewSupportedText;
                EditorGUILayout.LabelField(errorMsg);
            }
        }
        GUILayout.EndHorizontal();
        DestroyImmediate(previewGO);
    }
コード例 #16
0
 private void PlayNextAnimation()
 {
     if (this._cameraPath.nextPath != null)
     {
         CameraPathAnimator component = this._cameraPath.nextPath.GetComponent <CameraPathAnimator>();
         float value = (!this._cameraPath.interpolateNextPath) ? 0f : (this._percentage % 1f);
         component.Seek(value);
         component.Play();
         this.Stop();
     }
 }
コード例 #17
0
//    private void OnValidate()
//    {
//        UpdateCalculations();
//    }

    private void OnGUI()
    {
        int numberOfPaths = animators.Length;

        for (int p = 0; p < numberOfPaths; p++)
        {
            CameraPathAnimator animator = animators[p];

            if (animator == null)
            {
                return;
            }

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField(animator.name, GUILayout.Width(160));
            EditorGUILayout.LabelField("Path Time", GUILayout.Width(60));
            EditorGUILayout.LabelField(pathTimes[p].ToString("F1") + " secs", GUILayout.Width(70));

            if (GUILayout.Button("Goto Animation Target", GUILayout.Width(150)))
            {
                GotoScenePoint(animator.animationObject.position);
            }

            animator.showPreview = EditorGUILayout.Toggle("Show Preview", animator.showPreview);

            animator.editorPercentage = editorPercentage;

            if (animateInEditor)
            {
                SetTransform(animator.animationObject, animator);
            }

            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.BeginHorizontal();
        animateInEditor = EditorGUILayout.Toggle("Animate Targets in Editor", animateInEditor);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        float inputPercent  = editorPercentage * 100;
        float outputPercent = EditorGUILayout.Slider(inputPercent, 0, 100) * 0.01f;

        editorPercentage = outputPercent;
        EditorGUILayout.LabelField("%", GUILayout.Width(20));
        EditorGUILayout.EndHorizontal();

        RenderPreviews();

        if (GUI.changed)
        {
            UpdateCalculations();
        }
    }
コード例 #18
0
    //PRIVATE METHODS

    protected virtual void PlayNextAnimation()
    {
        if (_cameraPath.nextPath != null)
        {
            CameraPathAnimator _animator = _cameraPath.nextPath.GetComponent <CameraPathAnimator>();
            float nextPercent            = _cameraPath.interpolateNextPath ? _percentage % 1 : 0;
            _animator.Seek(nextPercent);
            _animator.Play();
            Stop();
        }
    }
コード例 #19
0
    void Awake()
    {
        if (pathAnimatorA == null)
        {
            return;
        }

        pathAnimator = pathAnimatorA;

        pathAnimatorA.playOnStart = true;
        pathAnimatorB.playOnStart = false;
    }
コード例 #20
0
ファイル: LuaPathCamera.cs プロジェクト: cedar-x/unilua_story
 public override void Init()
 {
     _cameraPath = gameObject.GetComponent<CameraPath>();
     if (_cameraPath == null)
         _cameraPath = gameObject.AddComponent<CameraPath>();
     _cameraAnimator = gameObject.GetComponent<CameraPathAnimator>();
     if (_cameraAnimator == null)
     {
         _cameraAnimator = gameObject.AddComponent<CameraPathAnimator>();
         _cameraAnimator.playOnStart = false;
     }
 }
コード例 #21
0
    private void OnEnable()
    {
        if(target != null)
        {
            _cameraPath = (CameraPath)target;
            _animator = _cameraPath.GetComponent<CameraPathAnimator>();
        }

        CameraPathEditorSceneGUI._cameraPath = _cameraPath;
        CameraPathEditorSceneGUI._animator = _animator;

        CameraPathEditorInspectorGUI._cameraPath = _cameraPath;
        CameraPathEditorInspectorGUI._animator = _animator;
        CameraPathEditorInspectorGUI.Setup();
    }
コード例 #22
0
    private void OnEnable()
    {
        if (target != null)
        {
            _cameraPath = (CameraPath)target;
            _animator   = _cameraPath.GetComponent <CameraPathAnimator>();
        }

        CameraPathEditorSceneGUI._cameraPath = _cameraPath;
        CameraPathEditorSceneGUI._animator   = _animator;

        CameraPathEditorInspectorGUI._cameraPath = _cameraPath;
        CameraPathEditorInspectorGUI._animator   = _animator;
        CameraPathEditorInspectorGUI.Setup();
    }
コード例 #23
0
    public static void CreateNewCameraPath()
    {
        GameObject newCameraPath = new GameObject("New Camera Path");

        Undo.RegisterCreatedObjectUndo(newCameraPath, "Created New Camera Path");
        newCameraPath.AddComponent <CameraPath>();
        CameraPathAnimator animator = newCameraPath.AddComponent <CameraPathAnimator>();

        if (Camera.main != null)
        {
            animator.animationObject = Camera.main.transform;
        }
        Selection.objects = new Object[] { newCameraPath };
        SceneView.lastActiveSceneView.FrameSelected();
//        EditorUtility.SetDirty(newCameraPath);
    }
コード例 #24
0
ファイル: ICameraOperate.cs プロジェクト: 737871854/FireMen2
    public void UpdateFixedFrame()
    {
        if (mMainCamera == null || mParcent == null)
        {
            return;
        }

        if (ioo.gameMode.State == E_GameState.Summary)
        {
            if (mCpa != null)
            {
                mCpa.AnimationCustomEvent -= OnCustomEvent;
                mCpa = null;
            }
        }
    }
コード例 #25
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);
    }
コード例 #26
0
    //=====================================================

    #region Private Methods

    void Awake()
    {
        Instance = this;
        _camera  = this.transform.GetComponentInChildren <Camera>();

        _currentCutscene       = eCutsceneType.NULL;
        _cutsceneObject        = null;
        _cutsceneTimer         = 0.0f;
        _cameraPath            = null;
        _isCameraFollowingPath = false;
        _cameraPathAnimator    = null;
        _isFadeCompelete       = false;
        _isPaused               = false;
        _durationStartToEnd     = 0.0f;
        _tweenId                = -1;
        _checkForCancelCutscene = false;
    }
コード例 #27
0
    private void OnEnable()
    {
        if (target != null)
        {
            _cameraPath = (CameraPath)target;
            _animator   = _cameraPath.GetComponent <CameraPathAnimator>();
        }

        CameraPathEditorSceneGUI._cameraPath  = _cameraPath;
        CameraPathEditorSceneGUI._animator    = _animator;
        CameraPathEditorSceneGUI.colouredText = new GUIStyle();
        CameraPathEditorSceneGUI.colouredText.normal.textColor = _cameraPath.textColour;

        CameraPathEditorInspectorGUI._cameraPath = _cameraPath;
        CameraPathEditorInspectorGUI._animator   = _animator;
        CameraPathEditorInspectorGUI.Setup();
    }
コード例 #28
0
    private void RenderPreviews()
    {
        int        numberOfPaths = animators.Length;
        GameObject previewGO     = new GameObject();

        previewGO.hideFlags = HideFlags.HideAndDontSave;
        Camera previewCam = previewGO.AddComponent <Camera>();

        GUILayout.BeginHorizontal();
        for (int p = 0; p < numberOfPaths; p++)
        {
            CameraPathAnimator animator = animators[p];
            CameraPath         path     = animator.cameraPath;

            if (path.realNumberOfPoints < 2 || !animator.showPreview)
            {
                continue;
            }

            if (SystemInfo.supportsRenderTextures && !EditorApplication.isPlaying)
            {
                RenderTexture rt = RenderTexture.GetTemporary(previewResolution, Mathf.RoundToInt(previewResolution / aspect), 24, RenderTextureFormat.RGB565, RenderTextureReadWrite.Default, 1);

                SetTransform(previewCam.transform, animator);
                previewCam.enabled       = true;
                previewCam.targetTexture = rt;
                previewCam.Render();
                previewCam.targetTexture = null;
                previewCam.enabled       = false;

                GUILayout.BeginVertical();
                GUILayout.Label(animator.name);
                GUILayout.Label(rt, GUILayout.Width(200), GUILayout.Height(150));
                GUILayout.EndVertical();
                RenderTexture.ReleaseTemporary(rt);
            }
            else
            {
                bool   canPreview = Application.HasProLicense() && SystemInfo.supportsRenderTextures;
                string errorMsg   = (!canPreview) ? "Preview is an Unity Pro Feature, sorry." : "No Preview When Playing.";
                EditorGUILayout.LabelField(errorMsg);
            }
        }
        GUILayout.EndHorizontal();
        DestroyImmediate(previewGO);
    }
コード例 #29
0
        /// <summary>
        /// 动态初始化
        /// </summary>
        /// <param name="data">英雄阵型序列化数据</param>
        /// <param name="XmlName">Xml地址</param>
        /// <param name="type">英雄阵型</param>
        /// <param name="speed">初始移动速度</param>
        public void Init(HeroPathDataObj data, HeroFormationType type, string PathXml)
        {
            //添加轨迹组件 动画组件 读取轨迹数据
            HeroPathdata = data;
            HeroPath     = this.gameObject.AddComponent <CameraPath>();
            HeroPathAnim = this.gameObject.AddComponent <CameraPathAnimator>();
            HeroPath.FromXML(PathXml);
            HeroPath.hermiteTension = data.Tension;
            //初始话战斗中心点和英雄中心点
            FightCenter = new GameObject("FightCenter");
            FightCenter.transform.parent   = this.transform;
            FightCenter.transform.position = data.InitPos;
            HerosCenter = new GameObject("HerosCenter");
            HerosCenter.transform.parent   = this.transform;
            HerosCenter.transform.position = data.InitPos;
            //初始化战斗摄像机 整队摄像机
            FightFollowCam = new GameObject("FightFollowCam");
            FightFollowCam.transform.parent        = FightCenter.transform;
            FightFollowCam.transform.localPosition = data.FightFollowCamPos;
            FightDefaultCam = new GameObject("FightDefaultCam");
            FightDefaultCam.transform.SetParent(FightCenter.transform);
            FightDefaultCam.transform.localPosition = data.FightDefaultCamPos;
            LineUpFollowCam = new GameObject("LineUpFollowCam");
            LineUpFollowCam.transform.parent        = HerosCenter.transform;
            LineUpFollowCam.transform.localPosition = data.LineUpFollowCamPos;
            //初始化队伍阵型
            GameObject objType = AssetLoader.Inst.GetAssetRes(type.ToString());

            FormationCenterObj = Instantiate(objType, data.InitPos, data.InitAngles) as GameObject;
            HeroFormationtype  = type;
            // FormationCenterObj.transform.parent = this.transform;
            FormationList = new List <GameObject>();
            for (int i = 0; i < FormationCenterObj.transform.childCount; i++)
            {
                FormationList.Add(FormationCenterObj.transform.GetChild(i).gameObject);
                //Debug.Log(FormationCenterObj.transform.GetChild(i).position);
            }
            FormationDic = new Dictionary <ObjectCreature, GameObject>();
            //初始化轨迹组件信息
            HeroPathAnim.animationObject = FormationCenterObj.transform;
            HeroPathAnim.pathSpeed       = 0;
            Heropathtype = HeroPathMoveType.Null;
            HeroPathPause();
            SetHeroPathIdle();
        }
コード例 #30
0
    public void startCamera()
    {
        cameras [index].gameObject.SetActive(true);
        // enable touch in vr
        //Cardboard.SDK.TapIsTrigger = false;
        CameraPathAnimator cpa = camerapath.GetComponent <CameraPathAnimator> ();

        cpa.animationObject = cameras [index];
        cpa.Seek(startPositions[index]);
        cpa.Play();

        // switch on vr, switch off canvas
        //Cardboard.SDK.TapIsTrigger = true;
        gameObject.SetActive(false);

        //initialize rest
        initializeGameObject();
    }
コード例 #31
0
 //本地初始化
 private void init()
 {
     HeroPathAnim = this.transform.FindChild("HerosPath").GetComponent <CameraPathAnimator>();
     HeroPath     = this.transform.FindChild("HerosPath").GetComponent <CameraPath>();
     //HeroPath.FromXML("Assets/CameraPath3/HerosPath.xml");
     FightCenter        = this.transform.FindChild("FightCenter").gameObject;
     HerosCenter        = this.transform.FindChild("HerosCenter").gameObject;
     FormationCenterObj = this.transform.FindChild("FormationCenter").gameObject;
     FormationList      = new List <GameObject>();
     for (int i = 0; i < FormationCenterObj.transform.childCount; i++)
     {
         FormationList.Add(FormationCenterObj.transform.GetChild(i).gameObject);
     }
     Heropathtype                 = HeroPathMoveType.Null;
     HeroFormationtype            = HeroFormationType.Formation133;
     HeroPathAnim.animationObject = FormationCenterObj.transform;
     HeroPathAnim.pathSpeed       = MoveSpeed = this.GetComponent <HeroPathData>().MoveSpeed;
     HeroPathPause();
 }
コード例 #32
0
ファイル: BattleManager.cs プロジェクト: dqchess/fire-emblem
    public void InitiateCameraPan(Camera gridCam)
    {
        gridCamera   = gridCam;
        battleCamera = GameObject.Find("Battle Camera").GetComponent <Camera>();
        gridCanvas   = GameObject.Find("Canvas").GetComponent <Canvas>();

        gridCanvas.enabled = true;
        gridCanvas.gameObject.SetActive(true);

        InstantiateBattlers();
        SetPositions();

        cameraPathAnimator = GameObject.Find("InitialCameraPan").GetComponent <CameraPathAnimator>();
        battleUI           = this.gameObject.GetComponent <BattleUI>();

        battleUI.enemy  = enemy;
        battleUI.player = player;

        cameraPathAnimator.Play();
    }
コード例 #33
0
ファイル: ICameraOperate.cs プロジェクト: 737871854/FireMen2
    public ICameraOperate(CameraManager cameraManager)
    {
        mCameraManager = cameraManager;

        mMainCamera      = Camera.main;
        mParcent         = mMainCamera.transform.parent;
        mShakeController = new ShakeController();
        mShakeController.Init(mMainCamera.transform);

        PauseMove = true;
        PauseRoll = true;

        mPercent = 0;
        GameObject obj = GameObject.FindGameObjectWithTag(GameTage.PluginCameraPath);

        if (obj != null)
        {
            mCpa = obj.GetComponent <CameraPathAnimator>();
            mCpa.AnimationCustomEvent += OnCustomEvent;
        }
    }
コード例 #34
0
 private void SetTransform(Transform transform, CameraPathAnimator animator)
 {
     CameraPath path = animator.cameraPath;
     transform.position = path.GetPathPosition(editorPercentage);
     transform.rotation = animator.GetAnimatedOrientation(editorPercentage, false);
 }