コード例 #1
0
ファイル: CameraControler.cs プロジェクト: sktsky/dzhart
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            //获取组件
            CameraControler sTarget = (CameraControler)target;

            //数据不为空
            if (sTarget.sObj != null)
            {
                editor = CreateEditor(sTarget.sObj);
                //editor.DrawDefaultInspector();
                editor.OnInspectorGUI();

                //sObj.SetInOutAll();//刷新所有值
            }
            else
            {
                editor = null;
                //新建按钮
                if (GUILayout.Button("New"))
                {
                    //文件夹路径
                    string assetPath = "Assets/SunRise720/Preset/CameraPosition/";
                    if (!Directory.Exists(assetPath))
                    {
                        Directory.CreateDirectory(assetPath);
                    }
                    //文件路径
                    string   assetName = "Cam";
                    string   path      = Path.Combine(assetPath, assetName + ".asset");
                    FileInfo fileInfo  = new FileInfo(path);
                    //文件同名
                    if (fileInfo.Exists)
                    {
                        assetName += ("_" + Sun.Rise.GetGUIDLast());
                        path       = Path.Combine(assetPath, assetName + ".asset");
                    }

                    CameraTargetScriptableObject newAsset = CreateInstance <CameraTargetScriptableObject>();
                    AssetDatabase.CreateAsset(newAsset, path);
                    sTarget.sObj = newAsset;
                }
            }
        }
コード例 #2
0
ファイル: CameraControler.cs プロジェクト: sktsky/dzhart
    public void MoveToTarg(CameraTargetScriptableObject tagSobj)
    {
        //值初始化 赋值
        isDoTweenOk              = false;
        sObj                     = tagSobj;//赋值
        angleDistance            = tagSobj.lookAngleDistance;
        lookTargetPosition       = tagSobj.lookTargetPosition;
        sCapsuleCollider.enabled = false;//先关闭碰撞

        DOTween.Kill("ToCameraRotationY");
        DOTween.To(() => transform.localRotation, x => transform.localRotation = x, new Vector3(0, tagSobj.lookAngleDistance.y, 0), tagSobj.fovTweenLate.y).SetId("ToCameraRotationY").SetAutoKill(true).SetEase(ease);
        DOTween.Kill("ToCameraRotationX");
        DOTween.To(() => sCamera.transform.localRotation, x => sCamera.transform.localRotation = x, new Vector3(tagSobj.lookAngleDistance.x, 0, 0), tagSobj.fovTweenLate.y).SetId("ToCameraRotationX").SetAutoKill(true).SetEase(ease);
        DOTween.Kill("ToCameraPosition");
        DOTween.To(() => transform.position, x => transform.position = x, tagSobj.sPosition, tagSobj.fovTweenLate.y).SetId("ToCameraPosition").SetEase(ease).SetAutoKill(true)
        .OnComplete((() =>
        {
            //人视穿行模式--------------------------------------------------------------------------
            if (tagSobj.camMode == CameraTargetScriptableObject.CameraMode.人视穿行)
            {
                sRigidBody.useGravity = true;    //打开重力
                sRigidBody.isKinematic = false;  //关闭自定义动画模式
                sCapsuleCollider.enabled = true; //打开碰撞
            }
            else
            {
                sRigidBody.useGravity = false;
                sRigidBody.isKinematic = true;
                sCapsuleCollider.enabled = false;
            }

            //VR模式--------------------------------------------------------------------------------
            if (tagSobj.camMode == CameraTargetScriptableObject.CameraMode.HTC头盔)
            {
                StartCoroutine(LoadDevice("OpenVR"));
            }
            else
            {
                StartCoroutine(LoadDevice("None"));
            }


            //路径动画模式--------------------------------------------------------------------------------
            if (tagSobj.camMode == CameraTargetScriptableObject.CameraMode.路径动画)
            {
                pathAnimation = 0f;
            }

            isDoTweenOk = true;
        }));


        if (UIDay2Night.Instance)
        {
            //改变时间
            if (tagSobj.dayAutoWeather.x > 0)
            {
                UIDay2Night.Instance.SetDayTime(tagSobj.dayAutoWeather.x, tagSobj.fovTweenLate.y);
            }
            //自动变化时间
            if (tagSobj.dayAutoWeather.y > 0)
            {
                UIDay2Night.Instance.AutoSlider(tagSobj.dayAutoWeather.y);
            }
            else
            {
                UIDay2Night.Instance.StopAutoSlider();
            }
            //改变天气
            //if (tagSobj.dayAutoWeather.z != 0)
            //{
            //    UIDay2Night.Instance.weatherToggle.TurnOn();
            //    Day2NightManager.Instance.ChangeWeatherIndex(1);
            //}
            //else
            //{
            //    UIDay2Night.Instance.weatherToggle.TurnOff();
            //    Day2NightManager.Instance.ChangeWeatherIndex(0);
            //}
        }

        //关闭云
        if (tagSobj.overCloudSetting.x == 1)
        {
            sCamera.GetComponent <OverCloudCamera>().renderVolumetricClouds = true;
        }
        else
        {
            sCamera.GetComponent <OverCloudCamera>().renderVolumetricClouds = false;
        }
        //关闭雾
        if (tagSobj.overCloudSetting.y == 1)
        {
            sCamera.GetComponent <OverCloudCamera>().renderAtmosphere = true;
        }
        else
        {
            sCamera.GetComponent <OverCloudCamera>().renderAtmosphere = false;
        }



        //改变系统阴影距离
        if (tagSobj.clippingShadow.z != -1)
        {
            DOTween.Kill("ShadowDistance");
            DOTween.To(() => QualitySettings.shadowDistance, x => QualitySettings.shadowDistance = x, tagSobj.clippingShadow.z, tagSobj.fovTweenLate.y).SetId("ShadowDistance").SetEase(ease).SetAutoKill(true);
        }
        //改变摄影机clipping  Fov
        foreach (Camera cam in cameras)
        {
            DOTween.Kill("ClippingPlanesNear" + cam.name);
            DOTween.To(() => cam.nearClipPlane, x => cam.nearClipPlane = x, tagSobj.clippingShadow.x, tagSobj.fovTweenLate.y).SetId("ClippingPlanesNear" + cam.name).SetEase(ease).SetAutoKill(true);
            DOTween.Kill("ClippingPlanesFar" + cam.name);
            DOTween.To(() => cam.farClipPlane, x => cam.farClipPlane = x, tagSobj.clippingShadow.y, tagSobj.fovTweenLate.y).SetId("ClippingPlanesFar" + cam.name).SetEase(ease).SetAutoKill(true);
            DOTween.Kill("FovCamera" + cam.name);
            DOTween.To(() => cam.fieldOfView, x => cam.fieldOfView = x, tagSobj.fovTweenLate.x, tagSobj.fovTweenLate.y).SetId("FovCamera" + cam.name).SetEase(ease).SetAutoKill(true);
        }
    }