コード例 #1
0
 void SetupEditorVariables()
 {
     cameraTranslateMode = (CPC_EManipulationModes)PlayerPrefs.GetInt("CPC_cameraTranslateMode", 1);
     cameraRotationMode  = (CPC_EManipulationModes)PlayerPrefs.GetInt("CPC_cameraRotationMode", 1);
     handlePositionMode  = (CPC_EManipulationModes)PlayerPrefs.GetInt("CPC_handlePositionMode", 0);
     waypointMode        = (CPC_ENewWaypointMode)PlayerPrefs.GetInt("CPC_waypointMode", 0);
 }
コード例 #2
0
    void DrawWaypointList()
    {
        serializedObject.Update();
        pointReorderableList.DoLayoutList();
        serializedObject.ApplyModifiedProperties();
        Rect r = GUILayoutUtility.GetRect(Screen.width - 16, 18);

        //r.height = 18;
        r.y -= 10;
        GUILayout.Space(-30);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button(addPointContent))
        {
            Undo.RecordObject(t, "Added camera path point");
            switch (waypointMode)
            {
            case CPC_ENewWaypointMode.LastWaypoint:
                if (t.points.Count > 0)
                {
                    t.points.Add(new CPC_Point(t.gameObject.transform.position, t.gameObject.transform.rotation));
                }
                else
                {
                    t.points.Add(new CPC_Point(t.gameObject.transform.position, t.gameObject.transform.rotation));
                    Debug.LogWarning("No previous waypoint found to place this waypoint, defaulting position to world center");
                    pointsListEmpty = false;
                }
                break;

            default:
                Debug.Log("No points available.");
                pointsListEmpty = true;
                break;
                //throw new ArgumentOutOfRangeException();
            }
            selectedIndex = t.points.Count - 1;
            SceneView.RepaintAll();
        }
        GUILayout.Label("at", GUILayout.Width(20));
        EditorGUI.BeginChangeCheck();
        waypointMode = (CPC_ENewWaypointMode)EditorGUILayout.EnumPopup(waypointMode, waypointMode == CPC_ENewWaypointMode.WaypointIndex ? GUILayout.Width(Screen.width / 4) : GUILayout.Width(Screen.width / 2));
        if (waypointMode == CPC_ENewWaypointMode.WaypointIndex)
        {
            waypointIndex = EditorGUILayout.IntField(waypointIndex, GUILayout.Width(Screen.width / 4));
        }
        if (EditorGUI.EndChangeCheck())
        {
            PlayerPrefs.SetInt("CPC_waypointMode", (int)waypointMode);
        }
        GUILayout.EndHorizontal();
    }
コード例 #3
0
    void DrawWaypointList()
    {
        GUILayout.Label("Replace all lerp types");
        GUILayout.BeginVertical("Box");
        GUILayout.BeginHorizontal();
        allCurveType = (CPC_ECurveType)EditorGUILayout.EnumPopup(allCurveType, GUILayout.Width(Screen.width / 3f));
        if (GUILayout.Button(replaceAllPositionContent))
        {
            Undo.RecordObject(t, "Applied new position");
            foreach (var index in t.points)
            {
                index.curveTypePosition = allCurveType;
                if (allCurveType == CPC_ECurveType.Custom)
                {
                    index.positionCurve.keys = allAnimationCurve.keys;
                }
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUI.enabled       = allCurveType == CPC_ECurveType.Custom;
        allAnimationCurve = EditorGUILayout.CurveField(allAnimationCurve, GUILayout.Width(Screen.width / 3f));
        GUI.enabled       = true;
        if (GUILayout.Button(replaceAllRotationContent))
        {
            Undo.RecordObject(t, "Applied new rotation");
            foreach (var index in t.points)
            {
                index.curveTypeRotation = allCurveType;
                if (allCurveType == CPC_ECurveType.Custom)
                {
                    index.rotationCurve = allAnimationCurve;
                }
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();
        GUILayout.BeginHorizontal();
        GUILayout.Space(Screen.width / 2f - 20);
        GUILayout.Label("↓");
        GUILayout.EndHorizontal();
        serializedObject.Update();
        pointReorderableList.DoLayoutList();
        serializedObject.ApplyModifiedProperties();
        Rect r = GUILayoutUtility.GetRect(Screen.width - 16, 18);

        //r.height = 18;
        r.y -= 10;
        GUILayout.Space(-30);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button(addPointContent))
        {
            Undo.RecordObject(t, "Added camera path point");
            switch (waypointMode)
            {
            case CPC_ENewWaypointMode.SceneCamera:
                t.points.Add(new CPC_Point(SceneView.lastActiveSceneView.camera.transform.position, SceneView.lastActiveSceneView.camera.transform.rotation));
                break;

            case CPC_ENewWaypointMode.LastWaypoint:
                if (t.points.Count > 0)
                {
                    t.points.Add(new CPC_Point(t.points[t.points.Count - 1].position, t.points[t.points.Count - 1].rotation)
                    {
                        handlenext = t.points[t.points.Count - 1].handlenext, handleprev = t.points[t.points.Count - 1].handleprev
                    });
                }
                else
                {
                    t.points.Add(new CPC_Point(Vector3.zero, Quaternion.identity));
                    Debug.LogWarning("No previous waypoint found to place this waypoint, defaulting position to world center");
                }
                break;

            case CPC_ENewWaypointMode.WaypointIndex:
                if (t.points.Count > waypointIndex - 1 && waypointIndex > 0)
                {
                    t.points.Add(new CPC_Point(t.points[waypointIndex - 1].position, t.points[waypointIndex - 1].rotation)
                    {
                        handlenext = t.points[waypointIndex - 1].handlenext, handleprev = t.points[waypointIndex - 1].handleprev
                    });
                }
                else
                {
                    t.points.Add(new CPC_Point(Vector3.zero, Quaternion.identity));
                    Debug.LogWarning("Waypoint index " + waypointIndex + " does not exist, defaulting position to world center");
                }
                break;

            case CPC_ENewWaypointMode.WorldCenter:
                t.points.Add(new CPC_Point(Vector3.zero, Quaternion.identity));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            selectedIndex = t.points.Count - 1;
            SceneView.RepaintAll();
        }
        GUILayout.Label("at", GUILayout.Width(20));
        EditorGUI.BeginChangeCheck();
        waypointMode = (CPC_ENewWaypointMode)EditorGUILayout.EnumPopup(waypointMode, waypointMode == CPC_ENewWaypointMode.WaypointIndex ? GUILayout.Width(Screen.width / 4) : GUILayout.Width(Screen.width / 2));
        if (waypointMode == CPC_ENewWaypointMode.WaypointIndex)
        {
            waypointIndex = EditorGUILayout.IntField(waypointIndex, GUILayout.Width(Screen.width / 4));
        }
        if (EditorGUI.EndChangeCheck())
        {
            PlayerPrefs.SetInt("CPC_waypointMode", (int)waypointMode);
        }
        GUILayout.EndHorizontal();
    }