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() { UpdateContainment(); for (int i = 0; i < containedDroneCount; i++) { Crazyflie drone = this.hitDrones[i]; drone.SetColorKeyframe(Evaluate(drone.transform.position), TimelineUtilities.CurrentTime); } EditorApplication.QueuePlayerLoopUpdate(); }
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; }