public void SetValues(float angle, float height, float intense, float time, int keyIndex, int curveIndex, ScriptableHapticCurve curve) { hitAngle = angle; hitHeight = height; intensity = intense; timing = time; keyFrameIndex = keyIndex; hapticCurveIndex = curveIndex; hapticCurve = curve; }
/// <summary> /// Adds a curve that already has a .asset file associated with the curve /// </summary> /// <param name="hapticCurve">The curve to add</param> public void AddSavedCurve(ScriptableHapticCurve hapticCurve) { // Add the curve info to the pattern CurveIndex = HapticPattern.AddSavedCurve(hapticCurve); // Start tracking the BodyHitUI for this new curve index bodyHitsPerCurve.Add(CurveIndex, new List <BodyHitUI>()); // Get all the curve info into the dictionary AddCurveToDictionary(CurveIndex, hapticCurve); }
private void AddCurveToDictionary(int curveIndex, ScriptableHapticCurve curveToAdd) { if (curveToAdd != null) { // Go through each keyframe, save the value, and place the GO representation for (int h = 0; h < curveToAdd.heightCurve.length; h++) { float hitHeight = curveToAdd.heightCurve[h].value; float hitAngle = curveToAdd.angleCurve[h].value; BodyHitUI currentHit = SpawnBodyHitGameObject(capsuleBodyCoordinate.CalculatePositionFromBodyCoordinateHit(new BodyCoordinateHit(hitHeight, hitAngle), true), hitAngle, hitHeight, curveToAdd.heightCurve[h].time, curveIndex, curveToAdd.intensityCurve[h].value); bodyHitsPerCurve[curveIndex].Add(currentHit); } } }
/// <summary> /// Adds a curve to the curveList. This method is used when the curve already has an .asset file associated /// with it and does not require tweaking it in any way. /// </summary> /// <param name="hapticCurve">The curve to add to the list</param> /// <returns>The index of the added curve</returns> public int AddSavedCurve(ScriptableHapticCurve hapticCurve) { curveList.Add(hapticCurve); return(curveList.Count - 1); }
/// <summary> /// Handles how to render the actual elements of the UI /// </summary> public void RenderSceneGUI(SceneView sceneview) { Handles.BeginGUI(); // Make a canvas that spans the entire height of the scene and a portion of the width Rect canvasRect = new Rect(0, 0, Screen.width / UI_SCREEN_WIDTH, Screen.height); GUILayout.BeginArea(canvasRect); // Make the area behind the GUI a gray, slightly transparent canvas EditorGUI.DrawRect(canvasRect, new Color(0.5f, 0.5f, 0.5f, 0.5f)); Rect verticleLayoutBox = EditorGUILayout.BeginVertical(); GUI.Box(verticleLayoutBox, GUIContent.none); // Add header for loading/saving patterns EditorGUILayout.Space(); EditorGUILayout.HelpBox("Pattern Management", MessageType.None); // Load a saved pattern EditorGUILayout.LabelField("Load Saved Pattern:", textLabelStyle); patternToLoad = EditorGUILayout.ObjectField(patternToLoad, typeof(ScriptableHapticPattern), false) as ScriptableHapticPattern; if (patternToLoad != null) { if (GUILayout.Button("Load Pattern")) { LoadPattern(); patternToLoad = null; } } // Save changes and return to previous scene if (GUILayout.Button("Save and return")) { patternWindow.SavePattern(patternName, selectedCollisionResolution, collisionResolutionIndex, selectedPlaybackTiming, customPlaybackTiming, selectedOffsetUse, selectedHeightOvershoot, selectedAngleOvershoot); } // Save the background color to temporarily change the discard background to red to indicate the negative nature of the button Color oldColor = GUI.backgroundColor; GUI.backgroundColor = Color.red; // Discard all the changes and return to previous scene if (GUILayout.Button("Discard changes")) { bool discardResult = EditorUtility.DisplayDialog("Discard changes?", "Are you sure you want to discard all changes made to this pattern?", "Yes", "Cancel"); if (discardResult) { patternWindow.DiscardChanges(); } } GUI.backgroundColor = oldColor; // Add header for pattern settings EditorGUILayout.Space(); EditorGUILayout.HelpBox("Pattern Settings", MessageType.None); // Prompt for pattern name which will become the file name EditorGUILayout.LabelField("Pattern Name:", textLabelStyle); patternName = EditorGUILayout.TextField(patternName); // Prompt for how to handle intensity collisions EditorGUILayout.LabelField("Collision Resolution:", textLabelStyle); selectedCollisionResolution = (PatternCollisionResolution)EditorGUILayout.EnumPopup(selectedCollisionResolution); // Prompt for the index of the curve to use if the resolution is set to CurvePriority if (selectedCollisionResolution == PatternCollisionResolution.CurvePriority) { EditorGUILayout.LabelField("Curve Index:", textLabelStyle); collisionResolutionIndex = EditorGUILayout.IntField(collisionResolutionIndex); } // Prompt for the playback timing on the pattern EditorGUILayout.LabelField("Playback Timing:", textLabelStyle); selectedPlaybackTiming = (PlaybackTiming)EditorGUILayout.EnumPopup(selectedPlaybackTiming); // Prompt for custom playback timing if they have selected CustomPlayback as the option if (selectedPlaybackTiming == PlaybackTiming.Custom) { EditorGUILayout.LabelField("Custom Playback Time:", textLabelStyle); customPlaybackTiming = EditorGUILayout.FloatField(customPlaybackTiming); } // Prompt for offset use EditorGUILayout.LabelField("Offset Use:", textLabelStyle); selectedOffsetUse = (OffsetUse)EditorGUILayout.EnumPopup(selectedOffsetUse); // Prompt for height overshoot EditorGUILayout.LabelField("Height Overshoot Resolution:", textLabelStyle); selectedHeightOvershoot = (PatternOvershootResolution)EditorGUILayout.EnumPopup(selectedHeightOvershoot); // Prompt for angle overshoot EditorGUILayout.LabelField("Angle Overshoot Resolution:", textLabelStyle); selectedAngleOvershoot = (PatternOvershootResolution)EditorGUILayout.EnumPopup(selectedAngleOvershoot); // Header for management curves EditorGUILayout.Space(); EditorGUILayout.HelpBox("Curve Management", MessageType.None); // Build string list of attached curves string[] curveNames = new string[patternWindow.HapticPattern.curveList.Count]; for (int n = 0; n < patternWindow.HapticPattern.curveList.Count; n++) { curveNames[n] = patternWindow.HapticPattern.curveList[n].ToString(); } // Show list of curves on the pattern for the user to select EditorGUILayout.LabelField("Current curve:", textLabelStyle); patternWindow.CurveIndex = EditorGUILayout.Popup(patternWindow.CurveIndex, curveNames); // Allow the user to add a new curve if (GUILayout.Button("Add New Curve")) { patternWindow.AddNewCurve("Default"); } if (GUILayout.Button("Remove Current Curve")) { patternWindow.RemoveCurrentCurve(); } // Add selected curve to pattern button EditorGUILayout.LabelField("Add Saved Curve:", textLabelStyle); curveToAdd = EditorGUILayout.ObjectField(curveToAdd, typeof(ScriptableHapticCurve), false) as ScriptableHapticCurve; if (curveToAdd != null) { if (GUILayout.Button("Add Curve")) { patternWindow.AddSavedCurve(curveToAdd); curveToAdd = null; } } EditorGUILayout.EndVertical(); GUILayout.EndArea(); Handles.EndGUI(); }