private static void DrawDroneTools(Crazyflie drone) { EditorGUI.BeginChangeCheck(); bool timestampsEnabled = EditorGUILayout.Toggle("Show Timestamps", showTimestamps); bool endpointsEnabled = EditorGUILayout.Toggle("Show Start/End Text", showEndpoints); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetBool(TIMESTAMPS_PREF_KEY, timestampsEnabled); EditorPrefs.SetBool(ENDPOINTS_PREF_KEY, endpointsEnabled); } EditorGUILayout.Space(30.0f); EditorGUI.BeginChangeCheck(); Color updatedColor = EditorGUILayout.ColorField(new GUIContent("Current Color"), drone.LightColor, false, false, false); if (EditorGUI.EndChangeCheck()) { drone.SetColorKeyframe(updatedColor, drone.Time); EditorApplication.QueuePlayerLoopUpdate(); } EditorGUILayout.Space(10); EditorGUI.BeginChangeCheck(); Vector3 updatedPosition = EditorGUILayout.Vector3Field(new GUIContent("Current Position"), drone.transform.position); if (EditorGUI.EndChangeCheck()) { drone.SetWaypoint(updatedPosition, drone.Time); } EditorGUILayout.Space(10); }
public void Apply() { if (Drone != null) { Drone.SetWaypoint(Position, TimelineUtilities.CurrentTime); } }
/// -------- DRONE HANDLES -------- /// public static void DrawDroneHandles(Crazyflie drone, bool active) { float time = (float)TimelineUtilities.Director.time; List <Waypoint> waypoints = drone.Waypoints; CustomHandles.DrawBezierPath(waypoints, Color.white, 2.0f); DrawWaypoints(waypoints); ColorKeyframeEditor.DrawColorKeyframes(drone, waypoints); if (active) { DrawDroneBounds(drone, Palette.Translucent); // DrawDroneBounds(drone, Color.white); EditorGUI.BeginChangeCheck(); Vector3 updatedPosition = CustomHandles.MoveHandle(drone.transform.position, 0.025f, 0.085f); if (EditorGUI.EndChangeCheck()) { drone.SetWaypoint(updatedPosition, time); } } //CustomHandles.DrawTangent(waypoints, 0.25f, time); }
static void CreateDrone() { if (DroneTemplate == null) { DroneTemplate = Resources.Load <GameObject>("Prefabs/crazyflie"); } string operationName = "Create Drone"; Undo.RecordObject(Director, operationName); Undo.RecordObject(Timeline, operationName); int droneCount = FindObjectsOfType <Crazyflie>().Length; GameObject drone = (GameObject)PrefabUtility.InstantiatePrefab(DroneTemplate); drone.name = $"Drone {droneCount}"; drone.transform.position = new Vector3(0, 0.5f, 0); drone.transform.SetAsLastSibling(); CrazyflieTrack track = Timeline.CreateTrack <CrazyflieTrack>(drone.name + " Track"); Crazyflie crazyflie = drone.GetComponent <Crazyflie>(); crazyflie?.Initialize(track); crazyflie?.SetColorKeyframe(Color.black, 0.0f); crazyflie?.SetWaypoint(drone.transform.position, 0.0f); Director.SetGenericBinding(track, crazyflie); AssetDatabase.Refresh(); EditorUtility.SetDirty(Timeline); EditorUtility.SetDirty(track); EditorUtility.SetDirty(Director); UnityEditor.Timeline.TimelineEditor.Refresh(UnityEditor.Timeline.RefreshReason.ContentsAddedOrRemoved); Undo.RegisterCreatedObjectUndo(drone, "Create Drone"); Undo.RegisterCreatedObjectUndo(track, "Create Drone"); Selection.activeObject = drone; }