diff --git a/SPAnim/Anim/AnimSettings.cs b/SPAnim/Anim/AnimSettings.cs index 862e1f9..8a4f045 100644 --- a/SPAnim/Anim/AnimSettings.cs +++ b/SPAnim/Anim/AnimSettings.cs @@ -8,6 +8,17 @@ namespace com.spacepuppy.Anim { + [System.Flags] + public enum AnimSettingsMask + { + Weight = 1, + Speed = 2, + Layer = 4, + WrapMode = 8, + BlendMode = 16, + TimeSupplier = 32 + } + [System.Serializable] public struct AnimSettings { @@ -63,6 +74,44 @@ public void Apply(ISPAnim anim) anim.TimeSupplier = this.timeSupplier.TimeSupplier; } + public void Apply(SPAnim anim, AnimSettingsMask mask) + { + if ((mask & AnimSettingsMask.Weight) != 0) anim.Weight = this.weight; + if ((mask & AnimSettingsMask.Speed) != 0) anim.Speed = this.speed; + if ((mask & AnimSettingsMask.Layer) != 0) anim.Layer = this.layer; + if ((mask & AnimSettingsMask.WrapMode) != 0) anim.WrapMode = this.wrapMode; + if ((mask & AnimSettingsMask.BlendMode) != 0) anim.BlendMode = this.blendMode; + if ((mask & AnimSettingsMask.TimeSupplier) != 0) anim.TimeSupplier = this.timeSupplier.TimeSupplier; + } + + public void Apply(AnimationState anim, AnimSettingsMask mask) + { + if ((mask & AnimSettingsMask.Weight) != 0) anim.weight = this.weight; + if ((mask & AnimSettingsMask.Speed) != 0) anim.speed = this.speed; + if ((mask & AnimSettingsMask.Layer) != 0) anim.layer = this.layer; + if ((mask & AnimSettingsMask.WrapMode) != 0) anim.wrapMode = this.wrapMode; + if ((mask & AnimSettingsMask.BlendMode) != 0) anim.blendMode = this.blendMode; + if ((mask & AnimSettingsMask.TimeSupplier) != 0 && this.timeSupplier.IsCustom) + { + anim.speed = this.speed * SPTime.GetInverseScale(this.timeSupplier.TimeSupplier); + } + } + + public void Apply(ISPAnim anim, AnimSettingsMask mask) + { + if (anim is SPAnim) + { + this.Apply(anim as SPAnim, mask); + return; + } + //can't set weight + if ((mask & AnimSettingsMask.Speed) != 0) anim.Speed = this.speed; + if ((mask & AnimSettingsMask.Layer) != 0) anim.Layer = this.layer; + if ((mask & AnimSettingsMask.WrapMode) != 0) anim.WrapMode = this.wrapMode; + //can't set blend mode + if ((mask & AnimSettingsMask.TimeSupplier) != 0) anim.TimeSupplier = this.timeSupplier.TimeSupplier; + } + #endregion #region Static Interface @@ -101,6 +150,17 @@ public static AnimSettings From(AnimationState anim) }; } + public static AnimSettings Intersect(AnimSettings settings, AnimSettings with, AnimSettingsMask mask) + { + if ((mask & AnimSettingsMask.Weight) != 0) settings.weight = with.weight; + if ((mask & AnimSettingsMask.Speed) != 0) settings.speed = with.speed; + if ((mask & AnimSettingsMask.Layer) != 0) settings.layer = with.layer; + if ((mask & AnimSettingsMask.WrapMode) != 0) settings.wrapMode = with.wrapMode; + if ((mask & AnimSettingsMask.BlendMode) != 0) settings.blendMode = with.blendMode; + if ((mask & AnimSettingsMask.TimeSupplier) != 0) settings.timeSupplier = with.timeSupplier; + return settings; + } + #endregion } diff --git a/SPAnim/Anim/Events/PlayAnimInfo.cs b/SPAnim/Anim/Events/PlayAnimInfo.cs index a20b2d2..7264637 100644 --- a/SPAnim/Anim/Events/PlayAnimInfo.cs +++ b/SPAnim/Anim/Events/PlayAnimInfo.cs @@ -19,7 +19,7 @@ public class PlayAnimInfo [SerializeField] private UnityEngine.Object _clip; [SerializeField] - public bool ApplyCustomSettings; + public AnimSettingsMask SettingsMask; [SerializeField] public AnimSettings Settings = AnimSettings.Default; [SerializeField] diff --git a/SPAnim/Anim/Events/i_PlayAnimation.cs b/SPAnim/Anim/Events/i_PlayAnimation.cs index 62c2329..4710652 100644 --- a/SPAnim/Anim/Events/i_PlayAnimation.cs +++ b/SPAnim/Anim/Events/i_PlayAnimation.cs @@ -38,7 +38,7 @@ public enum PlayByMode private UnityEngine.Object _clip; [SerializeField] - private bool _applyCustomSettings; + private AnimSettingsMask _settingsMask; [SerializeField] private AnimSettings _settings = AnimSettings.Default; @@ -67,11 +67,11 @@ private object PlayClip(SPLegacyAnimController controller, UnityEngine.Object cl { if (_crossFadeDur > 0f) return controller.CrossFadeAuxiliary(clip as AnimationClip, - _applyCustomSettings ? _settings : AnimSettings.Default, + (_settingsMask != 0) ? AnimSettings.Intersect(AnimSettings.Default, _settings, _settingsMask) : AnimSettings.Default, _crossFadeDur, _queueMode, _playMode); else return controller.PlayAuxiliary(clip as AnimationClip, - _applyCustomSettings ? _settings : AnimSettings.Default, + (_settingsMask != 0) ? AnimSettings.Intersect(AnimSettings.Default, _settings, _settingsMask) : AnimSettings.Default, _queueMode, _playMode); } else if (clip is IScriptableAnimationClip) @@ -99,7 +99,7 @@ private object PlayClip(Animation controller, AnimationClip clip) anim = animController.CrossFadeQueued(id, _crossFadeDur, _queueMode, _playMode); else anim = animController.PlayQueued(id, _queueMode, _playMode); - if (_applyCustomSettings) _settings.Apply(anim); + if (_settingsMask != 0) _settings.Apply(anim, _settingsMask); return anim; } @@ -119,7 +119,7 @@ private object TryPlay(object controller) anim.CrossFade(_crossFadeDur, _queueMode, _playMode); else anim.Play(_queueMode, _playMode); - if (_applyCustomSettings) _settings.Apply(anim); + if (_settingsMask != 0) _settings.Apply(anim, _settingsMask); return anim; } return null; @@ -142,7 +142,7 @@ private object TryPlay(object controller) anim = comp.CrossFadeQueued(_id, _crossFadeDur, _queueMode, _playMode); else anim = comp.PlayQueued(_id, _queueMode, _playMode); - if (_applyCustomSettings) _settings.Apply(anim); + if (_settingsMask != 0) _settings.Apply(anim, _settingsMask); return anim; } return null; @@ -161,7 +161,7 @@ private object TryPlay(object controller) anim.CrossFade(_crossFadeDur, _queueMode, _playMode); else anim.Play(_queueMode, _playMode); - if (_applyCustomSettings) _settings.Apply(anim); + if (_settingsMask != 0) _settings.Apply(anim, _settingsMask); return anim; } return null; diff --git a/SPAnim/Anim/Events/i_PlayRandomAnimation.cs b/SPAnim/Anim/Events/i_PlayRandomAnimation.cs index 302e823..d32dead 100644 --- a/SPAnim/Anim/Events/i_PlayRandomAnimation.cs +++ b/SPAnim/Anim/Events/i_PlayRandomAnimation.cs @@ -43,11 +43,11 @@ private object PlayClip(SPLegacyAnimController controller, UnityEngine.Object cl { if (info.CrossFadeDur > 0f) return controller.CrossFadeAuxiliary(clip as AnimationClip, - info.ApplyCustomSettings ? info.Settings : AnimSettings.Default, + (info.SettingsMask != 0) ? AnimSettings.Intersect(AnimSettings.Default, info.Settings, info.SettingsMask) : AnimSettings.Default, info.CrossFadeDur, info.QueueMode, info.PlayMode); else return controller.PlayAuxiliary(clip as AnimationClip, - info.ApplyCustomSettings ? info.Settings : AnimSettings.Default, + (info.SettingsMask != 0) ? AnimSettings.Intersect(AnimSettings.Default, info.Settings, info.SettingsMask) : AnimSettings.Default, info.QueueMode, info.PlayMode); } else if (clip is IScriptableAnimationClip) @@ -75,7 +75,7 @@ private object PlayClip(Animation controller, UnityEngine.Object clip, PlayAnimI anim = animController.CrossFadeQueued(id, info.CrossFadeDur, info.QueueMode, info.PlayMode); else anim = animController.PlayQueued(id, info.QueueMode, info.PlayMode); - if (info.ApplyCustomSettings) info.Settings.Apply(anim); + if (info.SettingsMask != 0) info.Settings.Apply(anim, info.SettingsMask); return anim; } @@ -98,7 +98,7 @@ private object TryPlay(object controller, PlayAnimInfo info) anim.CrossFade(info.CrossFadeDur, info.QueueMode, info.PlayMode); else anim.Play(info.QueueMode, info.PlayMode); - if (info.ApplyCustomSettings) info.Settings.Apply(anim); + if (info.SettingsMask != 0) info.Settings.Apply(anim, info.SettingsMask); return anim; } return null; @@ -121,7 +121,7 @@ private object TryPlay(object controller, PlayAnimInfo info) anim = comp.CrossFadeQueued(info.Id, info.CrossFadeDur, info.QueueMode, info.PlayMode); else anim = comp.PlayQueued(info.Id, info.QueueMode, info.PlayMode); - if (info.ApplyCustomSettings) info.Settings.Apply(anim); + if (info.SettingsMask != 0) info.Settings.Apply(anim, info.SettingsMask); return anim; } return null; @@ -140,7 +140,7 @@ private object TryPlay(object controller, PlayAnimInfo info) anim.CrossFade(info.CrossFadeDur, info.QueueMode, info.PlayMode); else anim.Play(info.QueueMode, info.PlayMode); - if (info.ApplyCustomSettings) info.Settings.Apply(anim); + if (info.SettingsMask != 0) info.Settings.Apply(anim, info.SettingsMask); return anim; } return null; diff --git a/SPAnim/Anim/Legacy/SPLegacyAnimController.cs b/SPAnim/Anim/Legacy/SPLegacyAnimController.cs index 0433cb0..8a7fcb1 100644 --- a/SPAnim/Anim/Legacy/SPLegacyAnimController.cs +++ b/SPAnim/Anim/Legacy/SPLegacyAnimController.cs @@ -427,7 +427,27 @@ internal AnimationState PlayQueuedInternal(string clipId, QueueMode queueMode, P if (_animation == null) throw new AnimationInvalidAccessException(); if (!_initialized) this.Init(); - var anim = _animation.PlayQueued(clipId, queueMode, playMode); + //HACK - StopSameLayer respects the base state's layer rather than the layer as configured... + AnimationState result; + if (playMode == PlayMode.StopSameLayer) + { + var st = _animation[clipId]; + if (!object.ReferenceEquals(st, null) && st.layer != layer) + { + int cache = st.layer; + st.layer = layer; + result = _animation.PlayQueued(clipId, queueMode, playMode); + st.layer = cache; + } + else + { + result = _animation.PlayQueued(clipId, queueMode, playMode); + } + } + else + { + result = _animation.PlayQueued(clipId, queueMode, playMode); + } if (_scriptableAnims != null && _scriptableAnims.Count > 0) { @@ -441,7 +461,7 @@ internal AnimationState PlayQueuedInternal(string clipId, QueueMode queueMode, P } } - return anim; + return result; } internal AnimationState CrossFadeQueuedInternal(string clipId, float fadeLength, QueueMode queueMode, PlayMode playMode, int layer) diff --git a/SPAnim/Properties/AssemblyInfo.cs b/SPAnim/Properties/AssemblyInfo.cs deleted file mode 100644 index fe213ba..0000000 --- a/SPAnim/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPAnim")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPAnim")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("2e21b07e-0968-4f86-97fd-692397dbfc20")] diff --git a/SPAnim/SPAnim.csproj b/SPAnim/SPAnim.csproj index 8cce8ab..615f208 100644 --- a/SPAnim/SPAnim.csproj +++ b/SPAnim/SPAnim.csproj @@ -1,77 +1,27 @@  - - + - Debug - AnyCPU - {2E21B07E-0968-4F86-97FD-692397DBFC20} - Library - Properties + net35;net471 com.spacepuppy SPAnim - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - + - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - + - - \ No newline at end of file diff --git a/SPAnimEditor/Anim/Events/PlayAnimInfoPropertyDrawer.cs b/SPAnimEditor/Anim/Events/PlayAnimInfoPropertyDrawer.cs index 1caa71b..d4628b0 100644 --- a/SPAnimEditor/Anim/Events/PlayAnimInfoPropertyDrawer.cs +++ b/SPAnimEditor/Anim/Events/PlayAnimInfoPropertyDrawer.cs @@ -18,11 +18,12 @@ public class PlayAnimInfoPropertyDrawer : PropertyDrawer public const string PROP_MODE = "_mode"; public const string PROP_ID = "_id"; public const string PROP_CLIP = "_clip"; - public const string PROP_APPPLYSETTINGS = "ApplyCustomSettings"; + public const string PROP_SETTINGSMASK = "SettingsMask"; public const string PROP_SETTINGS = "Settings"; public const string PROP_QUEUEMODE = "QueueMode"; public const string PROP_PLAYMODE = "PlayMode"; public const string PROP_CROSSFADEDUR = "CrossFadeDur"; + private static string[] PROPS_ANIMSETTINGS = new string[] { "weight", "speed", "layer", "wrapMode", "blendMode", "timeSupplier" }; public bool DrawFlat; @@ -36,16 +37,13 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent if (controller is Animation || controller is SPLegacyAnimController) { float h = EditorGUIUtility.singleLineHeight * 6f; - var propApplySetting = property.FindPropertyRelative(PROP_APPPLYSETTINGS); - if (propApplySetting.boolValue) - { - var propSettings = property.FindPropertyRelative(PROP_SETTINGS); - propSettings.isExpanded = true; - h += SPEditorGUI.GetPropertyHeight(propSettings, EditorHelper.TempContent(propSettings.displayName), true); - } - else + + var propSettings = property.FindPropertyRelative(PROP_SETTINGS); + h += EditorGUIUtility.singleLineHeight; + int mask = property.FindPropertyRelative(PROP_SETTINGSMASK).intValue; + for (int i = 0; i < PROPS_ANIMSETTINGS.Length; i++) { - h += EditorGUIUtility.singleLineHeight; + if (propSettings.isExpanded || (mask & (1 << i)) != 0) h += EditorGUIUtility.singleLineHeight; } return h; @@ -59,16 +57,12 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent float h = EditorGUIUtility.singleLineHeight * 5f; if (!this.DrawFlat) h += EditorGUIUtility.singleLineHeight; - var propApplySetting = property.FindPropertyRelative(PROP_APPPLYSETTINGS); - if (propApplySetting.boolValue) - { - var propSettings = property.FindPropertyRelative(PROP_SETTINGS); - propSettings.isExpanded = true; - h += SPEditorGUI.GetPropertyHeight(propSettings, EditorHelper.TempContent(propSettings.displayName), true); - } - else + var propSettings = property.FindPropertyRelative(PROP_SETTINGS); + h += EditorGUIUtility.singleLineHeight; + int mask = property.FindPropertyRelative(PROP_SETTINGSMASK).intValue; + for (int i = 0; i < PROPS_ANIMSETTINGS.Length; i++) { - h += EditorGUIUtility.singleLineHeight; + if (propSettings.isExpanded || (mask & (1 << i)) != 0) h += EditorGUIUtility.singleLineHeight; } return h; @@ -85,16 +79,12 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent float h = EditorGUIUtility.singleLineHeight * 6f; if (!this.DrawFlat) h += EditorGUIUtility.singleLineHeight; - var propApplySetting = property.FindPropertyRelative(PROP_APPPLYSETTINGS); - if (propApplySetting.boolValue) - { - var propSettings = property.FindPropertyRelative(PROP_SETTINGS); - propSettings.isExpanded = true; - h += SPEditorGUI.GetPropertyHeight(propSettings, EditorHelper.TempContent(propSettings.displayName), true); - } - else + var propSettings = property.FindPropertyRelative(PROP_SETTINGS); + h += EditorGUIUtility.singleLineHeight; + int mask = property.FindPropertyRelative(PROP_SETTINGSMASK).intValue; + for (int i = 0; i < PROPS_ANIMSETTINGS.Length; i++) { - h += EditorGUIUtility.singleLineHeight; + if (propSettings.isExpanded || (mask & (1 << i)) != 0) h += EditorGUIUtility.singleLineHeight; } return h; @@ -221,16 +211,40 @@ private void DrawGenerically(Rect position, SerializedProperty property, GUICont private void DrawSettings(Rect position, SerializedProperty property) { - var r3a = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight); - var propApplySettings = property.FindPropertyRelative(PROP_APPPLYSETTINGS); - SPEditorGUI.PropertyField(r3a, propApplySettings); - if (propApplySettings.boolValue) + var propMask = property.FindPropertyRelative(PROP_SETTINGSMASK); + var propSettings = property.FindPropertyRelative(PROP_SETTINGS); + + int mask = propMask.intValue; + + var r1 = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight); + propSettings.isExpanded = EditorGUI.Foldout(r1, propSettings.isExpanded, mask != 0 ? "Custom Settings : Active" : "Custom Settings"); + + EditorGUI.BeginChangeCheck(); + int row = 0; + for (int i = 0; i < PROPS_ANIMSETTINGS.Length; i++) { - var r3b = new Rect(position.xMin, r3a.yMax, position.width, position.height - EditorGUIUtility.singleLineHeight); - EditorGUI.indentLevel++; - SPEditorGUI.FlatChildPropertyField(r3b, property.FindPropertyRelative(PROP_SETTINGS)); - EditorGUI.indentLevel--; + int m = 1 << i; + bool active = (mask & m) != 0; + if (!propSettings.isExpanded && !active) continue; + + var propSet = propSettings.FindPropertyRelative(PROPS_ANIMSETTINGS[i]); + var r2 = new Rect(position.xMin, r1.yMax + row * EditorGUIUtility.singleLineHeight, position.width, EditorGUIUtility.singleLineHeight); + var r2a = new Rect(r2.xMin, r2.yMin, 30f, r2.height); + var r2b = new Rect(r2a.xMax, r2.yMin, r2.width - r2a.width, r2.height); + if(EditorGUI.Toggle(r2a, active)) + { + mask |= m; + EditorGUI.PropertyField(r2b, propSet); + } + else + { + mask &= ~m; + EditorGUI.PrefixLabel(r2b, EditorHelper.TempContent(propSet.displayName, propSet.tooltip)); + } + row++; } + if (EditorGUI.EndChangeCheck()) + propMask.intValue = mask; } } diff --git a/SPAnimEditor/Anim/Events/i_PlayAnimationInspector.cs b/SPAnimEditor/Anim/Events/i_PlayAnimationInspector.cs index d344a19..2cbde20 100644 --- a/SPAnimEditor/Anim/Events/i_PlayAnimationInspector.cs +++ b/SPAnimEditor/Anim/Events/i_PlayAnimationInspector.cs @@ -24,11 +24,12 @@ public class i_PlayAnimationInspector : SPEditor public const string PROP_TARGETANIMATOR = "_targetAnimator"; public const string PROP_ID = "_id"; public const string PROP_CLIP = "_clip"; - public const string PROP_APPLYSETTINGS = "_applyCustomSettings"; + public const string PROP_SETTINGSMASK = "_settingsMask"; public const string PROP_SETTINGS = "_settings"; public const string PROP_QUEUEMODE = "_queueMode"; public const string PROP_PLAYMODE = "_playMode"; public const string PROP_CROSSFADEDUR = "_crossFadeDur"; + private static string[] PROPS_ANIMSETTINGS = new string[] { "weight", "speed", "layer", "wrapMode", "blendMode", "timeSupplier" }; private TriggerableTargetObjectPropertyDrawer _targetDrawer = new TriggerableTargetObjectPropertyDrawer() { @@ -109,7 +110,7 @@ protected override void OnSPInspectorGUI() this.DrawPropertyField(PROP_CROSSFADEDUR); } - this.DrawDefaultInspectorExcept(EditorHelper.PROP_SCRIPT, PROP_ORDER, PROP_ACTIVATEON, PROP_MODE, PROP_TARGETANIMATOR, PROP_ID, PROP_CLIP, PROP_APPLYSETTINGS, PROP_SETTINGS, PROP_QUEUEMODE, PROP_PLAYMODE, PROP_CROSSFADEDUR); + this.DrawDefaultInspectorExcept(EditorHelper.PROP_SCRIPT, PROP_ORDER, PROP_ACTIVATEON, PROP_MODE, PROP_TARGETANIMATOR, PROP_ID, PROP_CLIP, PROP_SETTINGSMASK, PROP_SETTINGS, PROP_QUEUEMODE, PROP_PLAYMODE, PROP_CROSSFADEDUR); this.serializedObject.ApplyModifiedProperties(); } @@ -155,15 +156,36 @@ private void DrawTargetAnimatorProperty() private void DrawAnimSettings() { - var propApply = this.serializedObject.FindProperty(PROP_APPLYSETTINGS); - SPEditorGUILayout.PropertyField(propApply); - if (propApply.boolValue) + var propMask = this.serializedObject.FindProperty(PROP_SETTINGSMASK); + var propSettings = this.serializedObject.FindProperty(PROP_SETTINGS); + + int mask = propMask.intValue; + propSettings.isExpanded = EditorGUILayout.Foldout(propSettings.isExpanded, mask != 0 ? "Custom Settings : Active" : "Custom Settings"); + + EditorGUI.BeginChangeCheck(); + for (int i = 0; i < PROPS_ANIMSETTINGS.Length; i++) { - //this.DrawPropertyField(PROP_SETTINGS); - EditorGUI.indentLevel++; - SPEditorGUILayout.FlatChildPropertyField(this.serializedObject.FindProperty(PROP_SETTINGS)); - EditorGUI.indentLevel--; + int m = 1 << i; + bool active = (mask & m) != 0; + if (!propSettings.isExpanded && !active) continue; + + var propSet = propSettings.FindPropertyRelative(PROPS_ANIMSETTINGS[i]); + EditorGUILayout.BeginHorizontal(); + if (EditorGUILayout.Toggle(active, GUILayout.MaxWidth(20f))) + { + mask |= m; + EditorGUILayout.PropertyField(propSet); + } + else + { + mask &= ~m; + EditorGUILayout.PrefixLabel(EditorHelper.TempContent(propSet.displayName, propSet.tooltip)); + } + + EditorGUILayout.EndHorizontal(); } + if (EditorGUI.EndChangeCheck()) + propMask.intValue = mask; } private void DrawAnimIdSelector(object animator) diff --git a/SPAnimEditor/Anim/Events/i_PlayRandomAnimationInspector.cs b/SPAnimEditor/Anim/Events/i_PlayRandomAnimationInspector.cs index 1c2ae43..116994c 100644 --- a/SPAnimEditor/Anim/Events/i_PlayRandomAnimationInspector.cs +++ b/SPAnimEditor/Anim/Events/i_PlayRandomAnimationInspector.cs @@ -29,7 +29,7 @@ public class i_PlayRandomAnimationInspector : SPEditor public const string PROP_CLIP_MODE = "_mode"; public const string PROP_CLIP_ID = "_id"; public const string PROP_CLIP_CLIP = "_clip"; - public const string PROP_CLIP_APPPLYSETTINGS = "ApplyCustomSettings"; + public const string PROP_CLIP_SETTINGSMASK= "SettingsMask"; public const string PROP_CLIP_SETTINGS = "Settings"; public const string PROP_CLIP_QUEUEMODE = "QueueMode"; public const string PROP_CLIP_PLAYMODE = "PlayMode"; diff --git a/SPAnimEditor/Properties/AssemblyInfo.cs b/SPAnimEditor/Properties/AssemblyInfo.cs deleted file mode 100644 index 995be16..0000000 --- a/SPAnimEditor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPAnimEditor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPAnimEditor")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("da26b8bd-bb04-49da-88a1-c59178282858")] diff --git a/SPAnimEditor/SPAnimEditor.csproj b/SPAnimEditor/SPAnimEditor.csproj index c567744..4dd06f3 100644 --- a/SPAnimEditor/SPAnimEditor.csproj +++ b/SPAnimEditor/SPAnimEditor.csproj @@ -1,77 +1,35 @@  - - + - Debug - AnyCPU - {DA26B8BD-BB04-49DA-88A1-C59178282858} - Library - Properties + net35;net471 com.spacepuppyeditor SPAnimEditor - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEditor.dll + + ..\Resources\UnityEditor.Graphs.dll + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - - - - - - - - - - + - - {7fe0b8d6-ba29-43a6-b272-5d4f442fc4fa} - SpacepuppyUnityFrameworkEditor - - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - - - {2e21b07e-0968-4f86-97fd-692397dbfc20} - SPAnim - + + + - - \ No newline at end of file diff --git a/SPCamera/Properties/AssemblyInfo.cs b/SPCamera/Properties/AssemblyInfo.cs deleted file mode 100644 index 3bb3696..0000000 --- a/SPCamera/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPCamera")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPCamera")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("72334fdb-e3cd-4f17-9680-44d5c7f5e380")] diff --git a/SPCamera/SPCamera.csproj b/SPCamera/SPCamera.csproj index 9571202..54961d2 100644 --- a/SPCamera/SPCamera.csproj +++ b/SPCamera/SPCamera.csproj @@ -1,67 +1,27 @@  - - + - Debug - AnyCPU - {72334FDB-E3CD-4F17-9680-44D5C7F5E380} - Library - Properties + net35;net471 com.spacepuppy SPCamera - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - - - - - - - - - - - + - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - + - - \ No newline at end of file diff --git a/SPInput/Properties/AssemblyInfo.cs b/SPInput/Properties/AssemblyInfo.cs deleted file mode 100644 index 52bc0eb..0000000 --- a/SPInput/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPInput")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPInput")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("e61eea45-ea08-4ba4-86f6-b748dd047b6d")] diff --git a/SPInput/SPInput.csproj b/SPInput/SPInput.csproj index 6898c94..0145eef 100644 --- a/SPInput/SPInput.csproj +++ b/SPInput/SPInput.csproj @@ -1,40 +1,16 @@  - - + - Debug - AnyCPU - {E61EEA45-EA08-4BA4-86F6-B748DD047B6D} - Library - Properties + net35;net471 com.spacepuppy SPInput - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEngine.dll @@ -43,101 +19,9 @@ - - Properties\AssemblyVersionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - + - + - \ No newline at end of file diff --git a/SPInputEditor/Properties/AssemblyInfo.cs b/SPInputEditor/Properties/AssemblyInfo.cs deleted file mode 100644 index 9a44a02..0000000 --- a/SPInputEditor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPInputEditor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPInputEditor")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("b511b71c-2573-4209-ae41-6b0fecde10a4")] diff --git a/SPInputEditor/SPInput/Events/t_OnSimpleButtonPressInspector.cs b/SPInputEditor/SPInput/Events/t_OnSimpleButtonPressInspector.cs index 07cc932..4b38e26 100644 --- a/SPInputEditor/SPInput/Events/t_OnSimpleButtonPressInspector.cs +++ b/SPInputEditor/SPInput/Events/t_OnSimpleButtonPressInspector.cs @@ -5,6 +5,8 @@ using com.spacepuppy.Events; using com.spacepuppy.SPInput.Events; +using com.spacepuppyeditor.Settings; + namespace com.spacepuppyeditor.SPInput.Events { @@ -20,7 +22,7 @@ protected override void OnEnable() { base.OnEnable(); - _inputIds = com.spacepuppyeditor.Windows.AdvancedInputManagerWindow.GetAllAvailableInputs(); + _inputIds = InputSettings.GetGlobalInputIds(); } protected override void OnSPInspectorGUI() diff --git a/SPInputEditor/SPInputEditor.csproj b/SPInputEditor/SPInputEditor.csproj index 0c5ea37..2abeb8c 100644 --- a/SPInputEditor/SPInputEditor.csproj +++ b/SPInputEditor/SPInputEditor.csproj @@ -1,67 +1,35 @@  - - + - Debug - AnyCPU - {B511B71C-2573-4209-AE41-6B0FECDE10A4} - Library - Properties + net35;net471 com.spacepuppyeditor SPInputEditor - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEditor.dll + + ..\Resources\UnityEditor.Graphs.dll + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - + - - {7fe0b8d6-ba29-43a6-b272-5d4f442fc4fa} - SpacepuppyUnityFrameworkEditor - - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - - - {e61eea45-ea08-4ba4-86f6-b748dd047b6d} - SPInput - + + + - \ No newline at end of file diff --git a/SPMotor/Properties/AssemblyInfo.cs b/SPMotor/Properties/AssemblyInfo.cs deleted file mode 100644 index 99bf71e..0000000 --- a/SPMotor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPMotor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPMotor")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("05b56b56-292e-43b4-b3d3-c20403edde3e")] diff --git a/SPMotor/SPMotor.csproj b/SPMotor/SPMotor.csproj index bf8441d..429941d 100644 --- a/SPMotor/SPMotor.csproj +++ b/SPMotor/SPMotor.csproj @@ -1,64 +1,27 @@  - - + - Debug - AnyCPU - {05B56B56-292E-43B4-B3D3-C20403EDDE3E} - Library - Properties + net35;net471 com.spacepuppy SPMotor - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - - - - - - - - + - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - + - - \ No newline at end of file diff --git a/SPMotorEditor/Properties/AssemblyInfo.cs b/SPMotorEditor/Properties/AssemblyInfo.cs deleted file mode 100644 index 2553949..0000000 --- a/SPMotorEditor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPMotorEditor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPMotorEditor")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("c46b38ac-b4ca-45cb-8b2e-1e520550e8fc")] diff --git a/SPMotorEditor/SPMotorEditor.csproj b/SPMotorEditor/SPMotorEditor.csproj index a12bd03..a930950 100644 --- a/SPMotorEditor/SPMotorEditor.csproj +++ b/SPMotorEditor/SPMotorEditor.csproj @@ -1,67 +1,35 @@  - - + - Debug - AnyCPU - {C46B38AC-B4CA-45CB-8B2E-1E520550E8FC} - Library - Properties + net35;net471 com.spacepuppyeditor SPMotorEditor - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEditor.dll + + ..\Resources\UnityEditor.Graphs.dll + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - + - - {7fe0b8d6-ba29-43a6-b272-5d4f442fc4fa} - SpacepuppyUnityFrameworkEditor - - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - - - {05b56b56-292e-43b4-b3d3-c20403edde3e} - SPMotor - + + + - \ No newline at end of file diff --git a/SPPathfinding/Properties/AssemblyInfo.cs b/SPPathfinding/Properties/AssemblyInfo.cs deleted file mode 100644 index c8d8249..0000000 --- a/SPPathfinding/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPPathfinding")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPPathfinding")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("c71bc39f-71c7-4f5c-9f37-ae1c356c160b")] diff --git a/SPPathfinding/SPPathfinding.csproj b/SPPathfinding/SPPathfinding.csproj index 3076ec3..7c223d4 100644 --- a/SPPathfinding/SPPathfinding.csproj +++ b/SPPathfinding/SPPathfinding.csproj @@ -1,77 +1,27 @@  - - + - Debug - AnyCPU - {C71BC39F-71C7-4F5C-9F37-AE1C356C160B} - Library - Properties + net35;net471 com.spacepuppy SPPathfinding - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - + - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - + - \ No newline at end of file diff --git a/SPProject/Properties/AssemblyInfo.cs b/SPProject/Properties/AssemblyInfo.cs deleted file mode 100644 index c449703..0000000 --- a/SPProject/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPProject")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPProject")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("3efa3aa0-2f60-4876-93d7-9ba2e806f2de")] diff --git a/SPProject/SPProject.csproj b/SPProject/SPProject.csproj index 4a52d8d..fa3bcdf 100644 --- a/SPProject/SPProject.csproj +++ b/SPProject/SPProject.csproj @@ -1,62 +1,27 @@  - - + - Debug - AnyCPU - {3EFA3AA0-2F60-4876-93D7-9BA2E806F2DE} - Library - Properties + net35;net471 com.spacepuppy SPProject - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - - - - - - - + - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - + - \ No newline at end of file diff --git a/SPProjectEditor/Properties/AssemblyInfo.cs b/SPProjectEditor/Properties/AssemblyInfo.cs deleted file mode 100644 index 5d4466a..0000000 --- a/SPProjectEditor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPProjectEditor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPProjectEditor")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("21a1f01a-7f94-4074-a794-8c265d9ecca1")] diff --git a/SPProjectEditor/SPProjectEditor.csproj b/SPProjectEditor/SPProjectEditor.csproj index 20e165e..0582035 100644 --- a/SPProjectEditor/SPProjectEditor.csproj +++ b/SPProjectEditor/SPProjectEditor.csproj @@ -1,68 +1,35 @@  - - + - Debug - AnyCPU - {21A1F01A-7F94-4074-A794-8C265D9ECCA1} - Library - Properties + net35;net471 com.spacepuppyeditor SPProjectEditor - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEditor.dll + + ..\Resources\UnityEditor.Graphs.dll + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - - + - - {7fe0b8d6-ba29-43a6-b272-5d4f442fc4fa} - SpacepuppyUnityFrameworkEditor - - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - - - {3efa3aa0-2f60-4876-93d7-9ba2e806f2de} - SPProject - + + + - \ No newline at end of file diff --git a/SPScenes/Properties/AssemblyInfo.cs b/SPScenes/Properties/AssemblyInfo.cs deleted file mode 100644 index 4f74fba..0000000 --- a/SPScenes/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPScenes")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPScenes")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("3f77727e-5170-44a4-a3fa-3df77de6e2eb")] diff --git a/SPScenes/SPScenes.csproj b/SPScenes/SPScenes.csproj index 3ba7f85..6e9aeaf 100644 --- a/SPScenes/SPScenes.csproj +++ b/SPScenes/SPScenes.csproj @@ -1,64 +1,27 @@  - - + - Debug - AnyCPU - {3F77727E-5170-44A4-A3FA-3DF77DE6E2EB} - Library - Properties + net35;net471 com.spacepuppy SPScenes - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - - - - - - - - - + - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - + - \ No newline at end of file diff --git a/SPScenesEditor/Properties/AssemblyInfo.cs b/SPScenesEditor/Properties/AssemblyInfo.cs deleted file mode 100644 index b3869a8..0000000 --- a/SPScenesEditor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPScenesEditor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPScenesEditor")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("a8267310-ca39-4d9b-9a6a-a29b7d4dd970")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SPScenesEditor/SPScenesEditor.csproj b/SPScenesEditor/SPScenesEditor.csproj index 9662457..9ed4afc 100644 --- a/SPScenesEditor/SPScenesEditor.csproj +++ b/SPScenesEditor/SPScenesEditor.csproj @@ -1,64 +1,35 @@  - - + - Debug - AnyCPU - {A8267310-CA39-4D9B-9A6A-A29B7D4DD970} - Library - Properties - SPScenesEditor + net35;net471 + com.spacepuppyeditor SPScenesEditor - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEditor.dll + + ..\Resources\UnityEditor.Graphs.dll + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - + - - {7fe0b8d6-ba29-43a6-b272-5d4f442fc4fa} - SpacepuppyUnityFrameworkEditor - - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - - - {3f77727e-5170-44a4-a3fa-3df77de6e2eb} - SPScenes - + + + - \ No newline at end of file diff --git a/SPSensors/Properties/AssemblyInfo.cs b/SPSensors/Properties/AssemblyInfo.cs deleted file mode 100644 index 1b87974..0000000 --- a/SPSensors/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPSensors")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPSensors")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("ed3516f9-ebcf-44fc-9ed4-6f932625f2d3")] diff --git a/SPSensors/SPSensors.csproj b/SPSensors/SPSensors.csproj index de0c62c..8c24801 100644 --- a/SPSensors/SPSensors.csproj +++ b/SPSensors/SPSensors.csproj @@ -1,70 +1,27 @@  - - + - Debug - AnyCPU - {ED3516F9-EBCF-44FC-9ED4-6F932625F2D3} - Library - Properties + net35;net471 com.spacepuppy SPSensors - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - - - - - - - - - - - - - - + - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - + - - \ No newline at end of file diff --git a/SPSensors/Sensors/Visual/RightCylindricalVisualSensor.cs b/SPSensors/Sensors/Visual/RightCylindricalVisualSensor.cs index 5ad0c5d..a6affba 100644 --- a/SPSensors/Sensors/Visual/RightCylindricalVisualSensor.cs +++ b/SPSensors/Sensors/Visual/RightCylindricalVisualSensor.cs @@ -107,32 +107,49 @@ protected override bool TestVisibility(VisualAspect aspect) var center = this.GetCenterInWorldSpace(); var otherPos = aspect.transform.position; - if (!Cylinder.ContainsPoint(center - (rod * halfHeight), - center + (rod * halfHeight), - _radius, - _innerRadius, - otherPos)) + float aspRad = aspect.Radius; + if (aspRad > MathUtil.EPSILON) { - return false; - } + if (!Cylinder.ContainsSphere(center - (rod * halfHeight), + center + (rod * halfHeight), + _radius, + _innerRadius, + otherPos, + aspRad)) + { + return false; + } - if(this._angle < 360.0f) + if (this._angle < 360.0f) + { + var v = VectorUtil.SetLengthOnAxis(otherPos - center, rod, 0f); + var a = Vector3.Angle(this.transform.forward, v); + float k = 2f * Mathf.Asin(aspRad / (Mathf.Sqrt(v.sqrMagnitude + (aspRad * aspRad) / 4f))) * Mathf.Rad2Deg; + if (a > (_angle / 2.0f) - k) return false; + } + } + else { - var v = VectorUtil.SetLengthOnAxis(otherPos - center, rod, 0f); - var a = Vector3.Angle(this.transform.forward, v); - if (a > this._angle / 2.0f) return false; + if (!Cylinder.ContainsPoint(center - (rod * halfHeight), + center + (rod * halfHeight), + _radius, + _innerRadius, + otherPos)) + { + return false; + } + + if (this._angle < 360.0f) + { + var v = VectorUtil.SetLengthOnAxis(otherPos - center, rod, 0f); + var a = Vector3.Angle(this.transform.forward, v); + if (a > this._angle / 2.0f) return false; + } } if (this.RequiresLineOfSight) { var v = otherPos - center; - //RaycastHit[] hits = Physics.RaycastAll(this.transform.position, v, v.magnitude, this.LineOfSightMask); - //foreach (var hit in hits) - //{ - // //we ignore ourself - // var r = hit.collider.FindRoot(); - // if (r != aspect.entityRoot && r != this.entityRoot) return false; - //} using (var lst = com.spacepuppy.Collections.TempCollection.GetList()) { int cnt = PhysicsUtil.RaycastAll(this.transform.position, v, lst, v.magnitude, this.LineOfSightMask); diff --git a/SPSensors/Sensors/Visual/SphericalVisualSensor.cs b/SPSensors/Sensors/Visual/SphericalVisualSensor.cs index 48c0f68..743f1a2 100644 --- a/SPSensors/Sensors/Visual/SphericalVisualSensor.cs +++ b/SPSensors/Sensors/Visual/SphericalVisualSensor.cs @@ -74,42 +74,47 @@ public override BoundingSphere GetBoundingSphere() protected override bool TestVisibility(VisualAspect aspect) { - var sqrRadius = _radius * _radius; - var v = aspect.transform.position - this.transform.position; - if (v.sqrMagnitude > sqrRadius) return false; - if (this._innerRadius > 0f && v.sqrMagnitude < this._innerRadius * this._innerRadius) return false; + float aspRad = aspect.Radius; + float sqrRadius = _radius * _radius; + Vector3 v = aspect.transform.position - this.transform.position; + float sqrDist = v.sqrMagnitude; - if(this._horizontalAngle != 360.0f && this._verticalAngle != 360.0f) + if (sqrDist - (aspRad * aspRad) > sqrRadius) return false; + if (this._innerRadius > aspRad && sqrDist < this._innerRadius * this._innerRadius) return false; + + if (this._horizontalAngle < 360.0f && this._verticalAngle < 360.0f) { Vector3 directionOfAspectInLocalSpace = this.transform.InverseTransformDirection(v); //Quaternion.Inverse(this.transform.rotation) * v; - //var lookAtAngles = (VectorUtil.NearZeroVector(directionOfAspectInLocalSpace)) ? Vector3.zero : Quaternion.LookRotation(directionOfAspectInLocalSpace).eulerAngles; - //if (Mathf.Abs(lookAtAngles.y * 2.0f) > this._horizontalAngle) - // return false; - //else if (Mathf.Abs(lookAtAngles.x * 2.0f) > this._verticalAngle) - // return false; - float a; - a = VectorUtil.AngleBetween(new Vector2(1f, 0f), new Vector2(directionOfAspectInLocalSpace.z, directionOfAspectInLocalSpace.x)); - if (a > this._horizontalAngle / 2f) - return false; - a = VectorUtil.AngleBetween(new Vector2(1f, 0f), new Vector2(directionOfAspectInLocalSpace.z, directionOfAspectInLocalSpace.y)); - if (a > this._verticalAngle / 2f) - return false; + if (aspRad > MathUtil.EPSILON) + { + float k = 2f * Mathf.Asin(aspRad / (Mathf.Sqrt(sqrDist + (aspRad * aspRad) / 4f))) * Mathf.Rad2Deg; + a = VectorUtil.AngleBetween(new Vector2(1f, 0f), new Vector2(directionOfAspectInLocalSpace.z, directionOfAspectInLocalSpace.x)); + + if (a > (this._horizontalAngle / 2f) - k) + return false; + a = VectorUtil.AngleBetween(new Vector2(1f, 0f), new Vector2(directionOfAspectInLocalSpace.z, directionOfAspectInLocalSpace.y)); + if (a > (this._verticalAngle / 2f) - k) + return false; + } + else + { + a = VectorUtil.AngleBetween(new Vector2(1f, 0f), new Vector2(directionOfAspectInLocalSpace.z, directionOfAspectInLocalSpace.x)); + if (a > this._horizontalAngle / 2f) + return false; + a = VectorUtil.AngleBetween(new Vector2(1f, 0f), new Vector2(directionOfAspectInLocalSpace.z, directionOfAspectInLocalSpace.y)); + if (a > this._verticalAngle / 2f) + return false; + } + } - if(this.RequiresLineOfSight) + if (this.RequiresLineOfSight) { - //RaycastHit[] hits = Physics.RaycastAll(this.transform.position, v, v.magnitude, this.LineOfSightMask); - //foreach(var hit in hits) - //{ - // //we ignore ourself - // var r = hit.collider.FindRoot(); - // if (r != aspect.entityRoot && r != this.entityRoot) return false; - //} using (var lst = com.spacepuppy.Collections.TempCollection.GetList()) { int cnt = PhysicsUtil.RaycastAll(this.transform.position, v, lst, v.magnitude, this.LineOfSightMask); - for(int i = 0; i < cnt; i++) + for (int i = 0; i < cnt; i++) { //we ignore ourself var r = lst[i].collider.FindRoot(); diff --git a/SPSensors/Sensors/Visual/TunnelVisionVisualSensor.cs b/SPSensors/Sensors/Visual/TunnelVisionVisualSensor.cs index fd0ecf4..233666c 100644 --- a/SPSensors/Sensors/Visual/TunnelVisionVisualSensor.cs +++ b/SPSensors/Sensors/Visual/TunnelVisionVisualSensor.cs @@ -67,13 +67,29 @@ public override BoundingSphere GetBoundingSphere() protected override bool TestVisibility(VisualAspect aspect) { //if not in cylinder, can not see it - if (!Cone.ContainsPoint(this.transform.position, + float aspRad = aspect.Radius; + if (aspRad > MathUtil.EPSILON) + { + if (!Cone.ContainsSphere(this.transform.position, this.transform.position + this.Direction * _range, _startRadius, _endRadius, - aspect.transform.position)) + aspect.transform.position, + aspRad)) + { + return false; + } + } + else { - return false; + if (!Cone.ContainsPoint(this.transform.position, + this.transform.position + this.Direction * _range, + _startRadius, + _endRadius, + aspect.transform.position)) + { + return false; + } } if (this.RequiresLineOfSight) diff --git a/SPSensors/Sensors/Visual/VisualAspect.cs b/SPSensors/Sensors/Visual/VisualAspect.cs index 72252df..60e8c06 100644 --- a/SPSensors/Sensors/Visual/VisualAspect.cs +++ b/SPSensors/Sensors/Visual/VisualAspect.cs @@ -127,6 +127,10 @@ private void DecategorizeAspect() [SerializeField()] private float _precedence; + [SerializeField] + [MinRange(0f)] + private float _radius; + [SerializeField()] private Color _aspectColor = Color.blue; @@ -160,6 +164,12 @@ protected override void OnDisable() #region Properties + public float Radius + { + get { return _radius; } + set { _radius = value = Mathf.Max(0f, value); } + } + public bool OmniPresent { get { return _omniPresent; } diff --git a/SPSensorsEditor/Properties/AssemblyInfo.cs b/SPSensorsEditor/Properties/AssemblyInfo.cs deleted file mode 100644 index 1214b37..0000000 --- a/SPSensorsEditor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPSensorsEditor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPSensorsEditor")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("19fe4e4f-d5a6-4255-b222-2b0cbf61e7b6")] diff --git a/SPSensorsEditor/SPSensorsEditor.csproj b/SPSensorsEditor/SPSensorsEditor.csproj index 5c19c06..fdbc6be 100644 --- a/SPSensorsEditor/SPSensorsEditor.csproj +++ b/SPSensorsEditor/SPSensorsEditor.csproj @@ -1,72 +1,35 @@  - - + - Debug - AnyCPU - {19FE4E4F-D5A6-4255-B222-2B0CBF61E7B6} - Library - Properties + net35;net471 com.spacepuppyeditor SPSensorsEditor - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEditor.dll + + ..\Resources\UnityEditor.Graphs.dll + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - - - - - - + - - {7fe0b8d6-ba29-43a6-b272-5d4f442fc4fa} - SpacepuppyUnityFrameworkEditor - - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - - - {ed3516f9-ebcf-44fc-9ed4-6f932625f2d3} - SPSensors - + + + - \ No newline at end of file diff --git a/SPSensorsEditor/Sensors/Visual/VisualAspectInspector.cs b/SPSensorsEditor/Sensors/Visual/VisualAspectInspector.cs index dfc6090..593fbfb 100644 --- a/SPSensorsEditor/Sensors/Visual/VisualAspectInspector.cs +++ b/SPSensorsEditor/Sensors/Visual/VisualAspectInspector.cs @@ -65,6 +65,16 @@ private static void DrawIcon(VisualAspect targ) } } + [DrawGizmo(GizmoType.Selected | GizmoType.InSelectionHierarchy | GizmoType.Active)] + private static void DrawSphereGizmo(VisualAspect aspect, GizmoType gizmoType) + { + if (aspect.Radius > 0f) + { + Gizmos.color = aspect.AspectColor; + Gizmos.DrawWireSphere(aspect.transform.position, aspect.Radius); + } + } + /* * Obsolete method diff --git a/SPSerialization/Properties/AssemblyInfo.cs b/SPSerialization/Properties/AssemblyInfo.cs deleted file mode 100644 index 2140df4..0000000 --- a/SPSerialization/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPSerialization")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPSerialization")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("f6049e27-3b8a-4702-9334-cfeb49fe6e91")] diff --git a/SPSerialization/SPSerialization.csproj b/SPSerialization/SPSerialization.csproj index cfa7379..48c56ff 100644 --- a/SPSerialization/SPSerialization.csproj +++ b/SPSerialization/SPSerialization.csproj @@ -1,68 +1,27 @@  - - + - Debug - AnyCPU - {F6049E27-3B8A-4702-9334-CFEB49FE6E91} - Library - Properties + net35;net471 com.spacepuppy SPSerialization - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - - - - - - - - - - - - + - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - + - - \ No newline at end of file diff --git a/SPSerializationEditor/Properties/AssemblyInfo.cs b/SPSerializationEditor/Properties/AssemblyInfo.cs deleted file mode 100644 index 6283a40..0000000 --- a/SPSerializationEditor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPSerializationEditor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPSerializationEditor")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("cc2654d4-df57-4690-b9d4-daf95903b9bd")] diff --git a/SPSerializationEditor/SPSerializationEditor.csproj b/SPSerializationEditor/SPSerializationEditor.csproj index 329d53a..a5b2742 100644 --- a/SPSerializationEditor/SPSerializationEditor.csproj +++ b/SPSerializationEditor/SPSerializationEditor.csproj @@ -1,67 +1,35 @@  - - + - Debug - AnyCPU - {CC2654D4-DF57-4690-B9D4-DAF95903B9BD} - Library - Properties + net35;net471 com.spacepuppyeditor SPSerializationEditor - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEditor.dll + + ..\Resources\UnityEditor.Graphs.dll + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - + - - {7fe0b8d6-ba29-43a6-b272-5d4f442fc4fa} - SpacepuppyUnityFrameworkEditor - - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - - - {f6049e27-3b8a-4702-9334-cfeb49fe6e91} - SPSerialization - + + + - \ No newline at end of file diff --git a/SPSpawn/Properties/AssemblyInfo.cs b/SPSpawn/Properties/AssemblyInfo.cs deleted file mode 100644 index 55412df..0000000 --- a/SPSpawn/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPSpawn")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPSpawn")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("74edaa76-51a6-4b3c-bb72-de9eb40b93c9")] diff --git a/SPSpawn/SPSpawn.csproj b/SPSpawn/SPSpawn.csproj index 29e7f74..dccb9c2 100644 --- a/SPSpawn/SPSpawn.csproj +++ b/SPSpawn/SPSpawn.csproj @@ -1,69 +1,27 @@  - - + - Debug - AnyCPU - {74EDAA76-51A6-4B3C-BB72-DE9EB40B93C9} - Library - Properties + net35;net471 com.spacepuppy SPSpawn - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - - - - - - - - - - - - - - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - + - + - \ No newline at end of file diff --git a/SPSpawn/Spawn/Events/i_SpawnParticleEffect.cs b/SPSpawn/Spawn/Events/i_SpawnParticleEffect.cs index c7038f2..7c2b5aa 100644 --- a/SPSpawn/Spawn/Events/i_SpawnParticleEffect.cs +++ b/SPSpawn/Spawn/Events/i_SpawnParticleEffect.cs @@ -99,9 +99,11 @@ private GameObject Spawn(PrefabEntry entry) var go = pool.Spawn(entry.Prefab.gameObject, this.transform.position, this.transform.rotation, _spawnedObjectParent); var dur = (entry.Duration > 0f) ? entry.Duration : entry.Prefab.main.duration; - if (!float.IsNaN(dur) && !float.IsInfinity(dur)) + var timeSupplier = (entry.Prefab.main.useUnscaledTime) ? SPTime.Real : SPTime.Normal; + if (!float.IsNaN(dur) && !float.IsInfinity(dur) && dur >= 0f) { - this.InvokeGuaranteed(() => go.Kill(), dur); + this.InvokeGuaranteed(() => go.Kill(), dur, + entry.Prefab.main.useUnscaledTime ? SPTime.Real : SPTime.Normal); } if (_onSpawnedObject != null && _onSpawnedObject.Count > 0) diff --git a/SPSpawn/Spawn/SpawnPool.cs b/SPSpawn/Spawn/SpawnPool.cs index 906319c..1b9ca1f 100644 --- a/SPSpawn/Spawn/SpawnPool.cs +++ b/SPSpawn/Spawn/SpawnPool.cs @@ -444,10 +444,11 @@ private PrefabCache FindPrefabCache(GameObject obj) if (_prefabToCache.ContainsKey(id)) return _prefabToCache[id]; var controller = obj.FindComponent(); - if (controller == null && controller.Pool != this) return null; + if (controller == null || controller.Pool != this) return null; id = controller.PrefabID; - if (_prefabToCache.ContainsKey(id)) return _prefabToCache[id]; + PrefabCache result; + if (_prefabToCache.TryGetValue(id, out result)) return result; return null; } @@ -552,18 +553,26 @@ private class PrefabCache : IPrefabCache [System.NonSerialized()] private SpawnPool _owner; [System.NonSerialized()] - private HashSet _instances = new HashSet(ObjectReferenceEqualityComparer.Default); + private HashSet _instances; [System.NonSerialized()] - private HashSet _activeInstances = new HashSet(ObjectReferenceEqualityComparer.Default); + private HashSet _activeInstances; #endregion #region CONSTRUCTOR + protected PrefabCache() + { + _instances = new HashSet(ObjectReferenceEqualityComparer.Default); + _activeInstances = new HashSet(ObjectReferenceEqualityComparer.Default); + } + public PrefabCache(GameObject prefab, string name) { _prefab = prefab; _itemName = name; + _instances = new HashSet(ObjectReferenceEqualityComparer.Default); + _activeInstances = new HashSet(ObjectReferenceEqualityComparer.Default); } public void Init(SpawnPool owner) diff --git a/SPSpawn/Spawn/SpawnedObjectController.cs b/SPSpawn/Spawn/SpawnedObjectController.cs index a973740..2b19881 100644 --- a/SPSpawn/Spawn/SpawnedObjectController.cs +++ b/SPSpawn/Spawn/SpawnedObjectController.cs @@ -145,7 +145,7 @@ public void Kill() { if (!_pool.Despawn(this)) { - ObjUtil.SmartDestroy(this.gameObject); + Object.Destroy(this.gameObject); } else { diff --git a/SPSpawnEditor/Properties/AssemblyInfo.cs b/SPSpawnEditor/Properties/AssemblyInfo.cs deleted file mode 100644 index 8f46f12..0000000 --- a/SPSpawnEditor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPSpawnEditor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPSpawnEditor")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("70d5308a-a02e-428d-8c50-41208de16e6e")] diff --git a/SPSpawnEditor/SPSpawnEditor.csproj b/SPSpawnEditor/SPSpawnEditor.csproj index 824b80e..03d24b5 100644 --- a/SPSpawnEditor/SPSpawnEditor.csproj +++ b/SPSpawnEditor/SPSpawnEditor.csproj @@ -1,67 +1,35 @@  - - + - Debug - AnyCPU - {70D5308A-A02E-428D-8C50-41208DE16E6E} - Library - Properties + net35;net471 com.spacepuppyeditor SPSpawnEditor - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEditor.dll + + ..\Resources\UnityEditor.Graphs.dll + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - + - - {7fe0b8d6-ba29-43a6-b272-5d4f442fc4fa} - SpacepuppyUnityFrameworkEditor - - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - - - {74edaa76-51a6-4b3c-bb72-de9eb40b93c9} - SPSpawn - + + + - \ No newline at end of file diff --git a/SPTriggers/Events/i_Destroy.cs b/SPTriggers/Events/i_Destroy.cs index c7d1e89..65a665d 100644 --- a/SPTriggers/Events/i_Destroy.cs +++ b/SPTriggers/Events/i_Destroy.cs @@ -14,7 +14,6 @@ public class i_Destroy : AutoTriggerable private TriggerableTargetObject _target = new TriggerableTargetObject(); [SerializeField()] - [TimeUnitsSelector()] private SPTimePeriod _delay = 0f; #endregion diff --git a/SPTriggers/Events/i_Enable.cs b/SPTriggers/Events/i_Enable.cs index 76adb5d..214b1ea 100644 --- a/SPTriggers/Events/i_Enable.cs +++ b/SPTriggers/Events/i_Enable.cs @@ -26,7 +26,6 @@ public enum EnableMode private EnableMode _mode; [SerializeField()] - [TimeUnitsSelector()] private SPTimePeriod _delay = 0f; #endregion diff --git a/SPTriggers/Events/i_PlaySoundEffect.cs b/SPTriggers/Events/i_PlaySoundEffect.cs index a12fd8b..7c024fa 100644 --- a/SPTriggers/Events/i_PlaySoundEffect.cs +++ b/SPTriggers/Events/i_PlaySoundEffect.cs @@ -24,7 +24,6 @@ public class i_PlaySoundEffect : AutoTriggerable private AudioInterruptMode _interrupt = AudioInterruptMode.StopIfPlaying; [SerializeField()] - [TimeUnitsSelector()] private SPTimePeriod _delay; [Tooltip("Trigger something at the end of the sound effect. This is NOT perfectly accurate and really just starts a timer for the duration of the sound being played.")] @@ -32,7 +31,7 @@ public class i_PlaySoundEffect : AutoTriggerable private SPEvent _onAudioComplete; [System.NonSerialized()] - private RadicalCoroutine _completeRoutine; + private System.IDisposable _completeRoutine; #endregion @@ -107,7 +106,7 @@ public override bool Trigger(object sender, object arg) switch (this.Interrupt) { case AudioInterruptMode.StopIfPlaying: - if (_completeRoutine != null) _completeRoutine.Cancel(); + if (_completeRoutine != null) _completeRoutine.Dispose(); _completeRoutine = null; src.Stop(); break; @@ -138,7 +137,7 @@ public override bool Trigger(object sender, object arg) { if (src != null) { - _completeRoutine = this.Invoke(this.OnAudioCompleteHandler, clip.length); + _completeRoutine = this.InvokeGuaranteed(this.OnAudioCompleteHandler, clip.length, SPTime.Real); //src.Play(); src.PlayOneShot(clip); } @@ -146,7 +145,7 @@ public override bool Trigger(object sender, object arg) } else { - _completeRoutine = this.Invoke(this.OnAudioCompleteHandler, clip.length); + _completeRoutine = this.InvokeGuaranteed(this.OnAudioCompleteHandler, clip.length, SPTime.Real); //src.Play(); src.PlayOneShot(clip); } diff --git a/SPTriggers/Events/i_StopAudioSource.cs b/SPTriggers/Events/i_StopAudioSource.cs index 5e63b3b..43f303f 100644 --- a/SPTriggers/Events/i_StopAudioSource.cs +++ b/SPTriggers/Events/i_StopAudioSource.cs @@ -17,7 +17,6 @@ public class i_StopAudioSource : AutoTriggerable private TriggerableTargetObject _target; [SerializeField] - [TimeUnitsSelector()] private SPTimePeriod _fadeOutDur; [SerializeField] diff --git a/SPTriggers/Events/i_TriggerOnEval.cs b/SPTriggers/Events/i_TriggerOnEval.cs index b2309cd..11a77ee 100644 --- a/SPTriggers/Events/i_TriggerOnEval.cs +++ b/SPTriggers/Events/i_TriggerOnEval.cs @@ -20,7 +20,6 @@ public class i_TriggerOnEval : AutoTriggerable private bool _passAlongTriggerArg; [SerializeField()] - [TimeUnitsSelector()] private SPTimePeriod _delay = 0f; #endregion diff --git a/SPTriggers/Events/i_TriggerOnIfThen.cs b/SPTriggers/Events/i_TriggerOnIfThen.cs index f761037..d3ff8e0 100644 --- a/SPTriggers/Events/i_TriggerOnIfThen.cs +++ b/SPTriggers/Events/i_TriggerOnIfThen.cs @@ -21,7 +21,6 @@ public class i_TriggerOnIfThen : AutoTriggerable private bool _passAlongTriggerArg; [SerializeField()] - [TimeUnitsSelector()] private SPTimePeriod _delay = 0f; #endregion diff --git a/SPTriggers/Events/i_TriggerRandom.cs b/SPTriggers/Events/i_TriggerRandom.cs index 2282197..e292a4e 100644 --- a/SPTriggers/Events/i_TriggerRandom.cs +++ b/SPTriggers/Events/i_TriggerRandom.cs @@ -23,7 +23,6 @@ public class i_TriggerRandom : AutoTriggerable private bool _passAlongTriggerArg; [SerializeField()] - [TimeUnitsSelector()] private SPTimePeriod _delay = 0f; #endregion diff --git a/SPTriggers/Events/i_TriggerSequence.cs b/SPTriggers/Events/i_TriggerSequence.cs index dd59448..61b4c54 100644 --- a/SPTriggers/Events/i_TriggerSequence.cs +++ b/SPTriggers/Events/i_TriggerSequence.cs @@ -141,7 +141,7 @@ public void AttemptAutoStart() if (_signal == SignalMode.Auto) { IAutoSequenceSignal signal; - var targ = GameObjectUtil.GetGameObjectFromSource(_trigger.Targets[i].Target); + var targ = GameObjectUtil.GetGameObjectFromSource(_trigger.Targets[i].Target, true); if (targ != null && targ.GetComponentInChildren(out signal)) if (signal != null) { @@ -163,7 +163,7 @@ private System.Collections.IEnumerator DoAutoSequence(IAutoSequenceSignal signal int i = this.CurrentIndexNormalized; if (i < 0 || i >= _trigger.Targets.Count) yield break; - var go = GameObjectUtil.GetGameObjectFromSource(_trigger.Targets[i].Target); + var go = GameObjectUtil.GetGameObjectFromSource(_trigger.Targets[i].Target, true); if (go != null && go.GetComponentInChildren(out signal)) { var handle = signal.Wait(); diff --git a/SPTriggers/Events/t_Interval.cs b/SPTriggers/Events/t_Interval.cs index cc49c3c..dbaa9e1 100644 --- a/SPTriggers/Events/t_Interval.cs +++ b/SPTriggers/Events/t_Interval.cs @@ -88,7 +88,7 @@ protected override void OnTriggerActivate() _routine = null; } - this.StartRadicalCoroutine(this.TickerCallback(), RadicalCoroutineDisableMode.CancelOnDisable); + _routine = this.StartRadicalCoroutine(this.TickerCallback(), RadicalCoroutineDisableMode.CancelOnDisable); } diff --git a/SPTriggers/Events/t_IntervalRandom.cs b/SPTriggers/Events/t_IntervalRandom.cs index 707654b..4d5fc52 100644 --- a/SPTriggers/Events/t_IntervalRandom.cs +++ b/SPTriggers/Events/t_IntervalRandom.cs @@ -86,7 +86,7 @@ protected override void OnTriggerActivate() _routine = null; } - this.StartRadicalCoroutine(this.TickerCallback(), RadicalCoroutineDisableMode.CancelOnDisable); + _routine = this.StartRadicalCoroutine(this.TickerCallback(), RadicalCoroutineDisableMode.CancelOnDisable); } diff --git a/SPTriggers/Events/t_OnEnable.cs b/SPTriggers/Events/t_OnEnable.cs index f256362..104e68f 100644 --- a/SPTriggers/Events/t_OnEnable.cs +++ b/SPTriggers/Events/t_OnEnable.cs @@ -10,7 +10,6 @@ public sealed class t_OnEnable : TriggerComponent, IMStartOrEnableReceiver #region Fields [SerializeField()] - [TimeUnitsSelector()] private SPTimePeriod _delay; #endregion diff --git a/SPTriggers/Events/t_OnStart.cs b/SPTriggers/Events/t_OnStart.cs index 359a4e3..c849a05 100644 --- a/SPTriggers/Events/t_OnStart.cs +++ b/SPTriggers/Events/t_OnStart.cs @@ -10,7 +10,6 @@ public class t_OnStart : TriggerComponent #region Fields [SerializeField()] - [TimeUnitsSelector()] private SPTimePeriod _delay; #endregion diff --git a/SPTriggers/Properties/AssemblyInfo.cs b/SPTriggers/Properties/AssemblyInfo.cs deleted file mode 100644 index 3ea9b5f..0000000 --- a/SPTriggers/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPTriggers")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPTriggers")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("9c78e277-9614-4780-8c49-59b228f5a0be")] diff --git a/SPTriggers/SPTriggers.csproj b/SPTriggers/SPTriggers.csproj index b89fda7..3cbe6a2 100644 --- a/SPTriggers/SPTriggers.csproj +++ b/SPTriggers/SPTriggers.csproj @@ -1,40 +1,16 @@  - - + - Debug - AnyCPU - {9C78E277-9614-4780-8C49-59B228F5A0BE} - Library - Properties + net35;net471 com.spacepuppy SPTriggers - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEngine.dll @@ -43,67 +19,10 @@ - - Properties\AssemblyVersionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - - - {614b8c0c-0833-481b-8a76-d566887306f4} - SPTween - + - - \ No newline at end of file diff --git a/SPTriggersEditor/Events/i_SetValueOnTargetInspector.cs b/SPTriggersEditor/Events/i_SetValueOnTargetInspector.cs index 67dcc58..1ddb3f4 100644 --- a/SPTriggersEditor/Events/i_SetValueOnTargetInspector.cs +++ b/SPTriggersEditor/Events/i_SetValueOnTargetInspector.cs @@ -41,7 +41,7 @@ protected override void OnSPInspectorGUI() System.Reflection.MemberInfo selectedMember = null; var restrictType = TypeReferencePropertyDrawer.GetTypeFromTypeReference(restrictTypeProp); - if (!targetRef.TargetsTriggerArg && targetRef.Target != null && + if (restrictType == null && !targetRef.TargetsTriggerArg && targetRef.Target != null && targetRef.Find == TriggerableTargetObject.FindCommand.Direct && targetRef.ResolveBy != TriggerableTargetObject.ResolveByCommand.WithType && targetRef.Target.GetType() != restrictType) { diff --git a/SPTriggersEditor/Properties/AssemblyInfo.cs b/SPTriggersEditor/Properties/AssemblyInfo.cs deleted file mode 100644 index 8a90fda..0000000 --- a/SPTriggersEditor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPTriggersEditor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPTriggersEditor")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("16075f05-366b-42ea-a9c8-28f0b85bd444")] diff --git a/SPTriggersEditor/SPTriggersEditor.csproj b/SPTriggersEditor/SPTriggersEditor.csproj index c2bffeb..84647f1 100644 --- a/SPTriggersEditor/SPTriggersEditor.csproj +++ b/SPTriggersEditor/SPTriggersEditor.csproj @@ -1,75 +1,35 @@  - - + - Debug - AnyCPU - {16075F05-366B-42EA-A9C8-28F0B85BD444} - Library - Properties + net35;net471 com.spacepuppyeditor SPTriggersEditor - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEditor.dll + + ..\Resources\UnityEditor.Graphs.dll + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - - - - - - - - + - - {7fe0b8d6-ba29-43a6-b272-5d4f442fc4fa} - SpacepuppyUnityFrameworkEditor - - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - - - {9c78e277-9614-4780-8c49-59b228f5a0be} - SPTriggers - + + + - - \ No newline at end of file diff --git a/SPTween/Properties/AssemblyInfo.cs b/SPTween/Properties/AssemblyInfo.cs deleted file mode 100644 index 78e5b3a..0000000 --- a/SPTween/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPTween")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPTween")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("614b8c0c-0833-481b-8a76-d566887306f4")] diff --git a/SPTween/SPTween.csproj b/SPTween/SPTween.csproj index 15d65f9..64845a6 100644 --- a/SPTween/SPTween.csproj +++ b/SPTween/SPTween.csproj @@ -1,112 +1,27 @@  - - + - Debug - AnyCPU - {614B8C0C-0833-481B-8A76-D566887306F4} - Library - Properties + net35;net471 com.spacepuppy SPTween - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false + false + false - - - - + + + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - + - \ No newline at end of file diff --git a/SPTween/Tween/Easing.cs b/SPTween/Tween/Easing.cs index 2feb7af..40481da 100644 --- a/SPTween/Tween/Easing.cs +++ b/SPTween/Tween/Easing.cs @@ -819,6 +819,11 @@ public static Ease StrongEaseInOut #region AnimationCurve + /// + /// Returns an Ease method that ignores start and end. Instead just returning the value in the curve for 'c', as if you called Evaluate(c). + /// + /// + /// public static Ease FromAnimationCurve(AnimationCurve curve) { return (c, s, e, d) => @@ -827,6 +832,34 @@ public static Ease FromAnimationCurve(AnimationCurve curve) }; } + /// + /// This treats the curve as if it's a scaling factor. The vertical from 0->1 is the value s->e. And the horizontal is just 'c'. 'd' is ignored in favor of the duration of the curve. + /// + /// + /// + public static Ease FromVerticalScalingAnimationCurve(AnimationCurve curve) + { + return (c, s, e, d) => + { + if (d <= 0f) return e; + return Mathf.LerpUnclamped(s, e, curve.Evaluate(c / d)); + }; + } + + /// + /// This treats the curve as if it's a scaling factor. The vertical from 0->1 is the value s->e. And the horizontal from 0->1 is the time from c->d. + /// + /// + /// + public static Ease FromScalingAnimationCurve(AnimationCurve curve) + { + return (c, s, e, d) => + { + if (d <= 0f) return e; + return Mathf.LerpUnclamped(s, e, curve.Evaluate(c / d)); + }; + } + #endregion #region Configurable Cubic Bezier diff --git a/SPTween/Tween/Events/i_TweenTo.cs b/SPTween/Tween/Events/i_TweenTo.cs new file mode 100644 index 0000000..df80d9d --- /dev/null +++ b/SPTween/Tween/Events/i_TweenTo.cs @@ -0,0 +1,165 @@ +#pragma warning disable 0649 // variable declared but not used. +using UnityEngine; + +using com.spacepuppy.Events; +using com.spacepuppy.Tween; +using com.spacepuppy.Utils; + +namespace com.spacepuppy.Tween.Events +{ + + public class i_TweenTo : AutoTriggerable, IObservableTrigger + { + + #region Fields + + [SerializeField()] + [TriggerableTargetObject.Config(typeof(Transform))] + private TriggerableTargetObject _target = new TriggerableTargetObject(); + + [SerializeField()] + [TriggerableTargetObject.Config(typeof(Transform))] + private TriggerableTargetObject _location = new TriggerableTargetObject(); + + + [SerializeField()] + private EaseStyle _ease; + [SerializeField()] + private SPTimePeriod _duration; + + [SerializeField] + private bool _orientWithLocationRotation; + + [SerializeField()] + private bool _tweenEntireEntity; + + [SerializeField()] + private SPEvent _onComplete; + + [SerializeField()] + private SPEvent _onTick; + + [SerializeField()] + [Tooltip("Leave blank for tweens to be unique to this component.")] + private string _tweenToken; + + #endregion + + #region CONSTRUCTOR + + protected override void Awake() + { + base.Awake(); + + if (string.IsNullOrEmpty(_tweenToken)) _tweenToken = "i_Tween*" + this.GetInstanceID().ToString(); + } + + protected override void OnDisable() + { + base.OnDisable(); + + SPTween.KillAll(_target, _tweenToken); + } + + #endregion + + #region Properties + + public TriggerableTargetObject Target + { + get { return _target; } + } + + public TriggerableTargetObject Location + { + get { return _location; } + } + + public EaseStyle Ease + { + get { return _ease; } + set { _ease = value; } + } + + public SPTimePeriod Duration + { + get { return _duration; } + set { _duration = value; } + } + + public bool OrientWithLocationRotation + { + get { return _orientWithLocationRotation; } + set { _orientWithLocationRotation = value; } + } + + public bool TweenEntireEntity + { + get { return _tweenEntireEntity; } + set { _tweenEntireEntity = value; } + } + + public SPEvent OnComplete + { + get { return _onComplete; } + } + + public SPEvent OnTick + { + get { return _onTick; } + } + + public string TweenToken + { + get { return _tweenToken; } + set { _tweenToken = value; } + } + + #endregion + + #region TriggerableMechanism Interface + + public override bool Trigger(object sender, object arg) + { + if (!this.CanTrigger) return false; + + var targ = this._target.GetTarget(arg); + if (targ == null) return false; + if (_tweenEntireEntity) targ = GameObjectUtil.FindRoot(targ).transform; + + var loc = _location.GetTarget(arg); + if (targ == null || loc == null) return false; + + var twn = SPTween.Tween(targ); + + twn.To("position", _duration.Seconds, loc.position); + if (_orientWithLocationRotation) twn.To("rotation", _duration.Seconds, loc.rotation); + + twn.Use(_duration.TimeSupplier); + twn.SetId(_target); + + if (_onComplete.Count > 0) + twn.OnFinish((t) => _onComplete.ActivateTrigger(this, null)); + + if (_onTick.Count > 0) + twn.OnStep((t) => _onTick.ActivateTrigger(this, null)); + + twn.Play(true, _tweenToken); + + return true; + } + + #endregion + + #region IObservable Interface + + BaseSPEvent[] IObservableTrigger.GetEvents() + { + return new BaseSPEvent[] { _onTick, _onComplete }; + } + + #endregion + + } + +} diff --git a/SPTween/Tween/Events/i_TweenValue.cs b/SPTween/Tween/Events/i_TweenValue.cs index a53e615..f664e18 100644 --- a/SPTween/Tween/Events/i_TweenValue.cs +++ b/SPTween/Tween/Events/i_TweenValue.cs @@ -6,7 +6,7 @@ namespace com.spacepuppy.Tween.Events { - public class i_TweenValue : AutoTriggerable + public class i_TweenValue : AutoTriggerable, IObservableTrigger { #region Fields @@ -121,5 +121,14 @@ public class TweenData #endregion + #region IObservable Interface + + BaseSPEvent[] IObservableTrigger.GetEvents() + { + return new BaseSPEvent[] { _onTick, _onComplete }; + } + + #endregion + } } diff --git a/SPTween/Tween/SPTween.cs b/SPTween/Tween/SPTween.cs index c2f9dd0..e9cca31 100644 --- a/SPTween/Tween/SPTween.cs +++ b/SPTween/Tween/SPTween.cs @@ -363,19 +363,23 @@ public static Tweener PlayCurve(object targ, TweenCurve curve) return tween; } - public static Tweener PlayCurve(object targ, string propName, AnimationCurve curve, float dur, object option = null) + public static Tweener PlayCurve(object targ, string propName, AnimationCurve curve, object option = null) { if (curve == null) throw new System.ArgumentNullException("curve"); - var tween = new ObjectTweener(targ, MemberCurve.CreateFromTo(targ, propName, EaseMethods.FromAnimationCurve(curve), null, null, dur, option)); + float dur = (curve.keys.Length > 0) ? curve.keys.Last().time : 0f; + var tween = new ObjectTweener(targ, MemberCurve.CreateFromTo(targ, propName, + EaseMethods.FromAnimationCurve(curve), + null, null, dur, option)); tween.Play(); return tween; } - public static Tweener PlayCurve(object targ, string propName, AnimationCurve curve, object option = null) + public static Tweener PlayCurve(object targ, string propName, AnimationCurve curve, float dur, object option = null) { if (curve == null) throw new System.ArgumentNullException("curve"); - float dur = (curve.keys.Length > 0) ? curve.keys.Last().time : 0f; - var tween = new ObjectTweener(targ, MemberCurve.CreateFromTo(targ, propName, EaseMethods.FromAnimationCurve(curve), null, null, dur, option)); + var tween = new ObjectTweener(targ, MemberCurve.CreateFromTo(targ, propName, + EaseMethods.FromAnimationCurve(curve), + null, null, dur, option)); tween.Play(); return tween; } diff --git a/SPTween/Tween/TweenHash.cs b/SPTween/Tween/TweenHash.cs index e5b9061..6c4ee4a 100644 --- a/SPTween/Tween/TweenHash.cs +++ b/SPTween/Tween/TweenHash.cs @@ -277,18 +277,22 @@ public TweenHash UseCurve(TweenCurve curve) return this; } - public TweenHash UseCurve(string memberName, AnimationCurve curve, float dur, object option = null) + public TweenHash UseCurve(string memberName, AnimationCurve curve, object option = null) { if (curve == null) throw new System.ArgumentNullException("curve"); - _props.Add(new PropInfo(AnimMode.AnimCurve, memberName, EaseMethods.FromAnimationCurve(curve), dur, null, option)); + float dur = (curve.keys.Length > 0) ? curve.keys.Last().time : 0f; + _props.Add(new PropInfo(AnimMode.AnimCurve, memberName, + EaseMethods.FromAnimationCurve(curve), + dur, null, option)); return this; } - public TweenHash UseCurve(string memberName, AnimationCurve curve, object option = null) + public TweenHash UseCurve(string memberName, AnimationCurve curve, float dur, object option = null) { if (curve == null) throw new System.ArgumentNullException("curve"); - float dur = (curve.keys.Length > 0) ? curve.keys.Last().time : 0f; - _props.Add(new PropInfo(AnimMode.AnimCurve, memberName, EaseMethods.FromAnimationCurve(curve), dur, null, option)); + _props.Add(new PropInfo(AnimMode.AnimCurve, memberName, + EaseMethods.FromAnimationCurve(curve), + dur, null, option)); return this; } diff --git a/SPTweenEditor/Properties/AssemblyInfo.cs b/SPTweenEditor/Properties/AssemblyInfo.cs deleted file mode 100644 index cb519c8..0000000 --- a/SPTweenEditor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPTweenEditor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPTweenEditor")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("0d614c4e-000c-41c3-bc9b-21fa60e90afa")] diff --git a/SPTweenEditor/SPTweenEditor.csproj b/SPTweenEditor/SPTweenEditor.csproj index 58600d4..e930838 100644 --- a/SPTweenEditor/SPTweenEditor.csproj +++ b/SPTweenEditor/SPTweenEditor.csproj @@ -1,72 +1,35 @@  - - + - Debug - AnyCPU - {0D614C4E-000C-41C3-BC9B-21FA60E90AFA} - Library - Properties + net35;net471 com.spacepuppyeditor SPTweenEditor - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false + false + false - - - - + + + ..\Resources\UnityEditor.dll + + ..\Resources\UnityEditor.Graphs.dll + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - - - - + - - {7fe0b8d6-ba29-43a6-b272-5d4f442fc4fa} - SpacepuppyUnityFrameworkEditor - - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - - - {614b8c0c-0833-481b-8a76-d566887306f4} - SPTween - + + + - \ No newline at end of file diff --git a/SPUtils/Properties/AssemblyInfo.cs b/SPUtils/Properties/AssemblyInfo.cs deleted file mode 100644 index 633a21b..0000000 --- a/SPUtils/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPUtils")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPUtils")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("4fa4fb9b-8ad3-4d87-b895-f65f593a6867")] diff --git a/SPUtils/Render/Events/i_TweenMaterial.cs b/SPUtils/Render/Events/i_TweenMaterial.cs index ebd0ce2..85d00f6 100644 --- a/SPUtils/Render/Events/i_TweenMaterial.cs +++ b/SPUtils/Render/Events/i_TweenMaterial.cs @@ -19,11 +19,7 @@ public class i_TweenMaterial : AutoTriggerable private bool _killOnDisable; [SerializeField()] - private SPTime _timeSupplier; - - [SerializeField()] - [TimeUnitsSelector()] - private float _duration; + private SPTimePeriod _duration; [SerializeField()] private EaseStyle _ease; @@ -129,9 +125,9 @@ public override bool Trigger(object sender, object arg) } var twn = SPTween.Tween(_transition) - .FromTo("Position", EaseMethods.GetEase(_ease), _duration, 0f, 1f) + .FromTo("Position", EaseMethods.GetEase(_ease), _duration.Seconds, 0f, 1f) .SetId(this.AutoKillId) - .Use(_timeSupplier.TimeSupplier); + .Use(_duration.TimeSupplier); if (_onComplete.Count > 0) twn.OnFinish((t) => _onComplete.ActivateTrigger(this, null)); diff --git a/SPUtils/SPUtils.csproj b/SPUtils/SPUtils.csproj index 0705a07..71c07e5 100644 --- a/SPUtils/SPUtils.csproj +++ b/SPUtils/SPUtils.csproj @@ -1,40 +1,16 @@  - - + - Debug - AnyCPU - {4FA4FB9B-8AD3-4D87-B895-F65F593A6867} - Library - Properties + net35;net471 com.spacepuppy SPUtils - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEngine.dll @@ -43,44 +19,10 @@ - - Properties\AssemblyVersionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - - - {614b8c0c-0833-481b-8a76-d566887306f4} - SPTween - + - \ No newline at end of file diff --git a/SPUtilsEditor/Properties/AssemblyInfo.cs b/SPUtilsEditor/Properties/AssemblyInfo.cs deleted file mode 100644 index 453132b..0000000 --- a/SPUtilsEditor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPUtilsEditor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPUtilsEditor")] -[assembly: AssemblyCopyright("Copyright © 2018")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("b9bce83e-5ea8-4e75-acfd-45e7db035234")] diff --git a/SPUtilsEditor/SPUtilsEditor.csproj b/SPUtilsEditor/SPUtilsEditor.csproj index 9e6b12b..5865403 100644 --- a/SPUtilsEditor/SPUtilsEditor.csproj +++ b/SPUtilsEditor/SPUtilsEditor.csproj @@ -1,43 +1,22 @@  - - + - Debug - AnyCPU - {B9BCE83E-5EA8-4E75-ACFD-45E7DB035234} - Library - Properties + net35;net471 com.spacepuppyeditor SPUtilsEditor - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEditor.dll + + ..\Resources\UnityEditor.Graphs.dll + ..\Resources\UnityEngine.dll @@ -46,31 +25,11 @@ - - Properties\AssemblyVersionInfo.cs - - - - - - - - - + - - {7fe0b8d6-ba29-43a6-b272-5d4f442fc4fa} - SpacepuppyUnityFrameworkEditor - - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - - - {4fa4fb9b-8ad3-4d87-b895-f65f593a6867} - SPUtils - + + + - \ No newline at end of file diff --git a/SPWaypoint/Properties/AssemblyInfo.cs b/SPWaypoint/Properties/AssemblyInfo.cs deleted file mode 100644 index c02f4c8..0000000 --- a/SPWaypoint/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPWaypoint")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPWaypoint")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("bee152df-76d8-4174-ad23-3fefa5b218af")] diff --git a/SPWaypoint/SPWaypoint.csproj b/SPWaypoint/SPWaypoint.csproj index 1576c2d..27e025a 100644 --- a/SPWaypoint/SPWaypoint.csproj +++ b/SPWaypoint/SPWaypoint.csproj @@ -1,71 +1,28 @@  - - + - Debug - AnyCPU - {BEE152DF-76D8-4174-AD23-3FEFA5B218AF} - Library - Properties + net35;net471 com.spacepuppy SPWaypoint - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + false - - - - + + + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - - - - - - - - - - - + + - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - - - {614b8c0c-0833-481b-8a76-d566887306f4} - SPTween - + - - \ No newline at end of file diff --git a/SPWaypointEditor/Properties/AssemblyInfo.cs b/SPWaypointEditor/Properties/AssemblyInfo.cs deleted file mode 100644 index 1c28d3c..0000000 --- a/SPWaypointEditor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SPWaypointEditor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SPWaypointEditor")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("c9c2e4d7-0a1a-411b-a470-5863855a5dab")] diff --git a/SPWaypointEditor/SPWaypointEditor.csproj b/SPWaypointEditor/SPWaypointEditor.csproj index d6307df..00a5d7a 100644 --- a/SPWaypointEditor/SPWaypointEditor.csproj +++ b/SPWaypointEditor/SPWaypointEditor.csproj @@ -1,76 +1,38 @@  - - + - Debug - AnyCPU - {C9C2E4D7-0A1A-411B-A470-5863855A5DAB} - Library - Properties + net35;net471 com.spacepuppyeditor SPWaypointEditor - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + 3.1.1 + false + false - - - - + + + ..\Resources\UnityEditor.dll + + ..\Resources\UnityEditor.Graphs.dll + ..\Resources\UnityEngine.dll + + ..\Resources\UnityEngine.UI.dll + - - Properties\AssemblyVersionInfo.cs - - - - + - - {7fe0b8d6-ba29-43a6-b272-5d4f442fc4fa} - SpacepuppyUnityFrameworkEditor - - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - - - {0d614c4e-000c-41c3-bc9b-21fa60e90afa} - SPTweenEditor - - - {614b8c0c-0833-481b-8a76-d566887306f4} - SPTween - - - {bee152df-76d8-4174-ad23-3fefa5b218af} - SPWaypoint - + + + + + - \ No newline at end of file diff --git a/SpacepuppyUnityFramework/Events/Enums.cs b/SpacepuppyUnityFramework/Events/Enums.cs index 525c512..19d8dae 100644 --- a/SpacepuppyUnityFramework/Events/Enums.cs +++ b/SpacepuppyUnityFramework/Events/Enums.cs @@ -9,7 +9,7 @@ public enum ActivateEvent None = 0, OnStart = 1, OnEnable = 2, - OnStartAndEnable = 3, + OnStartOrEnable = 3, Awake = 4 } diff --git a/SpacepuppyUnityFramework/Events/Trigger.cs b/SpacepuppyUnityFramework/Events/Trigger.cs index eef2654..32d8f00 100644 --- a/SpacepuppyUnityFramework/Events/Trigger.cs +++ b/SpacepuppyUnityFramework/Events/Trigger.cs @@ -68,7 +68,7 @@ public abstract class AutoTriggerComponent : TriggerComponent #region Fields [SerializeField()] - private ActivateEvent _activateOn = ActivateEvent.OnStartAndEnable; + private ActivateEvent _activateOn = ActivateEvent.OnStartOrEnable; #endregion @@ -98,7 +98,7 @@ protected override void OnEnable() { base.OnEnable(); - if ((_activateOn & ActivateEvent.OnStart) != 0 && !this.started) return; + if (!this.started) return; if ((_activateOn & ActivateEvent.OnEnable) != 0) { diff --git a/SpacepuppyUnityFramework/Events/Triggerable.cs b/SpacepuppyUnityFramework/Events/Triggerable.cs index 3a3b3e1..ab79617 100644 --- a/SpacepuppyUnityFramework/Events/Triggerable.cs +++ b/SpacepuppyUnityFramework/Events/Triggerable.cs @@ -75,7 +75,7 @@ protected override void OnEnable() { base.OnEnable(); - if ((_activateOn & ActivateEvent.OnStart) != 0 && !this.started) return; + if (!this.started) return; if ((_activateOn & ActivateEvent.OnEnable) != 0) { diff --git a/SpacepuppyUnityFramework/Events/TriggerableTargetObject.cs b/SpacepuppyUnityFramework/Events/TriggerableTargetObject.cs index 2313043..642e9fb 100644 --- a/SpacepuppyUnityFramework/Events/TriggerableTargetObject.cs +++ b/SpacepuppyUnityFramework/Events/TriggerableTargetObject.cs @@ -167,7 +167,7 @@ public T GetTarget(object triggerArg) where T : class if (obj == null) return null; var result = ObjUtil.GetAsFromSource(obj); - if (result == null && this.ImplicityReducesEntireEntity && ComponentUtil.IsAcceptableComponentType(typeof(T))) + if (ObjUtil.IsNullOrDestroyed(result) && this.ImplicityReducesEntireEntity && ComponentUtil.IsAcceptableComponentType(typeof(T))) { //if not configured, and the triggerArg didn't reduce properly, lets search the entity of the 'triggerArg' var go = GameObjectUtil.FindRoot(GameObjectUtil.GetGameObjectFromSource(obj)); @@ -185,7 +185,7 @@ public object GetTarget(System.Type tp, object triggerArg) if (obj == null) return null; var result = ObjUtil.GetAsFromSource(tp, obj); - if (result == null && this.ImplicityReducesEntireEntity && ComponentUtil.IsAcceptableComponentType(tp)) + if (ObjUtil.IsNullOrDestroyed(result) && this.ImplicityReducesEntireEntity && ComponentUtil.IsAcceptableComponentType(tp)) { //if not configured, and the triggerArg didn't reduce properly, lets search the entity of the 'triggerArg' var go = GameObjectUtil.FindRoot(GameObjectUtil.GetGameObjectFromSource(obj)); @@ -202,7 +202,7 @@ public IEnumerable GetTargets(object triggerArg) where T : class if (obj == null) continue; var result = ObjUtil.GetAsFromSource(obj); - if (result == null && !_configured && obj == triggerArg && ComponentUtil.IsAcceptableComponentType(typeof(T))) + if (ObjUtil.IsNullOrDestroyed(result) && !_configured && obj == triggerArg && ComponentUtil.IsAcceptableComponentType(typeof(T))) { //if not configured, and the triggerArg didn't reduce properly, lets search the entity of the 'triggerArg' var go = GameObjectUtil.FindRoot(GameObjectUtil.GetGameObjectFromSource(obj)); @@ -220,7 +220,7 @@ public System.Collections.IEnumerable GetTargets(System.Type tp, object triggerA if (obj == null) continue; var result = ObjUtil.GetAsFromSource(tp, obj); - if (result == null && !_configured && obj == triggerArg && ComponentUtil.IsAcceptableComponentType(tp)) + if (ObjUtil.IsNullOrDestroyed(result) && !_configured && obj == triggerArg && ComponentUtil.IsAcceptableComponentType(tp)) { //if not configured, and the triggerArg didn't reduce properly, lets search the entity of the 'triggerArg' var go = GameObjectUtil.FindRoot(GameObjectUtil.GetGameObjectFromSource(obj)); @@ -241,7 +241,7 @@ private object ReduceTarget(object triggerArg) case FindCommand.Direct: { object obj = (_configured) ? targ : triggerArg; - if (obj == null) return null; + if (ObjUtil.IsNullOrDestroyed(obj)) return null; switch (_resolveBy) { case ResolveByCommand.Nothing: @@ -416,7 +416,7 @@ private System.Collections.IEnumerable ReduceTargets(object triggerArg) case FindCommand.Direct: { object obj = (_configured) ? _target : triggerArg; - if (obj == null) yield break; + if (ObjUtil.IsNullOrDestroyed(obj)) yield break; switch (_resolveBy) { case ResolveByCommand.Nothing: diff --git a/SpacepuppyUnityFramework/GameLoop.cs b/SpacepuppyUnityFramework/GameLoop.cs index e9a0b95..48cf8e5 100644 --- a/SpacepuppyUnityFramework/GameLoop.cs +++ b/SpacepuppyUnityFramework/GameLoop.cs @@ -56,6 +56,7 @@ public class GameLoop : ServiceComponent, IService private static UpdatePump _tardyFixedUpdatePump; private static com.spacepuppy.Async.InvokePump _updateInvokeHandle; + private static com.spacepuppy.Async.InvokePump _lateUpdateInvokeHandle; private static com.spacepuppy.Async.InvokePump _fixedUpdateInvokeHandle; private static int _currentFrame; @@ -108,6 +109,7 @@ protected override void OnValidAwake() _tardyFixedUpdatePump = new UpdatePump(); _updateInvokeHandle = new com.spacepuppy.Async.InvokePump(); + _lateUpdateInvokeHandle = new com.spacepuppy.Async.InvokePump(); _fixedUpdateInvokeHandle = new com.spacepuppy.Async.InvokePump(); } @@ -186,12 +188,17 @@ public static GameLoop Hook public static UpdatePump LateUpdatePump { get { return _lateUpdatePump; } } /// - /// Used to get back to the Update loop from an asynchronous thread. + /// Used to schedule an action on the next Update regardless of threading. /// public static com.spacepuppy.Async.InvokePump UpdateHandle { get { return _updateInvokeHandle; } } /// - /// Used to get back to the FixedUpdate loop from an asynchronous thread. + /// Used to schedule an action on the next LateUpdate regardless of threading. + /// + public static com.spacepuppy.Async.InvokePump LateUpdateHandle { get { return _lateUpdateInvokeHandle; } } + + /// + /// Used to schedule an action on the next FixedUpdate regardless of threading. /// public static com.spacepuppy.Async.InvokePump FixedUpdateHandle { get { return _fixedUpdateInvokeHandle; } } @@ -368,6 +375,7 @@ private void _updateHook_LateUpdate(object sender, System.EventArgs e) private void _tardyUpdateHook_LateUpdate(object sender, System.EventArgs e) { + _lateUpdateInvokeHandle.Update(); if (TardyLateUpdate != null) TardyLateUpdate(this, e); //Track exit of update loop diff --git a/SpacepuppyUnityFramework/Geom/Cone.cs b/SpacepuppyUnityFramework/Geom/Cone.cs index 881200a..ffefe6a 100644 --- a/SpacepuppyUnityFramework/Geom/Cone.cs +++ b/SpacepuppyUnityFramework/Geom/Cone.cs @@ -180,6 +180,33 @@ public static bool ContainsPoint(Vector3 start, Vector3 end, float startRadius, } } + public static bool ContainsSphere(Vector3 start, Vector3 end, float startRadius, float endRadius, Vector3 pnt, float sphereRadius) + { + var rail = end - start; + var rod = pnt - start; + var dot = Vector3.Dot(rod, rail); + var sqrRailLength = rail.sqrMagnitude; + float sqrSphereRad = sphereRadius * sphereRadius; + + if (dot < -sqrSphereRad || dot > sqrRailLength + sqrSphereRad) + { + return false; + } + else + { + float radius; + if (sqrRailLength < 0.0001f) + radius = Mathf.Max(startRadius, endRadius); + else + radius = startRadius + (endRadius - startRadius) * dot / sqrRailLength; + + if (rod.sqrMagnitude - dot * dot / sqrRailLength > radius * radius + sqrSphereRad) + return false; + else + return true; + } + } + #endregion } diff --git a/SpacepuppyUnityFramework/Geom/Cylinder.cs b/SpacepuppyUnityFramework/Geom/Cylinder.cs index c085ec4..dae10e2 100644 --- a/SpacepuppyUnityFramework/Geom/Cylinder.cs +++ b/SpacepuppyUnityFramework/Geom/Cylinder.cs @@ -206,6 +206,49 @@ public static bool ContainsPoint(Vector3 start, Vector3 end, float radius, float } } + public static bool ContainsSphere(Vector3 start, Vector3 end, float radius, Vector3 pnt, float sphereRadius) + { + var rail = end - start; + var rod = pnt - start; + var dot = Vector3.Dot(rod, rail); + float sqrRailLength = rail.sqrMagnitude; + float sqrSphereRad = sphereRadius * sphereRadius; + + if (dot < -sqrSphereRad || dot > sqrRailLength + sqrSphereRad) + { + return false; + } + else + { + if (rod.sqrMagnitude - dot * dot / sqrRailLength > radius * radius + sqrSphereRad) + return false; + else + return true; + } + } + + public static bool ContainsSphere(Vector3 start, Vector3 end, float radius, float innerRadius, Vector3 pnt, float sphereRadius) + { + var rail = end - start; + var rod = pnt - start; + var dot = Vector3.Dot(rod, rail); + var sqrRailLength = rail.sqrMagnitude; + float sqrSphereRad = sphereRadius * sphereRadius; + + if (dot < -sqrSphereRad || dot > sqrRailLength + sqrSphereRad) + { + return false; + } + else + { + float radialDistSqr = rod.sqrMagnitude - dot * dot / sqrRailLength; + if (radialDistSqr > radius * radius + sqrSphereRad || radialDistSqr < innerRadius * innerRadius - sqrSphereRad) + return false; + else + return true; + } + } + #endregion } } diff --git a/SpacepuppyUnityFramework/IMixin.cs b/SpacepuppyUnityFramework/IMixin.cs index 348ff54..b7619fa 100644 --- a/SpacepuppyUnityFramework/IMixin.cs +++ b/SpacepuppyUnityFramework/IMixin.cs @@ -118,6 +118,7 @@ public override void OnConstructed(IMixin obj) /// /// Sometimes you want to run Start late, to allow Start to be called on all other scripts. Basically adding a final ordering for Start similar to LateUpdate. /// + [MLateStartReceiverConstructor] public interface IMLateStartReceiver : IMixin, IEventfulComponent { void OnLateStart(); @@ -134,7 +135,7 @@ public override void OnConstructed(IMixin obj) { c.OnStarted += (s, e) => { - GameLoop.UpdateHandle.BeginInvoke(() => + GameLoop.LateUpdateHandle.BeginInvoke(() => { c.OnLateStart(); }); @@ -166,7 +167,7 @@ public override void OnConstructed(IMixin obj) { c.OnEnabled += (s, e) => { - GameLoop.UpdateHandle.BeginInvoke(() => + GameLoop.LateUpdateHandle.BeginInvoke(() => { c.OnLateStartOrEnable(); }); diff --git a/SpacepuppyUnityFramework/IProxy.cs b/SpacepuppyUnityFramework/IProxy.cs index ba2ff93..38165d8 100644 --- a/SpacepuppyUnityFramework/IProxy.cs +++ b/SpacepuppyUnityFramework/IProxy.cs @@ -1,8 +1,10 @@ -using UnityEngine; +#pragma warning disable 0649 // variable declared but not used. +using UnityEngine; using System.Collections.Generic; using System.Linq; using com.spacepuppy.Dynamic; +using com.spacepuppy.Events; using com.spacepuppy.Utils; namespace com.spacepuppy @@ -248,18 +250,24 @@ public object Value #endregion #region Methods - + public object GetValue() { - if (_target == null) + if (_target == null) return null; + + var obj = ObjUtil.ReduceIfProxy(_target); + if (obj == null) return null; else - return DynamicUtil.GetValue(_target, _memberName); + return DynamicUtil.GetValue(obj, _memberName); } public T GetValue() { - if (_target == null) + if (_target == null) return default(T); + + var obj = ObjUtil.ReduceIfProxy(_target); + if (obj == null) return default(T); else { @@ -275,7 +283,13 @@ public T GetValue() public bool SetValue(object value) { - return DynamicUtil.SetValue(_target, _memberName, value); + if (_target == null) return false; + + var obj = ObjUtil.ReduceIfProxy(_target); + if (obj == null) + return false; + else + return DynamicUtil.SetValue(_target, _memberName, value); } #endregion @@ -297,10 +311,19 @@ object IProxy.GetTarget(object arg) return this.GetValue(); } - System.Type IProxy.GetTargetType() + public System.Type GetTargetType() { if (_memberName == null) return typeof(object); - return DynamicUtil.GetReturnType(DynamicUtil.GetMember(_target, _memberName, false)) ?? typeof(object); + + if (_target is IProxy) + { + var tp = (_target as IProxy).GetTargetType(); + return DynamicUtil.GetReturnType(DynamicUtil.GetMemberFromType(tp, _memberName, false)) ?? typeof(object); + } + else + { + return DynamicUtil.GetReturnType(DynamicUtil.GetMember(ObjUtil.ReduceIfProxy(_target), _memberName, false)) ?? typeof(object); + } } #endregion @@ -322,4 +345,152 @@ public ConfigAttribute(DynamicMemberAccess memberAccessLevel) } + [CreateAssetMenu(fileName = "QueryProxy", menuName = "Spacepuppy/QueryProxy")] + public class QueryProxyToken : ScriptableObject, IProxy + { + + #region Fields + + [SerializeField] + private TriggerableTargetObject _target = new TriggerableTargetObject(TriggerableTargetObject.FindCommand.FindInScene, TriggerableTargetObject.ResolveByCommand.Nothing, string.Empty); + [SerializeField] + [TypeReference.Config(typeof(Component), allowAbstractClasses = true, allowInterfaces = true)] + private TypeReference _componentTypeOnTarget = new TypeReference(); + + [Space()] + [SerializeField] + [Tooltip("Cache the target when it's first retrieved. This is useful for speeding up any 'Find' commands if called repeatedly, but is hindered if the target is changing.")] + private bool _cache; + [System.NonSerialized] + private UnityEngine.Object _object; + + #endregion + + #region IProxy Interface + + bool IProxy.QueriesTarget + { + get { return _target.ImplicityReducesEntireEntity; } + } + + public object GetTarget() + { + if (_cache) + { + if (_object != null) return _object; + + _object = _target.GetTarget(_componentTypeOnTarget.Type ?? typeof(UnityEngine.Object), null) as UnityEngine.Object; + return _object; + } + else + { + return _target.GetTarget(_componentTypeOnTarget.Type ?? typeof(UnityEngine.Object), null) as UnityEngine.Object; + } + } + + public object GetTarget(object arg) + { + if (_cache) + { + if (_object != null) return _object; + + if (_componentTypeOnTarget == null) return null; + _object = _target.GetTarget(_componentTypeOnTarget.Type ?? typeof(UnityEngine.Object), arg) as UnityEngine.Object; + return _object; + } + else + { + if (_componentTypeOnTarget == null) return null; + return _target.GetTarget(_componentTypeOnTarget.Type ?? typeof(UnityEngine.Object), arg) as UnityEngine.Object; + } + } + + public System.Type GetTargetType() + { + if (_componentTypeOnTarget.Type != null) return _componentTypeOnTarget.Type; + return (_cache && _object != null) ? _object.GetType() : typeof(UnityEngine.Object); + } + + #endregion + + } + + [CreateAssetMenu(fileName = "MemberProxy", menuName = "Spacepuppy/MemberProxy")] + public class MemberProxyToken : ScriptableObject, IProxy + { + + #region Fields + + [SerializeField] + private MemberProxy _target; + + #endregion + + #region Properties + + public UnityEngine.Object Target + { + get { return _target.Target; } + set { _target.Target = value; } + } + + public string MemberName + { + get { return _target.MemberName; } + set { _target.MemberName = value; } + } + + public object Value + { + get { return _target.GetValue(); } + set { _target.SetValue(value); } + } + + #endregion + + #region Methods + + public object GetValue() + { + return _target.GetValue(); + } + + public T GetValue() + { + return _target.GetValue(); + } + + public bool SetValue(object value) + { + return _target.SetValue(value); + } + + #endregion + + #region IProxy Interface + + bool IProxy.QueriesTarget + { + get { return false; } + } + + object IProxy.GetTarget() + { + return _target.GetValue(); + } + + object IProxy.GetTarget(object arg) + { + return _target.GetValue(); + } + + System.Type IProxy.GetTargetType() + { + return _target.GetTargetType(); + } + + #endregion + + } + } diff --git a/SpacepuppyUnityFramework/Properties/AssemblyInfo.cs b/SpacepuppyUnityFramework/Properties/AssemblyInfo.cs deleted file mode 100644 index ea1e111..0000000 --- a/SpacepuppyUnityFramework/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SpacepuppyUnityFramework")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SpacepuppyUnityFramework")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("3b57db6b-ba67-46ad-b929-fdd8e6ae511e")] \ No newline at end of file diff --git a/SpacepuppyUnityFramework/Properties/AssemblyVersionInfo.cs b/SpacepuppyUnityFramework/Properties/AssemblyVersionInfo.cs index b15a007..15ffc3d 100644 --- a/SpacepuppyUnityFramework/Properties/AssemblyVersionInfo.cs +++ b/SpacepuppyUnityFramework/Properties/AssemblyVersionInfo.cs @@ -6,4 +6,5 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -[assembly: AssemblyVersion("3.0.1.18296")] \ No newline at end of file +[assembly: AssemblyVersion("3.1.1.18320")] +[assembly: AssemblyFileVersion("3.1.1.18320")] \ No newline at end of file diff --git a/SpacepuppyUnityFramework/Properties/AssemblyVersionInfo.tt b/SpacepuppyUnityFramework/Properties/AssemblyVersionInfo.tt index a765a65..0fefed4 100644 --- a/SpacepuppyUnityFramework/Properties/AssemblyVersionInfo.tt +++ b/SpacepuppyUnityFramework/Properties/AssemblyVersionInfo.tt @@ -9,7 +9,7 @@ //revision - preview = yyddd, stable = 0 int major = 3; - int minor = 0; + int minor = 1; int build = 1; int revision = 0; @@ -32,4 +32,5 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -[assembly: AssemblyVersion("<#= version #>")] \ No newline at end of file +[assembly: AssemblyVersion("<#= version #>")] +[assembly: AssemblyFileVersion("<#= version #>")] \ No newline at end of file diff --git a/SpacepuppyUnityFramework/PropertyAttributes.cs b/SpacepuppyUnityFramework/PropertyAttributes.cs index edde214..0490db4 100644 --- a/SpacepuppyUnityFramework/PropertyAttributes.cs +++ b/SpacepuppyUnityFramework/PropertyAttributes.cs @@ -362,6 +362,20 @@ public WeightedValueCollectionAttribute(string weightPropName, string valuePropN } } + [System.AttributeUsage(System.AttributeTargets.Field, AllowMultiple = false)] + public class InputIDAttribute : SPPropertyAttribute + { + + public string[] RestrictedTo; + public string[] Exclude; + + public InputIDAttribute() + { + + } + + } + #endregion #region Default Or Configured Property Drawer Attribute diff --git a/SpacepuppyUnityFramework/ProxyTarget.cs b/SpacepuppyUnityFramework/ProxyTarget.cs deleted file mode 100644 index 31aac00..0000000 --- a/SpacepuppyUnityFramework/ProxyTarget.cs +++ /dev/null @@ -1,217 +0,0 @@ -#pragma warning disable 0649 // variable declared but not used. - -using UnityEngine; -using System.Collections.Generic; -using System.Linq; - -using com.spacepuppy.Dynamic; -using com.spacepuppy.Events; -using com.spacepuppy.Utils; - -namespace com.spacepuppy -{ - - /// - /// An IProxy that locates an object by name/tag/type in a scene or entity. - /// - public class ProxyTarget : Triggerable, IDynamic, IProxy - { - - #region Fields - - [SerializeField] - private TriggerableTargetObject _target; - [SerializeField] - [TypeReference.Config(typeof(Component), allowAbstractClasses = true, allowInterfaces = true)] - private TypeReference _componentTypeOnTarget = new TypeReference(); - - [Space()] - [SerializeField] - [Tooltip("Cache the target when it's first retrieved. This is useful for speeding up any 'Find' commands if called repeatedly, but is hindered if the target is changing.")] - private bool _cache; - [System.NonSerialized] - private UnityEngine.Object _object; - - [Space()] - [SerializeField] - private bool _treatAsTriggerable = true; - [SerializeField] - [EnumPopupExcluding((int)TriggerActivationType.SendMessage, (int)TriggerActivationType.CallMethodOnSelectedTarget, (int)TriggerActivationType.EnableTarget)] - private TriggerActivationType _triggerAction; - - #endregion - - #region Properties - - public TriggerActivationType TriggerAction - { - get { return _triggerAction; } - set - { - switch (value) - { - case TriggerActivationType.SendMessage: - case TriggerActivationType.CallMethodOnSelectedTarget: - case TriggerActivationType.EnableTarget: - throw new System.ArgumentOutOfRangeException("TriggerActivationType not supported."); - default: - _triggerAction = value; - break; - } - } - } - - #endregion - - #region IProxy Interface - - bool IProxy.QueriesTarget - { - get { return _target.ImplicityReducesEntireEntity; } - } - - public object GetTarget() - { - if (_cache) - { - if (_object != null) return _object; - - _object = _target.GetTarget(_componentTypeOnTarget.Type ?? typeof(UnityEngine.Object), null) as UnityEngine.Object; - return _object; - } - else - { - return _target.GetTarget(_componentTypeOnTarget.Type ?? typeof(UnityEngine.Object), null) as UnityEngine.Object; - } - } - - public object GetTarget(object arg) - { - if (_cache) - { - if (_object != null) return _object; - - if (_componentTypeOnTarget == null) return null; - _object = _target.GetTarget(_componentTypeOnTarget.Type ?? typeof(UnityEngine.Object), arg) as UnityEngine.Object; - return _object; - } - else - { - if (_componentTypeOnTarget == null) return null; - return _target.GetTarget(_componentTypeOnTarget.Type ?? typeof(UnityEngine.Object), arg) as UnityEngine.Object; - } - } - - public System.Type GetTargetType() - { - if (_componentTypeOnTarget.Type != null) return _componentTypeOnTarget.Type; - return (_cache && _object != null) ? _object.GetType() : typeof(UnityEngine.Object); - } - - #endregion - - #region TriggerableMechanism Interface - - public override bool CanTrigger - { - get { return _treatAsTriggerable && base.CanTrigger; } - } - - public override bool Trigger(object sender, object arg) - { - if (!this.CanTrigger) return false; - - var targ = this.GetTarget(arg); - if (targ == null) return false; - - switch (_triggerAction) - { - case TriggerActivationType.TriggerAllOnTarget: - EventTriggerEvaluator.Current.TriggerAllOnTarget(targ, sender, arg); - return true; - case TriggerActivationType.TriggerSelectedTarget: - EventTriggerEvaluator.Current.TriggerSelectedTarget(targ, sender, arg); - return true; - case TriggerActivationType.DestroyTarget: - EventTriggerEvaluator.Current.DestroyTarget(targ); - return true; - } - - return false; - } - - #endregion - - #region IDynamic Interface - - object IDynamic.this[string sMemberName] - { - get - { - return (this as IDynamic).GetValue(sMemberName); - } - set - { - (this as IDynamic).SetValue(sMemberName, value); - } - } - - bool IDynamic.SetValue(string sMemberName, object value, params object[] index) - { - var targ = this.GetTarget(); - if (targ == null) return false; - return targ.SetValue(sMemberName, value, index); - } - - object IDynamic.GetValue(string sMemberName, params object[] args) - { - var targ = this.GetTarget(); - if (targ == null) return false; - return targ.GetValue(sMemberName, args); - } - - bool IDynamic.TryGetValue(string sMemberName, out object result, params object[] args) - { - var targ = this.GetTarget(); - if (targ == null) - { - result = null; - return false; - } - return targ.TryGetValue(sMemberName, out result, args); - } - - object IDynamic.InvokeMethod(string sMemberName, params object[] args) - { - var targ = this.GetTarget(); - if (targ == null) return false; - return targ.InvokeMethod(sMemberName, args); - } - - bool IDynamic.HasMember(string sMemberName, bool includeNonPublic) - { - var targ = this.GetTarget(); - if (targ == null) return false; - return DynamicUtil.HasMember(targ, sMemberName, includeNonPublic); - } - - IEnumerable IDynamic.GetMembers(bool includeNonPublic) - { - return DynamicUtil.GetMembers(this.GetTarget(), includeNonPublic); - } - - IEnumerable IDynamic.GetMemberNames(bool includeNonPublic) - { - return DynamicUtil.GetMemberNames(this.GetTarget(), includeNonPublic); - } - - System.Reflection.MemberInfo IDynamic.GetMember(string sMemberName, bool includeNonPublic) - { - return DynamicUtil.GetMember(this.GetTarget(), sMemberName, includeNonPublic); - } - - #endregion - - } - -} diff --git a/SpacepuppyUnityFramework/RadicalCoroutine.cs b/SpacepuppyUnityFramework/RadicalCoroutine.cs index 28f0c36..91164d1 100644 --- a/SpacepuppyUnityFramework/RadicalCoroutine.cs +++ b/SpacepuppyUnityFramework/RadicalCoroutine.cs @@ -1343,8 +1343,16 @@ public bool Tick(out object yieldObject) if (_e.MoveNext()) { - yieldObject = _e.Current; - return true; + if (_e == null) + { + yieldObject = null; + return false; + } + else + { + yieldObject = _e.Current; + return true; + } } else { diff --git a/SpacepuppyUnityFramework/SpacepuppyUnityFramework.csproj b/SpacepuppyUnityFramework/SpacepuppyUnityFramework.csproj index d2ac4d6..ba0582b 100644 --- a/SpacepuppyUnityFramework/SpacepuppyUnityFramework.csproj +++ b/SpacepuppyUnityFramework/SpacepuppyUnityFramework.csproj @@ -1,53 +1,25 @@  - - + - Debug - AnyCPU - {3B57DB6B-BA67-46AD-B929-FDD8E6AE511E} - Library - Properties + net35;net471 com.spacepuppy SpacepuppyUnityFramework - v3.5 - 512 - + false + false + false 15.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - true + true true - false - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false + false - - - - ..\Resources\UnityEngine.dll @@ -154,7 +126,6 @@ - TextTemplatingFileGenerator AssemblyVersionInfo.cs @@ -165,7 +136,6 @@ AssemblyVersionInfo.tt - @@ -210,8 +180,6 @@ - + - - \ No newline at end of file diff --git a/SpacepuppyUnityFramework/Utils/ArrayUtil.cs b/SpacepuppyUnityFramework/Utils/ArrayUtil.cs index db09e9a..eb3dbba 100644 --- a/SpacepuppyUnityFramework/Utils/ArrayUtil.cs +++ b/SpacepuppyUnityFramework/Utils/ArrayUtil.cs @@ -11,6 +11,40 @@ namespace com.spacepuppy.Utils public static class ArrayUtil { + +#if NET35 + + public static IEnumerable Append(this IEnumerable lst, T obj) + { + //foreach (var o in lst) + //{ + // yield return o; + //} + var e = new LightEnumerator(lst); + while (e.MoveNext()) + { + yield return e.Current; + } + yield return obj; + } + + public static IEnumerable Prepend(this IEnumerable lst, T obj) + { + yield return obj; + //foreach (var o in lst) + //{ + // yield return o; + //} + var e = new LightEnumerator(lst); + while (e.MoveNext()) + { + yield return e.Current; + } + } + +#endif + + #region General Methods public static bool IsEmpty(this IEnumerable lst) @@ -123,34 +157,6 @@ public static bool ContainsAny(this IEnumerable lst, IEnumerable objs) return lst.Intersect(objs).Count() > 0; } - public static IEnumerable Append(this IEnumerable lst, T obj) - { - //foreach (var o in lst) - //{ - // yield return o; - //} - var e = new LightEnumerator(lst); - while (e.MoveNext()) - { - yield return e.Current; - } - yield return obj; - } - - public static IEnumerable Prepend(this IEnumerable lst, T obj) - { - yield return obj; - //foreach (var o in lst) - //{ - // yield return o; - //} - var e = new LightEnumerator(lst); - while(e.MoveNext()) - { - yield return e.Current; - } - } - public static bool Contains(this IEnumerable lst, object obj) { //foreach (var o in lst) @@ -265,9 +271,9 @@ public static IEnumerable Except(this IEnumerable lst, T element, IEqua } } - #endregion +#endregion - #region Random Methods +#region Random Methods public static void Shuffle(T[] arr, IRandom rng = null) { @@ -417,9 +423,9 @@ public static T PickRandom(this IEnumerable lst, System.Func wei } } - #endregion +#endregion - #region Array Methods +#region Array Methods public static T[] Empty() { @@ -493,9 +499,9 @@ public static void Copy(IEnumerable source, System.Array destination, int } - #endregion +#endregion - #region HashSet Methods +#region HashSet Methods public static T Pop(this HashSet set) { @@ -511,9 +517,9 @@ public static T Pop(this HashSet set) throw new System.ArgumentException("HashSet must not be empty."); } - #endregion +#endregion - #region Special Types +#region Special Types private class TempArray { @@ -651,7 +657,7 @@ public static void Release(T[] arr) } } - #endregion +#endregion } diff --git a/SpacepuppyUnityFramework/Utils/CoroutineUtil.cs b/SpacepuppyUnityFramework/Utils/CoroutineUtil.cs index e395152..3703538 100644 --- a/SpacepuppyUnityFramework/Utils/CoroutineUtil.cs +++ b/SpacepuppyUnityFramework/Utils/CoroutineUtil.cs @@ -243,7 +243,7 @@ public static RadicalCoroutine Invoke(this MonoBehaviour behaviour, System.Actio return StartRadicalCoroutine(behaviour, RadicalInvokeRedirect(method, delay, -1f, time), disableMode); } - public static IRadicalWaitHandle InvokeGuaranteed(this MonoBehaviour behaviour, System.Action method, float delay, ITimeSupplier time = null) + public static InvokeHandle InvokeGuaranteed(this MonoBehaviour behaviour, System.Action method, float delay, ITimeSupplier time = null) { if (method == null) throw new System.ArgumentNullException("method"); //return StartRadicalCoroutine(GameLoop.Hook, RadicalInvokeRedirect(method, delay, -1f, time)); diff --git a/SpacepuppyUnityFramework/Utils/GameObjUtil.cs b/SpacepuppyUnityFramework/Utils/GameObjUtil.cs index ad8a830..e6efcfa 100644 --- a/SpacepuppyUnityFramework/Utils/GameObjUtil.cs +++ b/SpacepuppyUnityFramework/Utils/GameObjUtil.cs @@ -274,15 +274,7 @@ public static GameObject FindTrueRoot(this GameObject go) if (entity != null) return entity.gameObject; else - { - //var t = go.transform; - //while (t != null) - //{ - // if (MultiTagHelper.HasTag(t, SPConstants.TAG_ROOT)) return t.gameObject; - // t = t.parent; - //} - return null; - } + return FindParentWithTag(go.transform, SPConstants.TAG_ROOT); } public static GameObject FindTrueRoot(this Component c) @@ -293,15 +285,7 @@ public static GameObject FindTrueRoot(this Component c) if (entity != null) return entity.gameObject; else - { - //var t = c.transform; - //while (t != null) - //{ - // if (MultiTagHelper.HasTag(t, SPConstants.TAG_ROOT)) return t.gameObject; - // t = t.parent; - //} - return null; - } + return FindParentWithTag(c.transform, SPConstants.TAG_ROOT); } /// @@ -318,9 +302,8 @@ public static GameObject FindRoot(this GameObject go) return entity.gameObject; else { - //var root = FindTrueRoot(go); - //return (root != null) ? root : go; //we return self if no root was found... - return null; + var root = FindParentWithTag(go.transform, SPConstants.TAG_ROOT); + return (root != null) ? root : go; //we return self if no root was found... } } @@ -333,9 +316,8 @@ public static GameObject FindRoot(this Component c) return entity.gameObject; else { - //var root = FindTrueRoot(c); - //return (root != null) ? root : c.gameObject; - return null; + var root = FindParentWithTag(c.transform, SPConstants.TAG_ROOT); + return (root != null) ? root : c.gameObject; //we return self if no root was found... } } diff --git a/SpacepuppyUnityFramework/Utils/Messaging.cs b/SpacepuppyUnityFramework/Utils/Messaging.cs index 53d8a22..6212fe2 100644 --- a/SpacepuppyUnityFramework/Utils/Messaging.cs +++ b/SpacepuppyUnityFramework/Utils/Messaging.cs @@ -182,10 +182,11 @@ public static void FindAndBroadcast(System.Action functor, bool includeDis { if (functor == null) throw new System.ArgumentNullException("functor"); - using (var lst = TempCollection.GetSet()) + using (var coll = TempCollection.GetSet()) { - ObjUtil.FindObjectsOfInterface(lst); - var e = lst.GetEnumerator(); + ObjUtil.FindObjectsOfInterface(coll); + GlobalMessagePool.CopyReceivers(coll); + var e = coll.GetEnumerator(); while (e.MoveNext()) { if (includeDisabledComponents || TargetIsValid(e.Current)) @@ -205,10 +206,11 @@ public static void FindAndBroadcast(TArg arg, System.Action()) + using (var coll = TempCollection.GetSet()) { - ObjUtil.FindObjectsOfInterface(lst); - var e = lst.GetEnumerator(); + ObjUtil.FindObjectsOfInterface(coll); + GlobalMessagePool.CopyReceivers(coll); + var e = coll.GetEnumerator(); while (e.MoveNext()) { if (includeDisabledComponents || TargetIsValid(e.Current)) @@ -449,9 +451,23 @@ public static void Remove(T listener) public static T[] CopyReceivers() { + if (_receivers == null || _receivers.Count == 0) return ArrayUtil.Empty(); return _receivers.ToArray(); } + public static int CopyReceivers(ICollection coll) + { + if (_receivers == null || _receivers.Count == 0) return 0; + + int cnt = coll.Count; + var e = _receivers.GetEnumerator(); + while (e.MoveNext()) + { + coll.Add(e.Current); + } + return coll.Count - cnt; + } + public static void Execute(System.Action functor) { if (_state != ExecutingState.None) throw new System.InvalidOperationException("Can not globally broadcast a message currently executing."); diff --git a/SpacepuppyUnityFramework/Utils/VectorUtil.cs b/SpacepuppyUnityFramework/Utils/VectorUtil.cs index 9e1778a..84a6916 100644 --- a/SpacepuppyUnityFramework/Utils/VectorUtil.cs +++ b/SpacepuppyUnityFramework/Utils/VectorUtil.cs @@ -267,14 +267,17 @@ public static float AngleBetween(Vector3 a, Vector3 b) { // // Due to float error the dot / mag can sometimes be ever so slightly over 1, which can cause NaN in acos. //return Mathf.Acos(Vector3.Dot(a, b) / (a.magnitude * b.magnitude)) * MathUtil.RAD_TO_DEG; - double d = (double)Vector3.Dot(a, b) / ((double)a.magnitude * (double)b.magnitude); + double d = System.Math.Sqrt((double)a.sqrMagnitude * (double)b.sqrMagnitude); + if (d < MathUtil.DBL_EPSILON) return 0f; + + d = (double)Vector3.Dot(a, b) / d; if (d >= 1d) return 0f; else if (d <= -1d) return 180f; return (float)System.Math.Acos(d) * MathUtil.RAD_TO_DEG; } /// - /// Returns a vector adjacent to up in the general direction of forward. + /// Returns a vector orthogonal to up in the general direction of forward. /// /// /// @@ -845,6 +848,27 @@ public static void Set(ref Vector3 v, CartesianAxis axis, float value) } } + public static float Get(this Vector3 v, CartesianAxis axis) + { + switch (axis) + { + case CartesianAxis.Zneg: + return -v.z; + case CartesianAxis.Yneg: + return -v.y; + case CartesianAxis.Xneg: + return -v.x; + case CartesianAxis.X: + return v.x; + case CartesianAxis.Y: + return v.y; + case CartesianAxis.Z: + return v.z; + default: + return 0f; + } + } + public static Vector3 GetUnitVector(CartesianAxis axis) { switch (axis) diff --git a/SpacepuppyUnityFrameworkEditor/EditorHelper.cs b/SpacepuppyUnityFrameworkEditor/EditorHelper.cs index 68e3d7a..a0245f3 100644 --- a/SpacepuppyUnityFrameworkEditor/EditorHelper.cs +++ b/SpacepuppyUnityFrameworkEditor/EditorHelper.cs @@ -530,6 +530,65 @@ public static SerializedPropertyType GetPropertyType(System.Type tp) } } + public static double GetNumericValue(this SerializedProperty prop) + { + switch(prop.propertyType) + { + case SerializedPropertyType.Integer: + return (double)prop.intValue; + case SerializedPropertyType.Boolean: + return prop.boolValue ? 1d : 0d; + case SerializedPropertyType.Float: + return prop.type == "double" ? prop.doubleValue : (double)prop.floatValue; + case SerializedPropertyType.ArraySize: + return (double)prop.arraySize; + case SerializedPropertyType.Character: + return (double)prop.intValue; + default: + return 0d; + } + } + + public static void SetNumericValue(this SerializedProperty prop, double value) + { + switch (prop.propertyType) + { + case SerializedPropertyType.Integer: + prop.intValue = (int)value; + break; + case SerializedPropertyType.Boolean: + prop.boolValue = (System.Math.Abs(value) > MathUtil.DBL_EPSILON); + break; + case SerializedPropertyType.Float: + if (prop.type == "double") + prop.doubleValue = value; + else + prop.floatValue = (float)value; + break; + case SerializedPropertyType.ArraySize: + prop.arraySize = (int)value; + break; + case SerializedPropertyType.Character: + prop.intValue = (int)value; + break; + } + } + + public static bool IsNumericValue(this SerializedProperty prop) + { + switch (prop.propertyType) + { + case SerializedPropertyType.Integer: + case SerializedPropertyType.Boolean: + case SerializedPropertyType.Float: + case SerializedPropertyType.ArraySize: + case SerializedPropertyType.Character: + return true; + default: + return false; + } + } + public static int GetChildPropertyCount(SerializedProperty property, bool includeGrandChildren = false) @@ -652,7 +711,34 @@ private static void OnSceneGUI(SceneView scene) #endregion - #region Enum Utils + #region Value Utils + + /// + /// An editor time safe version of DynamicUtil.GetValueWithMember that attempts to not leak various values into the scene (like materials). + /// + /// + /// + /// + /// + public static object GetValueWithMemberSafe(MemberInfo info, object targObj, bool ignoreMethod) + { + if (info == null) return null; + targObj = ObjUtil.ReduceIfProxy(targObj); + + var tp = info.DeclaringType; + if (TypeUtil.IsType(tp, typeof(Renderer))) + { + switch (info.Name) + { + case "material": + return DynamicUtil.GetValue(targObj, "sharedMaterial"); + case "materials": + return DynamicUtil.GetValue(targObj, "sharedMaterials"); + } + } + + return DynamicUtil.GetValueWithMember(info, targObj, ignoreMethod); + } public static int ConvertPopupMaskToEnumMask(int mask, System.Enum[] enumFlagValues) { diff --git a/SpacepuppyUnityFrameworkEditor/Properties/AssemblyInfo.cs b/SpacepuppyUnityFrameworkEditor/Properties/AssemblyInfo.cs deleted file mode 100644 index 514be3e..0000000 --- a/SpacepuppyUnityFrameworkEditor/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SpacepuppyUnityFrameworkEditor")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SpacepuppyUnityFrameworkEditor")] -[assembly: AssemblyCopyright("Copyright © 2017")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("7fe0b8d6-ba29-43a6-b272-5d4f442fc4fa")] diff --git a/SpacepuppyUnityFrameworkEditor/PropertyAttributeDrawers/InputIDPropertyDrawer.cs b/SpacepuppyUnityFrameworkEditor/PropertyAttributeDrawers/InputIDPropertyDrawer.cs new file mode 100644 index 0000000..b1d2cd9 --- /dev/null +++ b/SpacepuppyUnityFrameworkEditor/PropertyAttributeDrawers/InputIDPropertyDrawer.cs @@ -0,0 +1,41 @@ +using UnityEngine; +using UnityEditor; +using System.Collections.Generic; +using System.Linq; + +using com.spacepuppy; +using com.spacepuppy.Utils; + +using com.spacepuppyeditor.Settings; + +namespace com.spacepuppyeditor.PropertyAttributeDrawers +{ + + [CustomPropertyDrawer(typeof(InputIDAttribute))] + public class InputIDPropertyDrawer : PropertyDrawer + { + + private string[] _inputIds; + + private void Init() + { + _inputIds = InputSettings.GetGlobalInputIds(); + } + + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + if (property.propertyType == SerializedPropertyType.String) + { + if (_inputIds == null) this.Init(); + + property.stringValue = SPEditorGUI.OptionPopupWithCustom(position, label, property.stringValue, _inputIds); + } + else + { + EditorGUI.PropertyField(position, property, label); + } + } + + } + +} diff --git a/SpacepuppyUnityFrameworkEditor/PropertyAttributeDrawers/ReorderableArrayPropertyDrawer.cs b/SpacepuppyUnityFrameworkEditor/PropertyAttributeDrawers/ReorderableArrayPropertyDrawer.cs index 7d9c634..6d85d0b 100644 --- a/SpacepuppyUnityFrameworkEditor/PropertyAttributeDrawers/ReorderableArrayPropertyDrawer.cs +++ b/SpacepuppyUnityFrameworkEditor/PropertyAttributeDrawers/ReorderableArrayPropertyDrawer.cs @@ -45,7 +45,23 @@ public class ReorderableArrayPropertyDrawer : PropertyDrawer, IArrayHandlingProp #region CONSTRUCTOR - private CachedReorderableList GetList(SerializedProperty property, GUIContent label) + public ReorderableArrayPropertyDrawer() + { + + } + + /// + /// Use this to set the element type of the list for drag & drop, if you're manually calling the drawer. + /// + /// + public ReorderableArrayPropertyDrawer(System.Type elementType) + { + this.ElementType = elementType; + } + + + + protected virtual CachedReorderableList GetList(SerializedProperty property, GUIContent label) { var lst = CachedReorderableList.GetListDrawer(property, _maskList_DrawHeader, _maskList_DrawElement, _addCallback); lst.draggable = _draggable; @@ -133,6 +149,8 @@ private void StartOnGUI(SerializedProperty property, GUIContent label) _lst = this.GetList(property, label); if (_lst.index >= _lst.count) _lst.index = -1; + + if (this.fieldInfo != null) this.ElementType = TypeUtil.GetElementTypeOfListType(this.fieldInfo.FieldType); } private void EndOnGUI(SerializedProperty property, GUIContent label) @@ -219,6 +237,15 @@ public bool AllowDragAndDrop set { _allowDragAndDrop = false; } } + /// + /// The type of the element in the array/list, will effect drag & drop filtering (unless overriden). + /// + public System.Type ElementType + { + get; + set; + } + #endregion #region OnGUI @@ -313,31 +340,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten } } - if (_allowDragAndDrop && this.fieldInfo != null && Event.current != null) - { - var ev = Event.current; - switch (ev.type) - { - case EventType.DragUpdated: - case EventType.DragPerform: - { - if (listArea.Contains(ev.mousePosition)) - { - var tp = TypeUtil.GetElementTypeOfListType(this.fieldInfo.FieldType); - var refs = (from o in DragAndDrop.objectReferences let obj = ObjUtil.GetAsFromSource(tp, o, false) where obj != null select obj); - DragAndDrop.visualMode = refs.Any() ? DragAndDropVisualMode.Link : DragAndDropVisualMode.Rejected; - - if (ev.type == EventType.DragPerform && refs.Any()) - { - DragAndDrop.AcceptDrag(); - AddObjectsToARray(property, refs.ToArray()); - GUI.changed = true; - } - } - } - break; - } - } + this.DoDragAndDrop(property, listArea); if (property.isExpanded && _drawElementAtBottom && _lst.index >= 0 && _lst.index < property.arraySize) { @@ -512,6 +515,38 @@ protected virtual float GetElementHeight(SerializedProperty element, GUIContent #endregion + #region Drag & Drop + + protected virtual void DoDragAndDrop(SerializedProperty property, Rect listArea) + { + if (_allowDragAndDrop && this.ElementType != null && Event.current != null) + { + var ev = Event.current; + switch (ev.type) + { + case EventType.DragUpdated: + case EventType.DragPerform: + { + if (listArea.Contains(ev.mousePosition)) + { + var refs = (from o in DragAndDrop.objectReferences let obj = ObjUtil.GetAsFromSource(this.ElementType, o, false) where obj != null select obj); + DragAndDrop.visualMode = refs.Any() ? DragAndDropVisualMode.Link : DragAndDropVisualMode.Rejected; + + if (ev.type == EventType.DragPerform && refs.Any()) + { + DragAndDrop.AcceptDrag(); + AddObjectsToArray(property, refs.ToArray()); + GUI.changed = true; + } + } + } + break; + } + } + } + + #endregion + protected GUIContent TempElementLabel(SerializedProperty element, int index) { @@ -555,7 +590,7 @@ protected static bool ElementIsFlatChildField(SerializedProperty property) return property.hasChildren && property.propertyType == SerializedPropertyType.Generic; } - private static void AddObjectsToARray(SerializedProperty listProp, object[] objs) + private static void AddObjectsToArray(SerializedProperty listProp, object[] objs) { if (listProp == null) throw new System.ArgumentNullException("listProp"); if (!listProp.isArray) throw new System.ArgumentException("Must be a SerializedProperty for an array/list.", "listProp"); diff --git a/SpacepuppyUnityFrameworkEditor/PropertyAttributeDrawers/TimeUnitsSelectorPropertyDrawer.cs b/SpacepuppyUnityFrameworkEditor/PropertyAttributeDrawers/TimeUnitsSelectorPropertyDrawer.cs index efc4cf5..fca12d3 100644 --- a/SpacepuppyUnityFrameworkEditor/PropertyAttributeDrawers/TimeUnitsSelectorPropertyDrawer.cs +++ b/SpacepuppyUnityFrameworkEditor/PropertyAttributeDrawers/TimeUnitsSelectorPropertyDrawer.cs @@ -103,16 +103,23 @@ public Rect DrawDuration(Rect position, SerializedProperty property, float desir var r = new Rect(position.xMin, position.yMin, Mathf.Min(position.width, desiredWidth), position.height); - var units = GetUnits(property, this.attribute as TimeUnitsSelectorAttribute, this.TimeUnitsCalculator); - - double dur = property.doubleValue; - if (MathUtil.IsReal(dur)) dur = this.TimeUnitsCalculator.SecondsToTimeUnits(units, dur); - EditorGUI.BeginChangeCheck(); - dur = EditorGUI.DoubleField(r, (float)dur); - if (EditorGUI.EndChangeCheck()) + if (property.IsNumericValue()) + { + var units = GetUnits(property, this.attribute as TimeUnitsSelectorAttribute, this.TimeUnitsCalculator); + + double dur = property.GetNumericValue(); + if (MathUtil.IsReal(dur)) dur = this.TimeUnitsCalculator.SecondsToTimeUnits(units, dur); + EditorGUI.BeginChangeCheck(); + dur = EditorGUI.DoubleField(r, (float)dur); + if (EditorGUI.EndChangeCheck()) + { + if (MathUtil.IsReal(dur)) dur = this.TimeUnitsCalculator.TimeUnitsToSeconds(units, dur); + property.SetNumericValue(dur); + } + } + else { - if(MathUtil.IsReal(dur)) dur = this.TimeUnitsCalculator.TimeUnitsToSeconds(units, dur); - property.doubleValue = dur; + EditorGUI.LabelField(r, "Unsupported type: " + property.type); } return new Rect(r.xMax, position.yMin, Mathf.Max(position.width - r.width, 0f), position.height); diff --git a/SpacepuppyUnityFrameworkEditor/PropertyAttributeDrawers/WeightedValueCollectionPropertyDrawer.cs b/SpacepuppyUnityFrameworkEditor/PropertyAttributeDrawers/WeightedValueCollectionPropertyDrawer.cs index 9c071b3..ee3677b 100644 --- a/SpacepuppyUnityFrameworkEditor/PropertyAttributeDrawers/WeightedValueCollectionPropertyDrawer.cs +++ b/SpacepuppyUnityFrameworkEditor/PropertyAttributeDrawers/WeightedValueCollectionPropertyDrawer.cs @@ -1,5 +1,6 @@ using UnityEngine; using UnityEditor; +using UnityEditorInternal; using System.Collections.Generic; using System.Linq; @@ -29,7 +30,7 @@ public string ValuePropertyName } #endregion - + public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { if (!property.isArray) @@ -92,7 +93,26 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten base.OnGUI(position, property, label); } + + + + #region Reorderable List + protected override CachedReorderableList GetList(SerializedProperty property, GUIContent label) + { + var result = base.GetList(property, label); + result.onAddCallback = (lst) => + { + ReorderableList.defaultBehaviours.DoAddButton(lst); + if (lst.serializedProperty != null && lst.serializedProperty.arraySize > 0) + { + var element = lst.serializedProperty.GetArrayElementAtIndex(lst.serializedProperty.arraySize - 1); + if (element != null) this.SetWeight(element, 1f); + } + }; + return result; + } + protected override void DrawElement(Rect area, SerializedProperty element, GUIContent label, int elementIndex) { var weightProp = element.FindPropertyRelative(this.WeightPropertyName); @@ -145,6 +165,97 @@ protected virtual void DrawElementValue(Rect area, SerializedProperty element, G } } + #endregion + + #region Drag & Drop + + protected override void DoDragAndDrop(SerializedProperty property, Rect listArea) + { + if (this.AllowDragAndDrop && this.fieldInfo != null && Event.current != null) + { + var ev = Event.current; + switch (ev.type) + { + case EventType.DragUpdated: + case EventType.DragPerform: + { + if (listArea.Contains(ev.mousePosition)) + { + DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; //default + + var valueMember = com.spacepuppy.Dynamic.DynamicUtil.GetMemberFromType(TypeUtil.GetElementTypeOfListType(this.fieldInfo.FieldType), this.ValuePropertyName, true); + if (valueMember == null) return; + var tp = com.spacepuppy.Dynamic.DynamicUtil.GetReturnType(valueMember); + if (tp == null) return; + + var refs = (from o in DragAndDrop.objectReferences let obj = ObjUtil.GetAsFromSource(tp, o, false) where obj != null select obj); + DragAndDrop.visualMode = refs.Any() ? DragAndDropVisualMode.Link : DragAndDropVisualMode.Rejected; + + if (ev.type == EventType.DragPerform && refs.Any()) + { + DragAndDrop.AcceptDrag(); + this.AddObjectsToArray(property, refs.ToArray()); + GUI.changed = true; + } + } + } + break; + } + } + } + + private void AddObjectsToArray(SerializedProperty listProp, object[] objs) + { + if (listProp == null) throw new System.ArgumentNullException("listProp"); + if (!listProp.isArray) throw new System.ArgumentException("Must be a SerializedProperty for an array/list.", "listProp"); + if (objs == null || objs.Length == 0) return; + + try + { + int start = listProp.arraySize; + listProp.arraySize += objs.Length; + for (int i = 0; i < objs.Length; i++) + { + var element = listProp.GetArrayElementAtIndex(start + i); + if (element != null) + { + this.SetWeight(element, 1f); + var objProp = element.FindPropertyRelative(this.ValuePropertyName); + if (objProp != null && objProp.propertyType == SerializedPropertyType.ObjectReference) + { + objProp.objectReferenceValue = objs[i] as UnityEngine.Object; + } + } + } + } + catch (System.Exception ex) + { + Debug.LogException(ex); + } + } + + #endregion + + #region Static Utils + + private void SetWeight(SerializedProperty element, float value) + { + var weight = element.FindPropertyRelative(this.WeightPropertyName); + if (weight == null) return; + + switch (weight.propertyType) + { + case SerializedPropertyType.Float: + weight.floatValue = value; + break; + case SerializedPropertyType.Integer: + weight.intValue = (int)value; + break; + } + } + + #endregion + } } diff --git a/SpacepuppyUnityFrameworkEditor/SPEditorGUI.cs b/SpacepuppyUnityFrameworkEditor/SPEditorGUI.cs index fc9bab2..86d5297 100644 --- a/SpacepuppyUnityFrameworkEditor/SPEditorGUI.cs +++ b/SpacepuppyUnityFrameworkEditor/SPEditorGUI.cs @@ -586,7 +586,7 @@ public static System.Enum EnumPopupExcluding(Rect position, GUIContent label, Sy public static string OptionPopupWithCustom(Rect position, string label, string value, string[] options) { if (options == null) options = ArrayUtil.Empty(); - + var guiOptions = (from s in options select EditorHelper.TempContent(s)).Append(EditorHelper.TempContent("Custom...")).ToArray(); int index = System.Array.IndexOf(options, value); @@ -1190,10 +1190,26 @@ private static GUIStyle GetCurveTextureStyle(Texture2D tex) /// public static string ReflectedPropertyField(Rect position, GUIContent label, object targObj, string selectedMemberName, DynamicMemberAccess access, out System.Reflection.MemberInfo selectedMember, bool allowSetterMethods = false) { - if(targObj is IDynamic) + if (targObj is IDynamic || targObj is IProxy) { var mask = allowSetterMethods ? System.Reflection.MemberTypes.Field | System.Reflection.MemberTypes.Property | System.Reflection.MemberTypes.Method : System.Reflection.MemberTypes.Field | System.Reflection.MemberTypes.Property; - var members = DynamicUtil.GetEasilySerializedMembers(targObj, mask, access).ToArray(); + System.Reflection.MemberInfo[] members = null; + System.Type targTp = null; + if (targObj is IDynamic) + { + targTp = targObj.GetType(); + members = DynamicUtil.GetEasilySerializedMembers(targObj, mask, access).ToArray(); + } + else if (targObj is IProxy) + { + targTp = (targObj as IProxy).GetTargetType(); + members = DynamicUtil.GetEasilySerializedMembersFromType(targTp, mask, access).ToArray(); + } + else + { + targTp = typeof(object); + members = ArrayUtil.Empty(); + } var entries = new GUIContent[members.Length + 1]; int index = -1; @@ -1201,9 +1217,9 @@ public static string ReflectedPropertyField(Rect position, GUIContent label, obj { var m = members[i]; if ((DynamicUtil.GetMemberAccessLevel(m) & DynamicMemberAccess.Write) != 0) - entries[i] = EditorHelper.TempContent(string.Format("{0} ({1}) -> {2}", m.Name, DynamicUtil.GetReturnType(m).Name, DynamicUtil.GetValueWithMember(m, targObj, true))); + entries[i] = EditorHelper.TempContent(string.Format("{0} ({1}) -> {2}", m.Name, DynamicUtil.GetReturnType(m).Name, EditorHelper.GetValueWithMemberSafe(m, targObj, true))); else - entries[i] = EditorHelper.TempContent(string.Format("{0} (readonly - {1}) -> {2}", m.Name, DynamicUtil.GetReturnType(m).Name, DynamicUtil.GetValueWithMember(m, targObj, true))); + entries[i] = EditorHelper.TempContent(string.Format("{0} (readonly - {1}) -> {2}", m.Name, DynamicUtil.GetReturnType(m).Name, EditorHelper.GetValueWithMemberSafe(m, targObj, true))); if (index < 0 && m.Name == selectedMemberName) { @@ -1235,12 +1251,12 @@ public static string ReflectedPropertyField(Rect position, GUIContent label, obj else { selectedMemberName = EditorGUI.TextField(r1, selectedMemberName); - selectedMember = new DynamicPropertyInfo(selectedMemberName, targObj.GetType(), typeof(Variant)); + selectedMember = new DynamicPropertyInfo(selectedMemberName, targTp, typeof(Variant)); return selectedMemberName; } } } - if (targObj != null) + else if (targObj != null) { var members = DynamicUtil.GetEasilySerializedMembers(targObj, System.Reflection.MemberTypes.Field | System.Reflection.MemberTypes.Property | System.Reflection.MemberTypes.Method, access).ToArray(); var entries = new GUIContent[members.Length]; @@ -1250,9 +1266,9 @@ public static string ReflectedPropertyField(Rect position, GUIContent label, obj { var m = members[i]; if((DynamicUtil.GetMemberAccessLevel(m) & DynamicMemberAccess.Write) != 0) - entries[i] = EditorHelper.TempContent(string.Format("{0} ({1}) -> {2}", m.Name, DynamicUtil.GetReturnType(m).Name, DynamicUtil.GetValueWithMember(m, targObj, true))); + entries[i] = EditorHelper.TempContent(string.Format("{0} ({1}) -> {2}", m.Name, DynamicUtil.GetReturnType(m).Name, EditorHelper.GetValueWithMemberSafe(m, targObj, true))); else - entries[i] = EditorHelper.TempContent(string.Format("{0} (readonly - {1}) -> {2}", m.Name, DynamicUtil.GetReturnType(m).Name, DynamicUtil.GetValueWithMember(m, targObj, true))); + entries[i] = EditorHelper.TempContent(string.Format("{0} (readonly - {1}) -> {2}", m.Name, DynamicUtil.GetReturnType(m).Name, EditorHelper.GetValueWithMemberSafe(m, targObj, true))); if (index < 0 && m.Name == selectedMemberName) { diff --git a/SpacepuppyUnityFrameworkEditor/Settings/BuildSettings.cs b/SpacepuppyUnityFrameworkEditor/Settings/BuildSettings.cs index 692e6cd..ba2259c 100644 --- a/SpacepuppyUnityFrameworkEditor/Settings/BuildSettings.cs +++ b/SpacepuppyUnityFrameworkEditor/Settings/BuildSettings.cs @@ -255,7 +255,7 @@ public virtual bool Build(string path, PostBuildOption option) } } - BuildPipeline.BuildPlayer(scenes, path, this.BuildTarget, this.BuildOptions); + var report = BuildPipeline.BuildPlayer(scenes, path, this.BuildTarget, this.BuildOptions); if (cacheInputs != null) { @@ -283,19 +283,26 @@ public virtual bool Build(string path, PostBuildOption option) } } - //save - if ((option & PostBuildOption.OpenFolder) != 0) + if (report != null && report.summary.result == UnityEditor.Build.Reporting.BuildResult.Succeeded) { - EditorUtility.RevealInFinder(path); + //save + if ((option & PostBuildOption.OpenFolder) != 0) + { + EditorUtility.RevealInFinder(path); + } + if ((option & PostBuildOption.Run) != 0) + { + var proc = new System.Diagnostics.Process(); + proc.StartInfo.FileName = path; + proc.Start(); + } + + return true; } - if ((option & PostBuildOption.Run) != 0) + else { - var proc = new System.Diagnostics.Process(); - proc.StartInfo.FileName = path; - proc.Start(); + return false; } - - return true; } } diff --git a/SpacepuppyUnityFrameworkEditor/Settings/InputSettings.cs b/SpacepuppyUnityFrameworkEditor/Settings/InputSettings.cs index 27ad7bb..a6426c5 100644 --- a/SpacepuppyUnityFrameworkEditor/Settings/InputSettings.cs +++ b/SpacepuppyUnityFrameworkEditor/Settings/InputSettings.cs @@ -421,6 +421,51 @@ public void ApplyToSerializedProperty(SerializedProperty prop) #endregion + #region Static Utils + + private static System.Func _overrideGetGlobalInputIds; + /// + /// Get the input id's that should show up in a drop down list for any InputID property. This includes in the t_OnSimpleButtonPress editor. + /// + /// Set this delegate to override the default entries as defined in InputManager.asset. This can be useful if you're using a custom input system + /// that has named inputs unique from what is found in the InputSettings.asset configuration. + /// + public static System.Func GetGlobalInputIds + { + get + { + if (_overrideGetGlobalInputIds == null) _overrideGetGlobalInputIds = GetGlobalInputIdsDefault; + return _overrideGetGlobalInputIds; + } + set + { + _overrideGetGlobalInputIds = value; + } + } + + public static string[] GetGlobalInputIdsDefault() + { + var asset = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset").FirstOrDefault(); + if (asset != null) + { + var obj = new SerializedObject(asset); + var axes = obj.FindProperty(PROP_AXES); + string[] arr = new string[axes.arraySize]; + for (int i = 0; i < arr.Length; i++) + { + arr[i] = axes.GetArrayElementAtIndex(i).FindPropertyRelative("m_Name").stringValue; + } + obj.Dispose(); + return arr; + } + else + { + return com.spacepuppy.Utils.ArrayUtil.Empty(); + } + } + + #endregion + } [CustomEditor(typeof(InputSettings), true)] diff --git a/SpacepuppyUnityFrameworkEditor/SpacepuppyUnityFrameworkEditor.csproj b/SpacepuppyUnityFrameworkEditor/SpacepuppyUnityFrameworkEditor.csproj index 94b9d9c..023eb97 100644 --- a/SpacepuppyUnityFrameworkEditor/SpacepuppyUnityFrameworkEditor.csproj +++ b/SpacepuppyUnityFrameworkEditor/SpacepuppyUnityFrameworkEditor.csproj @@ -1,42 +1,16 @@  - - + - Debug - AnyCPU - {7FE0B8D6-BA29-43A6-B272-5D4F442FC4FA} - Library - Properties + net35;net471 com.spacepuppyeditor SpacepuppyUnityFrameworkEditor - v3.5 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false + false + false - - - - + + + ..\Resources\UnityEditor.dll @@ -51,124 +25,6 @@ - - Properties\AssemblyVersionInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {3b57db6b-ba67-46ad-b929-fdd8e6ae511e} - SpacepuppyUnityFramework - + - - \ No newline at end of file