Ejemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        AnimationTest animationTest = (AnimationTest)target;

        GUILayout.BeginHorizontal();
        {
            if (GUILayout.Button("Play", GUILayout.Width(120)))
            {
                animationTest.Play();
            }
        }
        GUILayout.EndHorizontal();
    }
    public override void OnInspectorGUI()
    {
        CameraTestTool cameraTestTool = (CameraTestTool)target;

        cameraTestTool.m_TargetTransCache = EditorGUILayout.ObjectField("Target: ", cameraTestTool.m_TargetTransCache, typeof(Transform)) as Transform;
        //EditorGUILayout.Separator();
        EditorGUILayout.Space();

        cameraTestTool.m_fDefaultDistance = EditorGUILayout.FloatField("Default Distance: ", cameraTestTool.m_fDefaultDistance);
        cameraTestTool.m_fDefaultPitch    = EditorGUILayout.FloatField("Default Pitch: ", cameraTestTool.m_fDefaultPitch);
        cameraTestTool.m_fDefaultYaw      = EditorGUILayout.FloatField("Default Yaw: ", cameraTestTool.m_fDefaultYaw);
        if (GUILayout.Button("Rest to default"))
        {
            cameraTestTool.m_fDistance = cameraTestTool.m_fDefaultDistance;
            cameraTestTool.m_fPitch    = cameraTestTool.m_fDefaultPitch;
            cameraTestTool.m_fYaw      = cameraTestTool.m_fDefaultYaw;
        }
        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        cameraTestTool.m_fDistance = EditorGUILayout.FloatField("Distance: ", cameraTestTool.m_fDistance);
        cameraTestTool.m_fDistance = EditorGUILayout.Slider(cameraTestTool.m_fDistance, cameraTestTool.m_fDistanceMin, cameraTestTool.m_fDistanceMax);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        cameraTestTool.m_fPitch = EditorGUILayout.FloatField("Pitch: ", cameraTestTool.m_fPitch);
        cameraTestTool.m_fPitch = EditorGUILayout.Slider(cameraTestTool.m_fPitch, cameraTestTool.m_fPitchMin, cameraTestTool.m_fPitchMax);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.BeginHorizontal();
        cameraTestTool.m_fYaw = EditorGUILayout.FloatField("Yaw: ", cameraTestTool.m_fYaw);
        cameraTestTool.m_fYaw = EditorGUILayout.Slider(cameraTestTool.m_fYaw, -180, 180);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();

        base.OnInspectorGUI();

        EditorGUILayout.LabelField("Camera Anim Name:  " + cameraTestTool.m_ExportFileName);

        if (GUILayout.Button("Clear Pitch Curve"))
        {
            cameraTestTool.m_PitchRock = new AnimationCurve();
        }
        if (GUILayout.Button("Clear Yaw Curve"))
        {
            cameraTestTool.m_YawRock = new AnimationCurve();
        }
        if (GUILayout.Button("Clear Distance Curve"))
        {
            cameraTestTool.m_DistanceRock = new AnimationCurve();
        }
        if (GUILayout.Button("Clear Offset Curve"))
        {
            cameraTestTool.m_OffsetYRock = new AnimationCurve();
        }
        if (GUILayout.Button("Clear All Curve"))
        {
            if (EditorUtility.DisplayDialog("警告,不可撤销", "清除正在编辑的所有曲线吗?", "是的", "再想想"))
            {
                cameraTestTool.m_PitchRock    = new AnimationCurve();
                cameraTestTool.m_YawRock      = new AnimationCurve();
                cameraTestTool.m_DistanceRock = new AnimationCurve();
                cameraTestTool.m_OffsetYRock  = new AnimationCurve();
            }
        }
        cameraTestTool.m_fRockDely = EditorGUILayout.FloatField("Delay Time: ", cameraTestTool.m_fRockDely);
        cameraTestTool.m_fRockTime = EditorGUILayout.FloatField("Rock Time: ", cameraTestTool.m_fRockTime);
        if (GUILayout.Button("Test Rock"))
        {
            cameraTestTool.StartTestRock();
            if (cameraTestTool.m_TargetTransCache != null)
            {
                AnimationTest animationTest = cameraTestTool.m_TargetTransCache.gameObject.GetComponentInChildren <AnimationTest>();
                if (animationTest != null)
                {
                    animationTest.Play();
                }
            }
        }
        EditorGUILayout.Space();

        if (GUILayout.Button("Export"))
        {
            string defaultName = cameraTestTool.m_ExportFileName == string.Empty ?
                                 "CameraAnimCurve" + (Convert.ToInt32(System.DateTime.Now.ToString("ddHHmmss")) * 10).ToString() :
                                 cameraTestTool.m_ExportFileName;
            string savePath = EditorUtility.SaveFilePanel("保存摄像机动画", DefaultSaveDir, defaultName, "txt");
            if (savePath.Length != 0)
            {
                cameraTestTool.m_ExportFileName = System.IO.Path.GetFileName(savePath);
                ExportCurve2TXT(cameraTestTool, savePath);
            }
        }
        if (GUILayout.Button("Import"))
        {
            if (EditorUtility.DisplayDialog("警告,不可撤销", "导入会覆盖正在编辑的所有曲线,确定要这么做吗?", "是的", "再想想"))
            {
                string defaultFilePath = DefaultSaveDir + cameraTestTool.m_ExportFileName + ".txt";
                string filePath        = EditorUtility.OpenFilePanel("打开摄像机动画", defaultFilePath, "txt");
                if (filePath.Length != 0)
                {
                    cameraTestTool.m_ExportFileName = System.IO.Path.GetFileName(filePath);
                    ReadCurveFromTxt(cameraTestTool, filePath);
                }
            }
        }
    }