Beispiel #1
0
        private void OnEnable()
        {
            cc = (CameraManager)target;

            RefreshViewInfoProperties();

            cc.GetEffectInfo(out m_EffectInfo);
            if (m_EffectInfo == null)
            {
                m_EffectInfo = AssetDatabase.LoadAssetAtPath <CameraEffectInfo>(cc.effectProfileAssetPath);
            }
        }
Beispiel #2
0
        ///////////////////////////////////////////// 镜头切换、震屏等接口
        /// <summary>
        /// 播放震屏接口
        /// </summary>
        /// <param name="effectInfo"></param>
        /// <param name="onFinished"></param>
        public void PlayCameraEffect(CameraEffectInfo effectInfo, System.Action onFinished = null)
        {
            if (effectInfo == null)
            {
                Debug.LogWarning("PlayCameraEffect: CameraEffectProfile == none");
                return;
            }

            if (m_EffectInfo != null && m_EffectInfo.IsPlaying() && m_EffectInfo.m_Priority > effectInfo.m_Priority)
            {
                return;
            }

            StopCameraEffect();

            m_EffectInfo = effectInfo;
            m_EffectInfo.Play(onFinished);
        }
Beispiel #3
0
 public void GetEffectInfo(out CameraEffectInfo info)
 {
     info = m_EffectInfo;
 }
