-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import Rumble source from Sparklite v1.3
- Loading branch information
1 parent
8f850b7
commit 05e9fc9
Showing
62 changed files
with
3,893 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"files.exclude": | ||
{ | ||
"**/.DS_Store":true, | ||
"**/.git":true, | ||
"**/.gitignore":true, | ||
"**/.gitmodules":true, | ||
"**/*.booproj":true, | ||
"**/*.pidb":true, | ||
"**/*.suo":true, | ||
"**/*.user":true, | ||
"**/*.userprefs":true, | ||
"**/*.unityproj":true, | ||
"**/*.dll":true, | ||
"**/*.exe":true, | ||
"**/*.pdf":true, | ||
"**/*.mid":true, | ||
"**/*.midi":true, | ||
"**/*.wav":true, | ||
"**/*.gif":true, | ||
"**/*.ico":true, | ||
"**/*.jpg":true, | ||
"**/*.jpeg":true, | ||
"**/*.png":true, | ||
"**/*.psd":true, | ||
"**/*.tga":true, | ||
"**/*.tif":true, | ||
"**/*.tiff":true, | ||
"**/*.3ds":true, | ||
"**/*.3DS":true, | ||
"**/*.fbx":true, | ||
"**/*.FBX":true, | ||
"**/*.lxo":true, | ||
"**/*.LXO":true, | ||
"**/*.ma":true, | ||
"**/*.MA":true, | ||
"**/*.obj":true, | ||
"**/*.OBJ":true, | ||
"**/*.asset":true, | ||
"**/*.cubemap":true, | ||
"**/*.flare":true, | ||
"**/*.mat":true, | ||
"**/*.meta":true, | ||
"**/*.prefab":true, | ||
"**/*.unity":true, | ||
"build/":true, | ||
"Build/":true, | ||
"Library/":true, | ||
"library/":true, | ||
"obj/":true, | ||
"Obj/":true, | ||
"ProjectSettings/":true, | ||
"temp/":true, | ||
"Temp/":true | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
210 changes: 210 additions & 0 deletions
210
Assets/Red Blue Games/Rumble/Editor/RumbleInfoEditor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEditor; | ||
using UnityEditor.AnimatedValues; | ||
using UnityEngine; | ||
|
||
/// <summary> | ||
/// Drawer for RumbleInfo. | ||
/// </summary> | ||
[CustomEditor(typeof(RumbleInfo))] | ||
public class RumbleInfoEditor : Editor | ||
{ | ||
private SerializedProperty lifetimeProperty; | ||
private SerializedProperty radiusProperty; | ||
private SerializedProperty intensityModeProperty; | ||
private SerializedProperty constantIntensityProperty; | ||
private SerializedProperty intensityCurveProperty; | ||
private SerializedProperty intensityCurvePeriodProperty; | ||
private SerializedProperty isIntensityCurveLoopedProperty; | ||
private SerializedProperty falloffFunctionProperty; | ||
private SerializedProperty rumbleSettingsProperty; | ||
|
||
private AnimBool constantIntensityAnim = new AnimBool(); | ||
private AnimBool curveIntensityAnim = new AnimBool(); | ||
|
||
/// <summary> | ||
/// Gets the target, typed as RumbleInfo. | ||
/// </summary> | ||
/// <value>The target being drawn.</value> | ||
protected RumbleInfo Target | ||
{ | ||
get | ||
{ | ||
return (RumbleInfo)(object)target; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Draw the Inspector for the RumbleInfo | ||
/// </summary> | ||
public override void OnInspectorGUI() | ||
{ | ||
// Pull the property values from the asset/object | ||
serializedObject.Update(); | ||
|
||
EditorGUILayout.PropertyField(this.lifetimeProperty); | ||
EditorGUILayout.PropertyField(this.radiusProperty); | ||
EditorGUILayout.PropertyField(this.intensityModeProperty, new GUIContent("Intensity Over Time")); | ||
|
||
this.DrawGUIIntensitySettings(); | ||
|
||
EditorGUILayout.Space(); | ||
|
||
EditorGUILayout.PropertyField(this.falloffFunctionProperty, new GUIContent("Falloff")); | ||
|
||
EditorGUILayout.Space(); | ||
|
||
this.DrawDivider(); | ||
|
||
EditorGUILayout.PropertyField(this.rumbleSettingsProperty, true); | ||
|
||
if (GUI.changed) | ||
{ | ||
// Clamp values to their minimums | ||
this.radiusProperty.floatValue = Mathf.Max(this.radiusProperty.floatValue, RumbleInfo.MinRadius); | ||
this.lifetimeProperty.floatValue = Mathf.Max(this.lifetimeProperty.floatValue, RumbleInfo.MinLifetime); | ||
this.intensityCurvePeriodProperty.floatValue = Mathf.Clamp( | ||
this.intensityCurvePeriodProperty.floatValue, | ||
RumbleInfo.IntensityCurveSettings.MinPeriod, | ||
float.MaxValue); | ||
|
||
// Mark Asset as dirty so that Save will immediately write changes to disk. | ||
EditorUtility.SetDirty(this.Target); | ||
} | ||
|
||
// Apply any GUI edited/changed property values back to the asset/object | ||
serializedObject.ApplyModifiedProperties(); | ||
} | ||
|
||
private void DrawDivider() | ||
{ | ||
GUILayout.Box(string.Empty, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(1) }); | ||
} | ||
|
||
/// <summary> | ||
/// The Enable message. Called when inspector is deserialized. | ||
/// </summary> | ||
protected void OnEnable() | ||
{ | ||
var intensityCurveSettingsProperty = serializedObject.FindProperty("intensityCurveSettings"); | ||
|
||
this.lifetimeProperty = serializedObject.FindProperty("lifetime"); | ||
this.radiusProperty = serializedObject.FindProperty("radius"); | ||
this.intensityModeProperty = serializedObject.FindProperty("intensityMode"); | ||
this.constantIntensityProperty = serializedObject.FindProperty("constantIntensity"); | ||
this.intensityCurveProperty = intensityCurveSettingsProperty.FindPropertyRelative("curve"); | ||
this.isIntensityCurveLoopedProperty = intensityCurveSettingsProperty.FindPropertyRelative("isLooping"); | ||
this.intensityCurvePeriodProperty = intensityCurveSettingsProperty.FindPropertyRelative("period"); | ||
this.falloffFunctionProperty = serializedObject.FindProperty("falloffFunction"); | ||
|
||
this.rumbleSettingsProperty = serializedObject.FindProperty("rumbleSettings"); | ||
|
||
// Initialize the animation tracking fields so that you don't see it animate every time you click on a Rumble. | ||
var intensityOverLifetime = (RumbleInfo.RumbleIntensityMode)this.intensityModeProperty.enumValueIndex; | ||
this.constantIntensityAnim.value = intensityOverLifetime == RumbleInfo.RumbleIntensityMode.Constant; | ||
this.curveIntensityAnim.value = intensityOverLifetime == RumbleInfo.RumbleIntensityMode.Curve; | ||
|
||
this.constantIntensityAnim.valueChanged.AddListener(this.Repaint); | ||
this.curveIntensityAnim.valueChanged.AddListener(this.Repaint); | ||
} | ||
|
||
/// <summary> | ||
/// The disable event. | ||
/// </summary> | ||
protected void OnDisable() | ||
{ | ||
this.constantIntensityAnim.valueChanged.RemoveListener(this.Repaint); | ||
this.curveIntensityAnim.valueChanged.RemoveListener(this.Repaint); | ||
} | ||
|
||
private void DrawGUIIntensitySettings() | ||
{ | ||
EditorGUI.indentLevel++; | ||
|
||
// Set targets for lerped floats that track fade animation | ||
var intensityOverLifetime = (RumbleInfo.RumbleIntensityMode)this.intensityModeProperty.enumValueIndex; | ||
this.constantIntensityAnim.target = intensityOverLifetime == RumbleInfo.RumbleIntensityMode.Constant; | ||
this.curveIntensityAnim.target = intensityOverLifetime == RumbleInfo.RumbleIntensityMode.Curve; | ||
|
||
switch (Target.IntensityOverLifetime) | ||
{ | ||
case RumbleInfo.RumbleIntensityMode.Constant: | ||
EditorGUILayout.BeginFadeGroup(this.constantIntensityAnim.faded); | ||
EditorGUILayout.PropertyField(this.constantIntensityProperty, new GUIContent("Intensity")); | ||
EditorGUILayout.EndFadeGroup(); | ||
break; | ||
case RumbleInfo.RumbleIntensityMode.Curve: | ||
this.DrawGUIIntensityCurveSettings(); | ||
break; | ||
default: | ||
Debug.LogError("Unrecognized RumbleIntensityMode found in RumbleInfoEditor for IntensityOverLifetime. " + | ||
"Mode: " + Target.IntensityOverLifetime); | ||
break; | ||
} | ||
|
||
EditorGUI.indentLevel--; | ||
} | ||
|
||
private void DrawGUIIntensityCurveSettings() | ||
{ | ||
EditorGUILayout.BeginFadeGroup(this.curveIntensityAnim.faded); | ||
|
||
// Draw info explaining why Looping field is checked | ||
bool isLifetimeInfinite = float.IsInfinity(this.lifetimeProperty.floatValue); | ||
if (isLifetimeInfinite) | ||
{ | ||
EditorGUILayout.HelpBox("IntensityCurve has been auto flagged as looping due to infinite Lifetime.", MessageType.None); | ||
} | ||
|
||
EditorGUILayout.PropertyField(this.intensityCurveProperty); | ||
|
||
// Draw Looping Field | ||
bool isLoopingFieldDisabled = isLifetimeInfinite || this.intensityCurveProperty.objectReferenceValue == null; | ||
if (isLifetimeInfinite) | ||
{ | ||
// Force Looping set if lifetime is infinite, since an infinite period is invalid | ||
this.isIntensityCurveLoopedProperty.boolValue = true; | ||
} | ||
|
||
EditorGUI.BeginDisabledGroup(isLoopingFieldDisabled); | ||
EditorGUILayout.PropertyField(this.isIntensityCurveLoopedProperty, new GUIContent("Looping")); | ||
EditorGUI.EndDisabledGroup(); | ||
|
||
// Draw Period Field | ||
bool isLooping = this.isIntensityCurveLoopedProperty.boolValue; | ||
bool isPeriodFieldDisabled = !isLooping || this.intensityCurveProperty.objectReferenceValue == null; | ||
EditorGUI.BeginDisabledGroup(isPeriodFieldDisabled); | ||
|
||
var periodGUIContent = new GUIContent("Period"); | ||
if (isLifetimeInfinite) | ||
{ | ||
// Don't draw a slider for period with Infinite lifetime, since there is no longer a good slider range | ||
EditorGUILayout.PropertyField(this.intensityCurvePeriodProperty, periodGUIContent); | ||
} | ||
else | ||
{ | ||
EditorGUILayout.Slider( | ||
this.intensityCurvePeriodProperty, | ||
RumbleInfo.MinLifetime, | ||
this.lifetimeProperty.floatValue, | ||
periodGUIContent); | ||
|
||
// Always clamp period to lifetime - this fixes Period from exceeding lifetime when setting | ||
// Lifetime from infinite down to a finite number smaller than the period | ||
this.intensityCurvePeriodProperty.floatValue = Mathf.Min( | ||
this.intensityCurvePeriodProperty.floatValue, | ||
this.lifetimeProperty.floatValue); | ||
|
||
// If non-looping, force period to match lifetime | ||
if (!isLooping) | ||
{ | ||
this.intensityCurvePeriodProperty.floatValue = this.lifetimeProperty.floatValue; | ||
} | ||
} | ||
|
||
EditorGUI.EndDisabledGroup(); | ||
|
||
EditorGUILayout.EndFadeGroup(); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Assets/Red Blue Games/Rumble/Editor/RumbleInfoEditor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.