/** Checks if the data is valid */ public bool IsValid() { if (connectedTrack && connectedTrack.TypeSupportsSnapConnections()) { if (connectedTrack.allTrackSnapData != null && connectedTrack.allTrackSnapData.Count > 0) { return(true); } } return(false); }
public TrackSnapData ShowGUI(DragTrack dragTrack, bool useAngles) { label = CustomGUILayout.TextField("Editor label:", label, string.Empty, "The region's label when displayed in Actions."); bool isEnabled = !isDisabled; isEnabled = CustomGUILayout.Toggle("Is enabled?", isEnabled, string.Empty, "If True, the region is enabled"); isDisabled = !isEnabled; positionAlong = CustomGUILayout.Slider("Centre " + ((useAngles) ? "angle" : "position:"), positionAlong, 0f, 1f, string.Empty, "How far along the track (as a decimal) the region lies."); width = CustomGUILayout.Slider("Catchment size:", width, 0f, 1f, string.Empty, "How far apart from the snapping point (as a decimal of the track's length) the object can be for this to be enforced."); gizmoColor = CustomGUILayout.ColorField("Editor colour:", gizmoColor, string.Empty, "What colour to draw handles in the Scene with."); if (dragTrack.doSnapping) { if (dragTrack.actionListSource == ActionListSource.InScene) { cutsceneOnSnap = (Cutscene)CustomGUILayout.ObjectField <Cutscene> ("Cutscene on snap:", cutsceneOnSnap, true, "", "An optional Cutscene to run when a Draggable object snaps to this region"); } else if (dragTrack.actionListSource == ActionListSource.AssetFile) { actionListAssetOnSnap = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("ActionList on snap:", actionListAssetOnSnap, false, "", "An optional ActionList asset to run when a Draggable object snaps to this region"); } } if (dragTrack.TypeSupportsSnapConnections()) { if (connections.Count == 0) { TrackSnapConnection trackSnapConnection = new TrackSnapConnection(); connections.Add(trackSnapConnection); } for (int i = 0; i < connections.Count; i++) { EditorGUILayout.BeginHorizontal(); connections[i] = connections[i].ShowGUI(dragTrack, i); if (GUILayout.Button("+", GUILayout.MaxWidth(20f))) { Undo.RecordObject(dragTrack, "Add connection"); TrackSnapConnection trackSnapConnection = new TrackSnapConnection(); connections.Insert(i + 1, trackSnapConnection); i = -1; break; } if (connections.Count > 1 && GUILayout.Button("-", GUILayout.MaxWidth(20f))) { Undo.RecordObject(dragTrack, "Delete connection"); connections.RemoveAt(i); i = -1; break; } EditorGUILayout.EndHorizontal(); } } return(this); }