Beispiel #4
0
        public override void OnInspectorGUI()
        {
            //////// 编辑全局参数
            GUILayout.Space(10);
            GUILayout.Label("编辑相机参数(灵敏、平滑系数)", EGUIStyles.TitleTextStyle);

            DrawDefaultInspector();

            //////// 编辑相机位
            GUILayout.Space(30);
            EditorGUI.BeginDisabledGroup(!EditorApplication.isPlaying);
            {
                GUILayout.Label("编辑相机位参数", EGUIStyles.TitleTextStyle);


                ////// 编辑ViewTarget & CameraViewInfo
                EditorGUILayout.LabelField("资源路径:       " + m_ViewInfoAssetPath, GUILayout.ExpandWidth(true));

                EditorGUILayout.BeginHorizontal();
                {
                    cc.curCharView = (CameraViewInfoCollection.CharacterView)EditorGUILayout.EnumPopup("CharView", cc.curCharView, GUILayout.ExpandWidth(true));

                    //Color preColor = GUI.color;
                    //GUI.color = cc.m_isAiming ? Color.green : Color.red;
                    //if (GUILayout.Button("Aiming"))
                    //{
                    //    cc.m_isAiming = !cc.m_isAiming;
                    //}
                    //GUI.color = preColor;
                }
                EditorGUILayout.EndHorizontal();

                ////// GO
                EditorGUILayout.Separator();
                if (GUILayout.Button("GO", GUILayout.Height(30)))
                {
                    EditorSetCharacterView(cc.curCharView, cc.m_isAiming, 0.2f);
                }

                ////// SAVE & SAVE AS
                EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(m_ViewInfoAssetPath));
                {
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Save", GUILayout.Height(20)))
                    {
                        cc.SaveToDefault(m_ViewTarget, m_PendingViewInfo, m_SrcViewInfo);
                        AssetDatabase.Refresh();
                    }
                    //if (GUILayout.Button("Save as...", GUILayout.Width(200)))
                    //{
                    //    //string savePath = EditorUtility.SaveFilePanel("", cc.assetPath, "CameraViewInfo", "asset");
                    //    //if (!string.IsNullOrEmpty(savePath))
                    //    //{
                    //    //    savePath = savePath.Substring(Application.dataPath.Length - 6);

                    //    //    cc.SaveToDefault(m_ViewTarget, m_PendingViewInfo);
                    //    //    AssetDatabase.CreateAsset(m_PendingViewInfo, savePath);
                    //    //    AssetDatabase.Refresh();
                    //    //}
                    //}
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUI.EndDisabledGroup();

                GUILayout.Space(10);
                GUILayout.Label("当前相机位参数", EGUIStyles.Label2);
                if (m_viObject != null)
                {
                    m_viObject.Update();

                    EditorGUILayout.LabelField("rigOffset", GUILayout.ExpandWidth(false));
                    {
                        ++EditorGUI.indentLevel;
                        EditorGUILayout.DelayedFloatField(rigOffsetXProp, GUILayout.ExpandWidth(true));
                        EditorGUILayout.DelayedFloatField(rigOffsetYProp, GUILayout.ExpandWidth(true));
                        EditorGUILayout.DelayedFloatField(rigOffsetZProp, GUILayout.ExpandWidth(true));
                        --EditorGUI.indentLevel;
                    }
                    //EditorGUILayout.LabelField("rigOffsetWhenAim", GUILayout.ExpandWidth(false));
                    //{
                    //    ++EditorGUI.indentLevel;
                    //    EditorGUILayout.DelayedFloatField(rigOffsetXWhenAimProp, GUILayout.ExpandWidth(true));
                    //    EditorGUILayout.DelayedFloatField(rigOffsetYWhenAimProp, GUILayout.ExpandWidth(true));
                    //    EditorGUILayout.DelayedFloatField(rigOffsetZWhenAimProp, GUILayout.ExpandWidth(true));
                    //    --EditorGUI.indentLevel;
                    //}

                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUILayout.Slider(defaultFOVProp, 5, 90, GUILayout.ExpandWidth(true));
                    EditorGUI.EndDisabledGroup();
                    m_PendingViewInfo.fov = EditorGUILayout.Slider("fov", m_PendingViewInfo.fov, 5, 90, GUILayout.ExpandWidth(true));

                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUILayout.Slider(defaultPitchProp, minPitchProp.floatValue, maxPitchProp.floatValue, GUILayout.ExpandWidth(true));
                    EditorGUI.EndDisabledGroup();
                    m_PendingViewInfo.pitch = EditorGUILayout.Slider("pitch", m_PendingViewInfo.pitch, minPitchProp.floatValue, maxPitchProp.floatValue, GUILayout.ExpandWidth(true));
                    EditorGUILayout.Slider(minPitchProp, -80, 0, GUILayout.ExpandWidth(true));
                    EditorGUILayout.Slider(maxPitchProp, 0, 80, GUILayout.ExpandWidth(true));

                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUILayout.Slider(defaultYawProp, -180, 180, GUILayout.ExpandWidth(true));
                    EditorGUI.EndDisabledGroup();
                    m_PendingViewInfo.yaw = EditorGUILayout.Slider("yaw", m_PendingViewInfo.yaw, -180, 180, GUILayout.ExpandWidth(true));

                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUILayout.Slider(defaultDistanceProp, minDistanceProp.floatValue, maxDistanceProp.floatValue, GUILayout.ExpandWidth(true));
                    EditorGUI.EndDisabledGroup();
                    m_PendingViewInfo.distance = EditorGUILayout.Slider("distance", m_PendingViewInfo.distance, minDistanceProp.floatValue, maxDistanceProp.floatValue, GUILayout.ExpandWidth(true));
                    EditorGUILayout.Slider(minDistanceProp, 0.2f, maxDistanceProp.floatValue, GUILayout.ExpandWidth(true));
                    EditorGUILayout.Slider(maxDistanceProp, minDistanceProp.floatValue, 80, GUILayout.ExpandWidth(true));

                    m_viObject.ApplyModifiedProperties();
                }
            }
            EditorGUI.EndDisabledGroup();



            //////// 编辑相机震屏
            GUILayout.Space(30);
            EditorGUI.BeginDisabledGroup(!EditorApplication.isPlaying);
            {
                GUILayout.Label("编辑相机震屏", EGUIStyles.TitleTextStyle);

                ////// CameraEffectProfile
                m_EffectInfo = (CameraEffectInfo)EditorGUILayout.ObjectField("CameraEffectInfo", m_EffectInfo, typeof(CameraEffectInfo), true, GUILayout.ExpandWidth(true));
                EditorGUILayout.LabelField("资源路径:       " + m_EffectInfo != null ? AssetDatabase.GetAssetPath(m_EffectInfo) : "", GUILayout.ExpandWidth(true));

                ////// GO
                EditorGUILayout.Separator();
                if (GUILayout.Button("GO", GUILayout.Height(30)))
                {
                    cc.PlayCameraEffect(m_EffectInfo);
                }

                //////// SAVE & SAVE AS
                //EditorGUI.BeginDisabledGroup(!CanSave(m_EffectInfo));
                //{
                //    EditorGUILayout.BeginHorizontal();
                //    if (GUILayout.Button("Save", GUILayout.Width(200)))
                //    {
                //        AssetDatabase.CreateAsset(m_EffectInfo, cc.effectProfileAssetPath);
                //        AssetDatabase.Refresh();
                //    }
                //    if (GUILayout.Button("Save as...", GUILayout.Width(200)))
                //    {
                //        string savePath = EditorUtility.SaveFilePanel("", cc.effectProfileAssetPath, "CameraEffectProfile", "asset");
                //        if (!string.IsNullOrEmpty(savePath))
                //        {
                //            savePath = savePath.Substring(Application.dataPath.Length - 6);
                //            AssetDatabase.CreateAsset(m_EffectInfo, savePath);
                //            AssetDatabase.Refresh();
                //        }
                //    }
                //    EditorGUILayout.EndHorizontal();
                //}
                //EditorGUI.EndDisabledGroup();

                GUILayout.Space(10);
                GUILayout.Label("当前相机震屏参数", EGUIStyles.Label2);
                if (m_EffectInfo != null)
                {
                    Editor editor = CreateEditor(m_EffectInfo);
                    editor.OnInspectorGUI();
                }
            }
            EditorGUI.EndDisabledGroup();
        }