diff --git a/Assets/Editor/BFResourceTools/PrefabTools/RaycastTargetTool/CheckRaycastTargetWindow.cs b/Assets/Editor/BFResourceTools/PrefabTools/RaycastTargetTool/CheckRaycastTargetWindow.cs index 7eacf931e..bef8a6f4a 100644 --- a/Assets/Editor/BFResourceTools/PrefabTools/RaycastTargetTool/CheckRaycastTargetWindow.cs +++ b/Assets/Editor/BFResourceTools/PrefabTools/RaycastTargetTool/CheckRaycastTargetWindow.cs @@ -1,117 +1,117 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; -using UnityEditor.Experimental.SceneManagement; - -namespace BFEditor.Resource -{ - public class CheckRaycastTargetWindow : EditorWindow - { - ShowRaycast raycastHelper; - RectTransform rt; - Vector2 scrollPos; - - CheckRaycastTargetWindow() - { - this.titleContent = new GUIContent("检查RaycastTarget"); - } - - void OnEnable() - { - PrefabStage currentPrefabStage = PrefabStageUtility.GetCurrentPrefabStage(); - Transform tran; - if (currentPrefabStage == null) - tran = Selection.activeTransform; - else - tran = currentPrefabStage.prefabContentsRoot.transform; - if (tran != null) - rt = tran.GetComponent(); - if (rt != null) - { - raycastHelper = rt.GetComponent(); - if (raycastHelper == null) - raycastHelper = rt.gameObject.AddComponent(); - raycastHelper.SetEditorWindowMode(true); - } - } - - void OnGUI() - { - GUILayout.BeginVertical(); - EditorGUI.BeginChangeCheck(); - rt = (RectTransform)EditorGUILayout.ObjectField("", rt, typeof(RectTransform), true, GUILayout.Width(200)); - GUILayout.Space(6); - if (EditorGUI.EndChangeCheck()) - { - if (raycastHelper != null) - DestroyImmediate(raycastHelper); - if (rt != null) - { - raycastHelper = rt.GetComponent(); - if (raycastHelper == null) - raycastHelper = rt.gameObject.AddComponent(); - raycastHelper.SetEditorWindowMode(true); - } - } - if (raycastHelper != null) - { - GUILayout.Label(string.Format("raycastTarget组件一共有 {0} 个", raycastHelper.GetTotalCount())); - GUILayout.Label("(红色)image " + raycastHelper.GetImageCount() + - " (绿色)text " + raycastHelper.GetTextCount()); - GUILayout.Label("(黄色)emptyRaycast " + raycastHelper.GetEmptyCount() + - " (蓝色)rawImage " + raycastHelper.GetRawImageCount()); - GUILayout.Space(6); - scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Width(400), GUILayout.Height(270)); - List pathList = raycastHelper.GetImagePathList(); - int i = 0; - if (pathList.Count > 0) - { - GUILayout.Label("image路径:"); - for (; i < pathList.Count; i++) - GUILayout.Label(pathList[i]); - } - pathList = raycastHelper.GetTextPathList(); - i = 0; - if (pathList.Count > 0) - { - GUILayout.Label("text路径:"); - for (; i < pathList.Count; i++) - GUILayout.Label(pathList[i]); - } - pathList = raycastHelper.GetEmptyPathList(); - i = 0; - if (pathList.Count > 0) - { - GUILayout.Label("emptyRaycast路径:"); - for (; i < pathList.Count; i++) - GUILayout.Label(pathList[i]); - } - pathList = raycastHelper.GetRawImagePathList(); - i = 0; - if (pathList.Count > 0) - { - GUILayout.Label("rawImage路径:"); - for (; i < pathList.Count; i++) - GUILayout.Label(pathList[i]); - } - GUILayout.EndScrollView(); - } - GUILayout.EndVertical(); - } - - void OnDestroy() - { - if (raycastHelper != null) - DestroyImmediate(raycastHelper); - } - - //[MenuItem("资源工具/资源检查/检查RaycastTarget", false, 401)] - public static void OpenWindow() - { - CheckRaycastTargetWindow window = (CheckRaycastTargetWindow)GetWindowWithRect(typeof(CheckRaycastTargetWindow), - new Rect(Screen.width / 2, Screen.height / 2, 400, 400), true); - window.Show(); - } - } -} +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + + +namespace BFEditor.Resource +{ + public class CheckRaycastTargetWindow : EditorWindow + { + ShowRaycast raycastHelper; + RectTransform rt; + Vector2 scrollPos; + + CheckRaycastTargetWindow() + { + this.titleContent = new GUIContent("检查RaycastTarget"); + } + + void OnEnable() + { + UnityEditor.SceneManagement.PrefabStage currentPrefabStage = UnityEditor.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage(); + Transform tran; + if (currentPrefabStage == null) + tran = Selection.activeTransform; + else + tran = currentPrefabStage.prefabContentsRoot.transform; + if (tran != null) + rt = tran.GetComponent(); + if (rt != null) + { + raycastHelper = rt.GetComponent(); + if (raycastHelper == null) + raycastHelper = rt.gameObject.AddComponent(); + raycastHelper.SetEditorWindowMode(true); + } + } + + void OnGUI() + { + GUILayout.BeginVertical(); + EditorGUI.BeginChangeCheck(); + rt = (RectTransform)EditorGUILayout.ObjectField("", rt, typeof(RectTransform), true, GUILayout.Width(200)); + GUILayout.Space(6); + if (EditorGUI.EndChangeCheck()) + { + if (raycastHelper != null) + DestroyImmediate(raycastHelper); + if (rt != null) + { + raycastHelper = rt.GetComponent(); + if (raycastHelper == null) + raycastHelper = rt.gameObject.AddComponent(); + raycastHelper.SetEditorWindowMode(true); + } + } + if (raycastHelper != null) + { + GUILayout.Label(string.Format("raycastTarget组件一共有 {0} 个", raycastHelper.GetTotalCount())); + GUILayout.Label("(红色)image " + raycastHelper.GetImageCount() + + " (绿色)text " + raycastHelper.GetTextCount()); + GUILayout.Label("(黄色)emptyRaycast " + raycastHelper.GetEmptyCount() + + " (蓝色)rawImage " + raycastHelper.GetRawImageCount()); + GUILayout.Space(6); + scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Width(400), GUILayout.Height(270)); + List pathList = raycastHelper.GetImagePathList(); + int i = 0; + if (pathList.Count > 0) + { + GUILayout.Label("image路径:"); + for (; i < pathList.Count; i++) + GUILayout.Label(pathList[i]); + } + pathList = raycastHelper.GetTextPathList(); + i = 0; + if (pathList.Count > 0) + { + GUILayout.Label("text路径:"); + for (; i < pathList.Count; i++) + GUILayout.Label(pathList[i]); + } + pathList = raycastHelper.GetEmptyPathList(); + i = 0; + if (pathList.Count > 0) + { + GUILayout.Label("emptyRaycast路径:"); + for (; i < pathList.Count; i++) + GUILayout.Label(pathList[i]); + } + pathList = raycastHelper.GetRawImagePathList(); + i = 0; + if (pathList.Count > 0) + { + GUILayout.Label("rawImage路径:"); + for (; i < pathList.Count; i++) + GUILayout.Label(pathList[i]); + } + GUILayout.EndScrollView(); + } + GUILayout.EndVertical(); + } + + void OnDestroy() + { + if (raycastHelper != null) + DestroyImmediate(raycastHelper); + } + + //[MenuItem("资源工具/资源检查/检查RaycastTarget", false, 401)] + public static void OpenWindow() + { + CheckRaycastTargetWindow window = (CheckRaycastTargetWindow)GetWindowWithRect(typeof(CheckRaycastTargetWindow), + new Rect(Screen.width / 2, Screen.height / 2, 400, 400), true); + window.Show(); + } + } +} diff --git a/Assets/Editor/HierarchyTools/GameObjectEditer.cs b/Assets/Editor/HierarchyTools/GameObjectEditer.cs index f7225397f..bbb3b662a 100644 --- a/Assets/Editor/HierarchyTools/GameObjectEditer.cs +++ b/Assets/Editor/HierarchyTools/GameObjectEditer.cs @@ -1,206 +1,206 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; -using TMPro; -using BFEditor.Resource; -using BF; - -namespace BFEditor -{ - public class GameObjectEditer : Editor - { - static Material CustomUIDefault; - - // 重写Text菜单,默认取消raycastTarget - [MenuItem("GameObject/UI/Text", true)] - static bool ValidateUITextMenu() - { - return true; - } - - [MenuItem("GameObject/UI/Text", false)] - static void CreateUIText() - { - GameObject go = new GameObject("Text", typeof(UnityEngine.UI.Text)); - UnityEngine.UI.Text text = go.GetComponent(); - text.raycastTarget = false; - text.material = GetCustomDefaultUIMat(); - CheckAndSetUIParent(go.transform); - } - - [MenuItem("GameObject/UI/TextMeshPro - Text", true)] - static bool ValidateUITextMeshProMenu() - { - return true; - } - - [MenuItem("GameObject/UI/TextMeshPro - Text", false)] - static void CreateUITextMeshPro() - { - Debug.LogError("请在UI/BF通用控件里创建Text"); - } - - // 重写Image菜单,默认取消raycastTarget - [MenuItem("GameObject/UI/Image", true)] - static bool ValidateUIImageMenu() - { - return true; - } - - [MenuItem("GameObject/UI/Image", false)] - static void CreateUIImage() - { - GameObject go = new GameObject("Image", typeof(UnityEngine.UI.Image)); - UnityEngine.UI.Image image = go.GetComponent(); - image.raycastTarget = false; - image.material = GetCustomDefaultUIMat(); - CheckAndSetUIParent(go.transform); - } - - [MenuItem("GameObject/UI/BFSlider", false)] - static void CreateBFSlider() - { - GameObject go = new GameObject("BFSlider", typeof(BFSlider)); - BFSlider slider = go.GetComponent(); - slider.raycastTarget = false; - slider.material = GetCustomDefaultUIMat(); - CheckAndSetUIParent(go.transform); - } - - [MenuItem("GameObject/UI/Raw Image", true)] - static bool ValidateUIRawImageMenu() - { - return true; - } - - [MenuItem("GameObject/UI/Raw Image", false)] - static void CreateUIRawImage() - { - GameObject go = new GameObject("RawImage", typeof(UnityEngine.UI.RawImage)); - UnityEngine.UI.RawImage image = go.GetComponent(); - image.raycastTarget = false; - image.material = GetCustomDefaultUIMat(); - CheckAndSetUIParent(go.transform); - } - - static void CheckAndSetUIParent(Transform uiTransform) - { - if (Selection.activeTransform) // 当前有选择一个父节点 - { - uiTransform.SetParent(Selection.activeTransform, false); - } - else - { - var currentPrefabStage = UnityEditor.Experimental.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage(); - if (currentPrefabStage != null) //当前处于prefab编辑模式 - { - var prefabRoot = currentPrefabStage.prefabContentsRoot; - uiTransform.SetParent(prefabRoot.transform, false); - } - } - Selection.activeTransform = uiTransform; - } - - static Material GetCustomDefaultUIMat() - { - if (CustomUIDefault == null) - CustomUIDefault = AssetDatabase.LoadAssetAtPath(ResourceProcessConfig.CUSTOM_DEFAULT_UI_MAT_PATH); - return CustomUIDefault; - } - - [MenuItem("GameObject/UI/Button", true)] - static bool ValidateUIButtonMenu() - { - return true; - } - - [MenuItem("GameObject/UI/Button", false)] - static void CreateUIButton() - { - Debug.LogError("请在UI/BF通用控件里创建Button"); - } - - [MenuItem("GameObject/UI/Button - TextMeshPro", true)] - static bool ValidateUIButtonTMPMenu() - { - return true; - } - - [MenuItem("GameObject/UI/Button - TextMeshPro", false)] - static void CreateUIButtonTMP() - { - Debug.LogError("请在UI/BF通用控件里创建Button"); - } - - [MenuItem("GameObject/UI/Text - TextMeshPro", true)] - static bool ValidateUITextTMPMenu() - { - return true; - } - - [MenuItem("GameObject/UI/Text - TextMeshPro", false)] - static void CreateUITextTMP() - { - Debug.LogError("请在UI/BF通用控件里创建Text"); - } - - [MenuItem("GameObject/UI/BF通用控件/Button")] - static void CreateBFCommonButton() - { - GameObject go = new GameObject("Button", typeof(UnityEngine.UI.Image)); - UnityEngine.UI.Image image = go.GetComponent(); - image.material = GetCustomDefaultUIMat(); - go.AddComponent(); - CheckAndSetUIParent(go.transform); - } - - - [MenuItem("GameObject/UI/BF通用控件/Text")] - static void CreateBFCommonText() - { - if (TMP_Settings.defaultFontAsset == null) - { - var tmpSettings = TMP_Settings.instance; - var type = tmpSettings.GetType(); - var fontAssetField = type.GetField("m_defaultFontAsset", System.Reflection.BindingFlags.Instance | - System.Reflection.BindingFlags.NonPublic); - var fontAssets = AssetDatabase.LoadAssetAtPath(ResourceProcessConfig.DEFAULT_TMP_FONTASSET_PATH); - fontAssetField.SetValue(tmpSettings, fontAssets); - AssetDatabase.Refresh(); - } - - GameObject go = new GameObject("TextMeshPro", typeof(TMPro.TextMeshProUGUI)); - TMPro.TextMeshProUGUI textMeshPro = go.GetComponent(); - textMeshPro.raycastTarget = false; - var font = AssetDatabase.LoadAssetAtPath( - "Assets/arts/fonts/tmpfonts/default/tmpfont/font_sdf.asset"); - textMeshPro.font = font; - textMeshPro.material = GetCustomDefaultUIMat(); - textMeshPro.enableWordWrapping = false; - CheckAndSetUIParent(go.transform); - - if (TMP_Settings.defaultFontAsset != null) - { - var tmpSettings = TMP_Settings.instance; - var type = tmpSettings.GetType(); - var fontAssetField = type.GetField("m_defaultFontAsset", System.Reflection.BindingFlags.Instance | - System.Reflection.BindingFlags.NonPublic); - fontAssetField.SetValue(tmpSettings, null); - AssetDatabase.Refresh(); - } - } - - [MenuItem("GameObject/UI/创建序列帧")] - static void CreateFrameAnimation() - { - FrameAnimationTools.CreateFrameAnimation(); - } - - [MenuItem("GameObject/UI/创建序列帧(父节点)")] - static void CreateFrameAnimationInParent() - { - FrameAnimationTools.CreateFrameAnimation(true); - } - } -} +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using TMPro; +using BFEditor.Resource; +using BF; + +namespace BFEditor +{ + public class GameObjectEditer : Editor + { + static Material CustomUIDefault; + + // 重写Text菜单,默认取消raycastTarget + [MenuItem("GameObject/UI/Text", true)] + static bool ValidateUITextMenu() + { + return true; + } + + [MenuItem("GameObject/UI/Text", false)] + static void CreateUIText() + { + GameObject go = new GameObject("Text", typeof(UnityEngine.UI.Text)); + UnityEngine.UI.Text text = go.GetComponent(); + text.raycastTarget = false; + text.material = GetCustomDefaultUIMat(); + CheckAndSetUIParent(go.transform); + } + + [MenuItem("GameObject/UI/TextMeshPro - Text", true)] + static bool ValidateUITextMeshProMenu() + { + return true; + } + + [MenuItem("GameObject/UI/TextMeshPro - Text", false)] + static void CreateUITextMeshPro() + { + Debug.LogError("请在UI/BF通用控件里创建Text"); + } + + // 重写Image菜单,默认取消raycastTarget + [MenuItem("GameObject/UI/Image", true)] + static bool ValidateUIImageMenu() + { + return true; + } + + [MenuItem("GameObject/UI/Image", false)] + static void CreateUIImage() + { + GameObject go = new GameObject("Image", typeof(UnityEngine.UI.Image)); + UnityEngine.UI.Image image = go.GetComponent(); + image.raycastTarget = false; + image.material = GetCustomDefaultUIMat(); + CheckAndSetUIParent(go.transform); + } + + [MenuItem("GameObject/UI/BFSlider", false)] + static void CreateBFSlider() + { + GameObject go = new GameObject("BFSlider", typeof(BFSlider)); + BFSlider slider = go.GetComponent(); + slider.raycastTarget = false; + slider.material = GetCustomDefaultUIMat(); + CheckAndSetUIParent(go.transform); + } + + [MenuItem("GameObject/UI/Raw Image", true)] + static bool ValidateUIRawImageMenu() + { + return true; + } + + [MenuItem("GameObject/UI/Raw Image", false)] + static void CreateUIRawImage() + { + GameObject go = new GameObject("RawImage", typeof(UnityEngine.UI.RawImage)); + UnityEngine.UI.RawImage image = go.GetComponent(); + image.raycastTarget = false; + image.material = GetCustomDefaultUIMat(); + CheckAndSetUIParent(go.transform); + } + + static void CheckAndSetUIParent(Transform uiTransform) + { + if (Selection.activeTransform) // 当前有选择一个父节点 + { + uiTransform.SetParent(Selection.activeTransform, false); + } + else + { + var currentPrefabStage = UnityEditor.SceneManagement.PrefabStageUtility.GetCurrentPrefabStage(); + if (currentPrefabStage != null) //当前处于prefab编辑模式 + { + var prefabRoot = currentPrefabStage.prefabContentsRoot; + uiTransform.SetParent(prefabRoot.transform, false); + } + } + Selection.activeTransform = uiTransform; + } + + static Material GetCustomDefaultUIMat() + { + if (CustomUIDefault == null) + CustomUIDefault = AssetDatabase.LoadAssetAtPath(ResourceProcessConfig.CUSTOM_DEFAULT_UI_MAT_PATH); + return CustomUIDefault; + } + + [MenuItem("GameObject/UI/Button", true)] + static bool ValidateUIButtonMenu() + { + return true; + } + + [MenuItem("GameObject/UI/Button", false)] + static void CreateUIButton() + { + Debug.LogError("请在UI/BF通用控件里创建Button"); + } + + [MenuItem("GameObject/UI/Button - TextMeshPro", true)] + static bool ValidateUIButtonTMPMenu() + { + return true; + } + + [MenuItem("GameObject/UI/Button - TextMeshPro", false)] + static void CreateUIButtonTMP() + { + Debug.LogError("请在UI/BF通用控件里创建Button"); + } + + [MenuItem("GameObject/UI/Text - TextMeshPro", true)] + static bool ValidateUITextTMPMenu() + { + return true; + } + + [MenuItem("GameObject/UI/Text - TextMeshPro", false)] + static void CreateUITextTMP() + { + Debug.LogError("请在UI/BF通用控件里创建Text"); + } + + [MenuItem("GameObject/UI/BF通用控件/Button")] + static void CreateBFCommonButton() + { + GameObject go = new GameObject("Button", typeof(UnityEngine.UI.Image)); + UnityEngine.UI.Image image = go.GetComponent(); + image.material = GetCustomDefaultUIMat(); + go.AddComponent(); + CheckAndSetUIParent(go.transform); + } + + + [MenuItem("GameObject/UI/BF通用控件/Text")] + static void CreateBFCommonText() + { + if (TMP_Settings.defaultFontAsset == null) + { + var tmpSettings = TMP_Settings.instance; + var type = tmpSettings.GetType(); + var fontAssetField = type.GetField("m_defaultFontAsset", System.Reflection.BindingFlags.Instance | + System.Reflection.BindingFlags.NonPublic); + var fontAssets = AssetDatabase.LoadAssetAtPath(ResourceProcessConfig.DEFAULT_TMP_FONTASSET_PATH); + fontAssetField.SetValue(tmpSettings, fontAssets); + AssetDatabase.Refresh(); + } + + GameObject go = new GameObject("TextMeshPro", typeof(TMPro.TextMeshProUGUI)); + TMPro.TextMeshProUGUI textMeshPro = go.GetComponent(); + textMeshPro.raycastTarget = false; + var font = AssetDatabase.LoadAssetAtPath( + "Assets/arts/fonts/tmpfonts/default/tmpfont/font_sdf.asset"); + textMeshPro.font = font; + textMeshPro.material = GetCustomDefaultUIMat(); + textMeshPro.enableWordWrapping = false; + CheckAndSetUIParent(go.transform); + + if (TMP_Settings.defaultFontAsset != null) + { + var tmpSettings = TMP_Settings.instance; + var type = tmpSettings.GetType(); + var fontAssetField = type.GetField("m_defaultFontAsset", System.Reflection.BindingFlags.Instance | + System.Reflection.BindingFlags.NonPublic); + fontAssetField.SetValue(tmpSettings, null); + AssetDatabase.Refresh(); + } + } + + [MenuItem("GameObject/UI/创建序列帧")] + static void CreateFrameAnimation() + { + FrameAnimationTools.CreateFrameAnimation(); + } + + [MenuItem("GameObject/UI/创建序列帧(父节点)")] + static void CreateFrameAnimationInParent() + { + FrameAnimationTools.CreateFrameAnimation(true); + } + } +} diff --git a/Assets/Editor/JenkinsAdapter.cs b/Assets/Editor/JenkinsAdapter.cs index 2619dd120..042345752 100644 --- a/Assets/Editor/JenkinsAdapter.cs +++ b/Assets/Editor/JenkinsAdapter.cs @@ -1,93 +1,93 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using UnityEditor; -using UnityEngine; -using BFEditor.Build; - -public class JenkinsAdapter { - - /// - /// 构建版本号 - /// - private static string BuildVersion = (int.Parse(DateTime.Now.ToString("yyMMddHH"))).ToString(); - private static int versionCode = 10; - private static string versionName = "1.4.0"; - - [MenuItem("Jenkins/JenkinsBuildIos")] - public static void CommandLineBuildIos() { - var buildInfo = new BuildInfo(); - buildInfo.version = versionName; - buildInfo.mode = "publish_release"; - buildInfo.bundleName = "com.combo.heroes.puzzle.rpg"; - buildInfo.skipVersion = false; - BuildProjectTools.BuildResources(buildInfo, Application.streamingAssetsPath, true); - // 重新生成XLua - CompileScriptsUtils.RegenerateXLuaCode(true); - - // 设置版本号 - PlayerSettings.bundleVersion = buildInfo.version; - //SDK要求 - PlayerSettings.iOS.targetOSVersionString = "12.0"; - //设置Build,每次需要增加 - PlayerSettings.iOS.buildNumber = versionCode.ToString(); - // 隐藏ios的横条 - PlayerSettings.iOS.hideHomeButton = false; - // 禁止在所有边缘上延迟手势 - PlayerSettings.iOS.deferSystemGesturesMode = UnityEngine.iOS.SystemGestureDeferMode.All; - // 设置竖屏 - PlayerSettings.defaultInterfaceOrientation = UIOrientation.Portrait; - PlayerSettings.allowedAutorotateToPortrait = false; - PlayerSettings.allowedAutorotateToPortraitUpsideDown = false; - PlayerSettings.allowedAutorotateToLandscapeLeft = false; - PlayerSettings.allowedAutorotateToLandscapeRight = false; - // 关闭启动动画 - PlayerSettings.SplashScreen.show = false; - // 设置包名 - PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, buildInfo.bundleName); - // 是否跳过版本控制 - var symbols = "THREAD_SAFE;USE_AB"; - if (buildInfo.skipVersion) - { - symbols = symbols + ";SKIP_VERSION;"; - } - PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS, symbols); - // 商品名称 - PlayerSettings.productName = "Knights Combo"; - // BuildType设置dev/release - EditorUserBuildSettings.iOSBuildConfigType = iOSBuildType.Release; - EditorUserBuildSettings.development = false; - // 使用IL2CPP - var scriptImp = ScriptingImplementation.IL2CPP; - PlayerSettings.SetScriptingBackend(BuildTargetGroup.iOS, scriptImp); - // 目标平台架构,目前支持ARM64 - PlayerSettings.SetArchitecture(BuildTargetGroup.iOS, 1); - - // 开始打包 - BuildPipeline.BuildPlayer(GetBuildScenes(), GetIosBuildPath(), BuildTarget.iOS, BuildOptions.None); - Console.WriteLine("Build Complete Path:" + GetIosBuildPath()); - } - - - /// - /// 获取build Setting 列表里的打勾场景 - /// - /// - private static string[] GetBuildScenes() { - List names = new List(); - - foreach (var x in EditorBuildSettings.scenes) { - if (!x.enabled) continue; - names.Add(x.path); - } - return names.ToArray(); - } - - #region Get Build Path - private static string GetIosBuildPath() { - return "build/iOS"; - } - - #endregion - +using System; +using System.Collections.Generic; +using System.Diagnostics; +using UnityEditor; +using UnityEngine; +using BFEditor.Build; + +public class JenkinsAdapter { + + /// + /// 构建版本号 + /// + private static string BuildVersion = (int.Parse(DateTime.Now.ToString("yyMMddHH"))).ToString(); + private static int versionCode = 10; + private static string versionName = "1.4.0"; + + [MenuItem("Jenkins/JenkinsBuildIos")] + public static void CommandLineBuildIos() { + var buildInfo = new BuildInfo(); + buildInfo.version = versionName; + buildInfo.mode = "publish_release"; + buildInfo.bundleName = "com.combo.heroes.puzzle.rpg"; + buildInfo.skipVersion = false; + BuildProjectTools.BuildResources(buildInfo, Application.streamingAssetsPath, true); + // 重新生成XLua + CompileScriptsUtils.RegenerateXLuaCode(true); + + // 设置版本号 + PlayerSettings.bundleVersion = buildInfo.version; + //SDK要求 + PlayerSettings.iOS.targetOSVersionString = "12.0"; + //设置Build,每次需要增加 + PlayerSettings.iOS.buildNumber = versionCode.ToString(); + // 隐藏ios的横条 + PlayerSettings.iOS.hideHomeButton = false; + // 禁止在所有边缘上延迟手势 + PlayerSettings.iOS.deferSystemGesturesMode = UnityEngine.iOS.SystemGestureDeferMode.All; + // 设置竖屏 + PlayerSettings.defaultInterfaceOrientation = UIOrientation.Portrait; + PlayerSettings.allowedAutorotateToPortrait = false; + PlayerSettings.allowedAutorotateToPortraitUpsideDown = false; + PlayerSettings.allowedAutorotateToLandscapeLeft = false; + PlayerSettings.allowedAutorotateToLandscapeRight = false; + // 关闭启动动画 + PlayerSettings.SplashScreen.show = false; + // 设置包名 + PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, buildInfo.bundleName); + // 是否跳过版本控制 + var symbols = "THREAD_SAFE;USE_AB"; + if (buildInfo.skipVersion) + { + symbols = symbols + ";SKIP_VERSION;"; + } + PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.iOS, symbols); + // 商品名称 + PlayerSettings.productName = "Knights Combo"; + // BuildType设置dev/release + EditorUserBuildSettings.iOSXcodeBuildConfig = XcodeBuildConfig.Release; + EditorUserBuildSettings.development = false; + // 使用IL2CPP + var scriptImp = ScriptingImplementation.IL2CPP; + PlayerSettings.SetScriptingBackend(BuildTargetGroup.iOS, scriptImp); + // 目标平台架构,目前支持ARM64 + PlayerSettings.SetArchitecture(BuildTargetGroup.iOS, 1); + + // 开始打包 + BuildPipeline.BuildPlayer(GetBuildScenes(), GetIosBuildPath(), BuildTarget.iOS, BuildOptions.None); + Console.WriteLine("Build Complete Path:" + GetIosBuildPath()); + } + + + /// + /// 获取build Setting 列表里的打勾场景 + /// + /// + private static string[] GetBuildScenes() { + List names = new List(); + + foreach (var x in EditorBuildSettings.scenes) { + if (!x.enabled) continue; + names.Add(x.path); + } + return names.ToArray(); + } + + #region Get Build Path + private static string GetIosBuildPath() { + return "build/iOS"; + } + + #endregion + } \ No newline at end of file diff --git a/Assets/Editor/LuaGenConfig.cs b/Assets/Editor/LuaGenConfig.cs index 29b3e32f6..df3613bd9 100644 --- a/Assets/Editor/LuaGenConfig.cs +++ b/Assets/Editor/LuaGenConfig.cs @@ -1,708 +1,760 @@ -/* -* Tencent is pleased to support the open source community by making xLua available. -* Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. -* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at -* http://opensource.org/licenses/MIT -* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ - -using System.Collections.Generic; -using System; -using UnityEngine; -using XLua; -using System.Linq; -using System.Reflection; - -namespace BFEditor -{ - //配置的详细介绍请看Doc下《XLua的配置.doc》 - public static class LuaGenConfig - { - //--------------begin 纯lua编程配置参考---------------------------- - static List exclude = new List { - "HideInInspector", "ExecuteInEditMode", - "AddComponentMenu", "ContextMenu", - "RequireComponent", "DisallowMultipleComponent", - "SerializeField", "AssemblyIsEditorAssembly", - "Attribute", "Types", - "UnitySurrogateSelector", "TrackedReference", - "TypeInferenceRules", "FFTWindow", - "RPC", "Network", "MasterServer", - "BitStream", "HostData", - "ConnectionTesterStatus", "GUI", "EventType", - "EventModifiers", "FontStyle", "TextAlignment", - "TextEditor", "TextEditorDblClickSnapping", - "TextGenerator", "TextClipping", "Gizmos", - "ADBannerView", "ADInterstitialAd", - "Android", "Tizen", "jvalue", - "iPhone", "iOS", "Windows", "CalendarIdentifier", - "CalendarUnit", "CalendarUnit", - "ClusterInput", "FullScreenMovieControlMode", - "FullScreenMovieScalingMode", "Handheld", - "LocalNotification", "NotificationServices", - "RemoteNotificationType", "RemoteNotification", - "SamsungTV", "TextureCompressionQuality", - "TouchScreenKeyboardType", "TouchScreenKeyboard", - "MovieTexture", "UnityEngineInternal", - "Terrain", "Tree", "SplatPrototype", - "DetailPrototype", "DetailRenderMode", - "MeshSubsetCombineUtility", "AOT", "Social", "Enumerator", - "SendMouseEvents", "Cursor", "Flash", "ActionScript", - "OnRequestRebuild", "Ping", - "ShaderVariantCollection", "SimpleJson.Reflection", - "CoroutineTween", "GraphicRebuildTracker", - "Advertisements", "UnityEditor", "WSA", - "EventProvider", "Apple", - "ClusterInput", "Motion", - "UnityEngine.UI.ReflectionMethodsCache", "NativeLeakDetection", - "NativeLeakDetectionMode", "WWWAudioExtensions", "UnityEngine.Experimental", - -// 下面是项目自己补充的不导出的class - "UnityEngine.ClusterSerialization", "UnityEngine.AudioSettings", "UnityEngine.Caching", - "UnityEngine.DrivenRectTransformTracker", "UnityEngine.LightingSettings", "UnityEngine.InputManagerEntry", - "UnityEngine.InputRegistering", "UnityEngine.AnimatorControllerParameter", "UnityEngine.LightProbeGroup", - "UnityEngine.UI.DefaultControls", "UnityEngine.CanvasRenderer.OnRequestRebuild", - "TMPro.TMP_SpriteAssetImporter", "TMPro.TMP_PreBuildProcessor", "TMPro.TMP_PackageUtilities", - "TMPro.TMP_PostBuildProcessHandler", "TMPro.TMP_PackageUtilities", "TMPro.TMP_PackageResourceImporter", - "TMPro.TMP_ProjectConversionUtility", "TMPro.TMP_FontAsset_CreationMenu", "TMPro.TMP_EditorResourceManager", - "TMPro.SortingLayerHelper", - "UnityEngine.CloudStreaming", - "BFEditor.EditorBattleRoleAttackOperate", - "IronSourceBannerEvents", "IronSourceEvents", "IronSourceInterstitialEvents", "IronSourceRewardedVideoEvents", - "IronSourceAdQualityManifestTools" - }; - - static bool isExcluded(Type type) - { - var fullName = type.FullName; - for (int i = 0; i < exclude.Count; i++) - { - if (!string.IsNullOrEmpty(fullName) && fullName.Contains(exclude[i])) - { - return true; - } - } - return false; - } - - [LuaCallCSharp] - public static IEnumerable LuaCallCSharp - { - get - { - List namespaces = new List() // 在这里添加名字空间 - { - "BF", - "UnityEngine", - "UnityEngine.UI", - "UnityEngine.U2D", - "UnityEngine.Rendering.Universal", - "TMPro", - "DG.Tweening", - "DG.Tweening.Core", - }; - var unityTypes = (from assembly in AppDomain.CurrentDomain.GetAssemblies() - where !(assembly.ManifestModule is System.Reflection.Emit.ModuleBuilder) - from type in assembly.GetExportedTypes() - where type.Namespace != null && namespaces.Contains(type.Namespace) && !isExcluded(type) - && type.BaseType != typeof(MulticastDelegate) && !type.IsInterface && !type.IsEnum - select type); - - string[] customAssemblys = new string[] { - "Assembly-CSharp", - }; - var customTypes = (from assembly in customAssemblys.Select(s => Assembly.Load(s)) - from type in assembly.GetExportedTypes() - where type.Namespace == null || !type.Namespace.StartsWith("XLua") - && type.BaseType != typeof(MulticastDelegate) && !type.IsInterface && !type.IsEnum && !isExcluded(type) - select type); - - var otherTypes = new List() { - typeof(System.Object), - typeof(System.ValueType), - typeof(System.Reflection.BindingFlags), - typeof(System.Uri), - typeof(System.Enum), - typeof(System.DateTime), - typeof(System.DateTimeOffset), - typeof(System.IO.File), - typeof(System.DBNull), - typeof(System.Convert), - typeof(System.DayOfWeek), - typeof(System.Net.NetworkInformation.Ping), - typeof(System.Net.NetworkInformation.IPStatus), - typeof(System.Net.NetworkInformation.PingCompletedEventHandler), - typeof(System.Net.NetworkInformation.PingCompletedEventArgs), - typeof(System.Net.NetworkInformation.PingReply), - typeof(System.ComponentModel.AsyncCompletedEventArgs), - typeof(System.ComponentModel.Component), - typeof(UnityEngine.Events.UnityEvent), - typeof(System.Collections.Generic.List), - typeof(System.Collections.Generic.List), - typeof(System.Collections.Generic.List), - typeof(System.Collections.Generic.List), - typeof(System.Collections.Generic.List), - typeof(System.Collections.Generic.List>), - typeof(DG.Tweening.Core.TweenerCore), - typeof(DG.Tweening.Core.TweenerCore), - - typeof(System.Action), - - typeof(UnityEngine.Camera.FieldOfViewAxis), - typeof(UnityEngine.Camera.RenderRequestMode), - typeof(UnityEngine.Camera.RenderRequestOutputSpace), - typeof(UnityEngine.TextCore.FaceInfo), - typeof(UnityEngine.Rendering.LightShadowResolution), - typeof(UnityEngine.RenderTextureFormat), - typeof(UnityEngine.RenderTextureReadWrite), - typeof(UnityEngine.RigidbodyConstraints), - typeof(UnityEngine.TransparencySortMode), - typeof(UnityEngine.Object), - typeof(UnityEngine.Rect), - typeof(UnityEngine.Vector2), - typeof(UnityEngine.Vector3), - typeof(UnityEngine.Vector4), - typeof(UnityEngine.Quaternion), - typeof(UnityEngine.Matrix4x4), - typeof(UnityEngine.Color), - typeof(UnityEngine.Ray), - typeof(UnityEngine.Bounds), - typeof(UnityEngine.Ray2D), - typeof(UnityEngine.Time), - typeof(UnityEngine.Motion), - typeof(UnityEngine.GameObject), - typeof(UnityEngine.Component), - typeof(UnityEngine.Behaviour), - typeof(UnityEngine.EventSystems.UIBehaviour), - typeof(UnityEngine.Transform), - typeof(UnityEngine.RectTransform), - typeof(UnityEngine.RectTransform.Axis), - typeof(UnityEngine.RectTransform.Edge), - typeof(UnityEngine.Resources), - typeof(UnityEngine.TextAsset), - typeof(UnityEngine.Keyframe), - typeof(UnityEngine.Sprite), - typeof(UnityEngine.AnimatorStateInfo), - typeof(UnityEngine.AnimatorCullingMode), - typeof(UnityEngine.Animation), - typeof(UnityEngine.AnimationCurve), - typeof(UnityEngine.AnimationClip), - typeof(UnityEngine.MonoBehaviour), - typeof(UnityEngine.ParticleSystem), - typeof(UnityEngine.ParticleSystem.MainModule), - typeof(UnityEngine.ParticleSystem.EmissionModule), - typeof(UnityEngine.ParticleSystem.ShapeModule), - typeof(UnityEngine.ParticleSystem.VelocityOverLifetimeModule), - typeof(UnityEngine.ParticleSystem.LimitVelocityOverLifetimeModule), - typeof(UnityEngine.ParticleSystem.InheritVelocityModule), - typeof(UnityEngine.ParticleSystem.ForceOverLifetimeModule), - typeof(UnityEngine.ParticleSystem.ColorOverLifetimeModule), - typeof(UnityEngine.ParticleSystem.ColorBySpeedModule), - typeof(UnityEngine.ParticleSystem.SizeOverLifetimeModule), - typeof(UnityEngine.ParticleSystem.SizeBySpeedModule), - typeof(UnityEngine.ParticleSystem.RotationBySpeedModule), - typeof(UnityEngine.ParticleSystem.RotationOverLifetimeModule), - typeof(UnityEngine.ParticleSystem.ExternalForcesModule), - typeof(UnityEngine.ParticleSystem.NoiseModule), - typeof(UnityEngine.ParticleSystem.CollisionModule), - typeof(UnityEngine.ParticleSystem.TriggerModule), - typeof(UnityEngine.ParticleSystem.SubEmittersModule), - typeof(UnityEngine.ParticleSystem.TextureSheetAnimationModule), - typeof(UnityEngine.ParticleSystem.LightsModule), - typeof(UnityEngine.ParticleSystem.TrailModule), - typeof(UnityEngine.ParticleSystem.CustomDataModule), - typeof(UnityEngine.ParticleSystem.MinMaxCurve), - typeof(UnityEngine.ParticleSystem.Particle), - typeof(UnityEngine.ParticleSystem.Burst), - typeof(UnityEngine.ParticleSystem.MinMaxGradient), - typeof(UnityEngine.ParticleSystem.EmitParams), - typeof(UnityEngine.ParticleSystemRenderer), - typeof(UnityEngine.MeshRenderer), - typeof(UnityEngine.SkinnedMeshRenderer), - typeof(UnityEngine.Renderer), - typeof(UnityEngine.WWW), - typeof(UnityEngine.Light), - typeof(UnityEngine.Mathf), - typeof(UnityEngine.Debug), - typeof(UnityEngine.Screen), - typeof(UnityEngine.Resolution), - typeof(UnityEngine.Shader), - typeof(UnityEngine.ShaderVariantCollection), - typeof(UnityEngine.Playables.PlayableDirector), - typeof(UnityEngine.Playables.PlayableAsset), - typeof(UnityEngine.Playables.Playable), - typeof(UnityEngine.RuntimeAnimatorController), - typeof(UnityEngine.Application), - typeof(UnityEngine.SystemLanguage), - typeof(UnityEngine.AudioClip), - typeof(UnityEngine.SceneManagement.SceneManager), - typeof(UnityEngine.SceneManagement.Scene), - typeof(UnityEngine.AssetBundle), - typeof(UnityEngine.AssetBundleRequest), - typeof(UnityEngine.AudioSource), - typeof(UnityEngine.AsyncOperation), - typeof(UnityEngine.Avatar), - typeof(UnityEngine.Animator), - typeof(UnityEngine.Events.UnityEvent), - typeof(UnityEngine.Events.UnityEvent), - typeof(UnityEngine.Events.UnityEvent), - typeof(UnityEngine.Events.UnityEvent), - typeof(UnityEngine.Events.UnityEvent), - typeof(UnityEngine.Events.UnityEventBase), - typeof(UnityEngine.LayerMask), - typeof(UnityEngine.RenderTextureDescriptor), - typeof(UnityEngine.Material), - typeof(UnityEngine.MaterialPropertyBlock), - typeof(UnityEngine.SpriteRenderer), - typeof(UnityEngine.Mesh), - typeof(UnityEngine.MeshFilter), - typeof(UnityEngine.Rendering.ShadowCastingMode), - typeof(UnityEngine.Video.VideoClip), - typeof(UnityEngine.Video.VideoPlayer), - typeof(UnityEngine.RenderSettings), - typeof(UnityEngine.Canvas), - typeof(UnityEngine.CanvasGroup), - typeof(UnityEngine.CanvasRenderer), - typeof(UnityEngine.Camera), - typeof(UnityEngine.Camera.GateFitMode), - typeof(UnityEngine.Camera.GateFitParameters), - typeof(UnityEngine.Camera.StereoscopicEye), - typeof(UnityEngine.Camera.MonoOrStereoscopicEye), - typeof(UnityEngine.LineRenderer), - typeof(UnityEngine.Texture2D), - typeof(UnityEngine.Texture2D.EXRFlags), - typeof(UnityEngine.Font), - typeof(UnityEngine.RenderTexture), - typeof(UnityEngine.Texture), - typeof(UnityEngine.Graphics), - typeof(UnityEngine.Input), - typeof(UnityEngine.KeyCode), - typeof(UnityEngine.Video.VideoClip), - typeof(UnityEngine.PlayerPrefs), - typeof(UnityEngine.ShaderVariantCollection), - typeof(UnityEngine.ShaderVariantCollection.ShaderVariant), - typeof(UnityEngine.NetworkReachability), - typeof(UnityEngine.RuntimePlatform), - typeof(UnityEngine.Rendering.CompareFunction), - typeof(UnityEngine.TextAnchor), - typeof(UnityEngine.LightProbes), - typeof(UnityEngine.Graphics), - typeof(UnityEngine.BoxCollider), - typeof(UnityEngine.RaycastHit), - typeof(UnityEngine.LightmapSettings), - typeof(UnityEngine.LightmapData), - typeof(UnityEngine.LightProbes), - typeof(UnityEngine.ReflectionProbe), - typeof(UnityEngine.BatteryStatus), - - typeof(UnityEngine.UI.CanvasScaler), - typeof(UnityEngine.UI.Dropdown), - typeof(UnityEngine.UI.Dropdown.OptionData), - typeof(UnityEngine.UI.Dropdown.OptionDataList), - typeof(UnityEngine.UI.Dropdown.DropdownEvent), - typeof(UnityEngine.UI.Graphic), - typeof(UnityEngine.UI.GraphicRaycaster), - typeof(UnityEngine.UI.GraphicRaycaster.BlockingObjects), - typeof(UnityEngine.UI.Image), - typeof(UnityEngine.UI.Image.Type), - typeof(UnityEngine.UI.Image.FillMethod), - typeof(UnityEngine.UI.Image.OriginHorizontal), - typeof(UnityEngine.UI.Image.OriginVertical), - typeof(UnityEngine.UI.Image.Origin90), - typeof(UnityEngine.UI.Image.Origin180), - typeof(UnityEngine.UI.Image.Origin360), - typeof(UnityEngine.UI.Button), - typeof(UnityEngine.UI.Button.ButtonClickedEvent), - typeof(UnityEngine.UI.InputField), - typeof(UnityEngine.UI.InputField.ContentType), - typeof(UnityEngine.UI.InputField.InputType), - typeof(UnityEngine.UI.InputField.CharacterValidation), - typeof(UnityEngine.UI.InputField.LineType), - typeof(UnityEngine.UI.InputField.SubmitEvent), - typeof(UnityEngine.UI.InputField.OnChangeEvent), - typeof(UnityEngine.UI.Mask), - typeof(UnityEngine.UI.MaskableGraphic), - typeof(UnityEngine.UI.MaskableGraphic.CullStateChangedEvent), - typeof(UnityEngine.UI.MaskUtilities), - typeof(UnityEngine.UI.RawImage), - typeof(UnityEngine.UI.RectMask2D), - typeof(UnityEngine.UI.Scrollbar), - typeof(UnityEngine.UI.ScrollRect), - typeof(UnityEngine.UI.ScrollRect.MovementType), - typeof(UnityEngine.UI.ScrollRect.ScrollbarVisibility), - typeof(UnityEngine.UI.ScrollRect.ScrollRectEvent), - typeof(UnityEngine.UI.Selectable), - typeof(UnityEngine.UI.Slider), - typeof(UnityEngine.UI.Slider.Direction), - typeof(UnityEngine.UI.Slider.SliderEvent), - typeof(UnityEngine.UI.Text), - typeof(UnityEngine.UI.Toggle), - typeof(UnityEngine.UI.Toggle.ToggleTransition), - typeof(UnityEngine.UI.Toggle.ToggleEvent), - typeof(UnityEngine.UI.ToggleGroup), - typeof(UnityEngine.UI.LayoutElement), - typeof(UnityEngine.UI.GridLayoutGroup), - typeof(UnityEngine.UI.GridLayoutGroup.Corner), - typeof(UnityEngine.UI.GridLayoutGroup.Axis), - typeof(UnityEngine.UI.GridLayoutGroup.Constraint), - typeof(UnityEngine.UI.VerticalLayoutGroup), - typeof(UnityEngine.UI.LayoutGroup), - typeof(UnityEngine.GUIUtility), - - // spine - typeof(Spine.TrackEntry), - typeof(Spine.SkeletonData), - typeof(Spine.Skeleton), - typeof(Spine.Slot), - typeof(Spine.RegionAttachment), - typeof(Spine.Animation), - typeof(Spine.AnimationState), - typeof(Spine.AnimationStateData), - typeof(Spine.AnimationStateData.AnimationPair), - typeof(Spine.AnimationStateData.AnimationPairComparer), - typeof(Spine.AnimationState.TrackEntryDelegate), - typeof(Spine.Unity.SkeletonGraphic), - typeof(Spine.Unity.SkeletonAnimation), - typeof(Spine.Unity.SkeletonDataAsset), - typeof(Spine.Unity.MeshGenerator), - typeof(Spine.Unity.MeshGenerator.Settings), - typeof(Spine.Unity.SkeletonRenderer), - typeof(Spine.Unity.SkeletonRenderer.SpriteMaskInteractionMaterials), - typeof(Spine.Unity.BoneFollower), - typeof(Spine.Unity.BoneFollowerGraphic), - typeof(Spine.Unity.BoneFollower.AxisOrientation), - - // TextMeshPro - typeof(TMPro.TextAlignmentOptions), - typeof(TMPro.TMP_FontAsset), - typeof(TMPro.TMP_Character), - typeof(TMPro.TextMeshProUGUI), - typeof(TMPro.TextMeshPro), - typeof(TMPro.TMP_Text), - typeof(TMPro.TMP_Dropdown), - typeof(TMPro.TMP_Dropdown.OptionData), - typeof(TMPro.TMP_Dropdown.OptionDataList), - typeof(TMPro.TMP_Dropdown.DropdownEvent), - typeof(TMPro.TMP_InputField), - typeof(TMPro.TMP_InputField.ContentType), - typeof(TMPro.TMP_InputField.InputType), - typeof(TMPro.TMP_InputField.CharacterValidation), - typeof(TMPro.TMP_InputField.LineType), - typeof(TMPro.TMP_InputField.SubmitEvent), - typeof(TMPro.TMP_InputField.OnChangeEvent), - typeof(TMPro.TMP_InputField.SelectionEvent), - typeof(TMPro.TMP_InputField.TextSelectionEvent), - typeof(TMPro.TMP_InputField.TouchScreenKeyboardEvent), - typeof(TMP_AnimationCurve), - typeof(TMP_Curve), - - //DOTween - typeof(DG.Tweening.AutoPlay), - typeof(DG.Tweening.AxisConstraint), - typeof(DG.Tweening.Ease), - typeof(DG.Tweening.LogBehaviour), - typeof(DG.Tweening.LoopType), - typeof(DG.Tweening.PathMode), - typeof(DG.Tweening.PathType), - typeof(DG.Tweening.RotateMode), - typeof(DG.Tweening.ScrambleMode), - typeof(DG.Tweening.TweenType), - typeof(DG.Tweening.UpdateType), - - typeof(DG.Tweening.DOTween), - typeof(DG.Tweening.Core.DOTweenComponent), - typeof(DG.Tweening.Core.TweenerCore), - typeof(DG.Tweening.Core.TweenerCore), - typeof(DG.Tweening.Core.TweenerCore), - typeof(DG.Tweening.Core.TweenerCore), - typeof(DG.Tweening.Core.TweenerCore), - typeof(DG.Tweening.Core.TweenerCore), - typeof(DG.Tweening.Core.TweenerCore), - typeof(DG.Tweening.DOVirtual), - typeof(DG.Tweening.EaseFactory), - typeof(DG.Tweening.Tweener), - typeof(DG.Tweening.Tween), - typeof(DG.Tweening.Sequence), - typeof(DG.Tweening.TweenParams), - typeof(DG.Tweening.Core.ABSSequentiable), - typeof(DG.Tweening.TweenCallback), - typeof(DG.Tweening.TweenExtensions), - typeof(DG.Tweening.TweenSettingsExtensions), - typeof(DG.Tweening.ShortcutExtensions), - typeof(DG.Tweening.DOTweenModuleUI), - - // 数数 - typeof(ThinkingAnalytics.ThinkingAnalyticsAPI.TATimeZone), - typeof(ThinkingAnalytics.ThinkingAnalyticsAPI.TAMode), - typeof(ThinkingAnalytics.ThinkingAnalyticsAPI.NetworkType), - - typeof(Http.RequestState), - typeof(BestHTTP.HTTPResponse), - typeof(BestHTTP.Forms.HTTPUrlEncodedForm), - typeof(BestHTTP.Forms.HTTPFormBase), - - // 支付 - typeof(UnityEngine.Purchasing.Product), - typeof(UnityEngine.Purchasing.ProductDefinition), - typeof(UnityEngine.Purchasing.ProductMetadata), - typeof(UnityEngine.Purchasing.ProductType), - - typeof(BF.MonoSingleton), - typeof(BF.BFSlider.FillDirection), - typeof(BF.ScrollRectBaseOld.MovementType), - typeof(BF.ScrollRectBaseOld.ScrollbarVisibility), - typeof(BF.NetServiceType), - typeof(BF.NetIncomingMessageType), - typeof(BF.BFGridLayout.Corner), - typeof(BF.BFGridLayout.Constraint), - }; - return unityTypes.Concat(customTypes).Concat(otherTypes); - } - } - - //自动把LuaCallCSharp涉及到的delegate加到CSharpCallLua列表,后续可以直接用lua函数做callback - [CSharpCallLua] - public static List CSharpCallLua - { - get - { - var lua_call_csharp = LuaCallCSharp; - var delegate_types = new List(); - var flag = BindingFlags.Public | BindingFlags.Instance - | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.DeclaredOnly; - foreach (var field in (from type in lua_call_csharp select type).SelectMany(type => type.GetFields(flag))) - { - // 增加过滤黑名单class - if (typeof(Delegate).IsAssignableFrom(field.FieldType) && !isExcluded(field.FieldType)) - { - delegate_types.Add(field.FieldType); - } - } - - foreach (var method in (from type in lua_call_csharp select type).SelectMany(type => type.GetMethods(flag))) - { - // 增加过滤黑名单class - if (typeof(Delegate).IsAssignableFrom(method.ReturnType) && !isExcluded(method.ReturnType)) - { - delegate_types.Add(method.ReturnType); - } - foreach (var param in method.GetParameters()) - { - var paramType = param.ParameterType.IsByRef ? param.ParameterType.GetElementType() : param.ParameterType; - // 增加过滤黑名单class - if (typeof(Delegate).IsAssignableFrom(paramType) && !isExcluded(paramType)) - { - delegate_types.Add(paramType); - } - } - } - return delegate_types.Where(t => t.BaseType == typeof(MulticastDelegate) && !hasGenericParameter(t) && !delegateHasEditorRef(t)).Distinct().ToList(); - } - } - //黑名单 - [BlackList] - public static List> BlackList = new List>() { - new List(){"System.Xml.XmlNodeList", "ItemOf"}, - new List(){"UnityEngine.WWW", "movie"}, -#if UNITY_WEBGL - new List(){"UnityEngine.WWW", "threadPriority"}, -#endif - new List(){"UnityEngine.Texture2D", "alphaIsTransparency"}, - new List(){"UnityEngine.Security", "GetChainOfTrustValue"}, - new List(){"UnityEngine.CanvasRenderer", "onRequestRebuild"}, - new List(){"UnityEngine.Light", "areaSize"}, - new List(){"UnityEngine.Light", "lightmapBakeType"}, - new List(){"UnityEngine.Light", "SetLightDirty"}, - new List(){"UnityEngine.Light", "shadowRadius"}, - new List(){"UnityEngine.Light", "shadowAngle"}, - new List(){"UnityEngine.WWW", "MovieTexture"}, - new List(){"UnityEngine.WWW", "GetMovieTexture"}, - new List(){"UnityEngine.AnimatorOverrideController", "PerformOverrideClipListCleanup"}, -#if !UNITY_WEBPLAYER - new List(){"UnityEngine.Application", "ExternalEval"}, -#endif - new List(){"UnityEngine.GameObject", "networkView"}, //4.6.2 not support - new List(){"UnityEngine.Component", "networkView"}, //4.6.2 not support - new List(){"System.IO.FileInfo", "GetAccessControl", "System.Security.AccessControl.AccessControlSections"}, - new List(){"System.IO.FileInfo", "SetAccessControl", "System.Security.AccessControl.FileSecurity"}, - new List(){"System.IO.File", "Create", "System.String", "System.Int32", "System.IO.FileOptions", "System.Security.AccessControl.FileSecurity"}, - new List(){"System.IO.File", "SetAccessControl", "System.String", "System.Security.AccessControl.FileSecurity"}, - new List(){"System.IO.File", "GetAccessControl", "System.String"}, - new List(){"System.IO.File", "GetAccessControl", "System.String", "System.Security.AccessControl.AccessControlSections"}, - new List(){"System.IO.DirectoryInfo", "GetAccessControl", "System.Security.AccessControl.AccessControlSections"}, - new List(){"System.IO.DirectoryInfo", "SetAccessControl", "System.Security.AccessControl.DirectorySecurity"}, - new List(){"System.IO.DirectoryInfo", "CreateSubdirectory", "System.String", "System.Security.AccessControl.DirectorySecurity"}, - new List(){"System.IO.DirectoryInfo", "Create", "System.Security.AccessControl.DirectorySecurity"}, - new List(){"UnityEngine.MonoBehaviour", "runInEditMode"}, - new List(){"UnityEngine.Texture", "imageContentsHash"}, - new List(){"UnityEngine.UI.Text", "OnRebuildRequested"}, - new List(){"UnityEngine.UI.Graphic", "OnRebuildRequested"}, - new List(){"BF.Atlas", "Clear"}, - new List(){"BF.Atlas", "GetCount"}, - new List(){"BF.Atlas", "AddSprite", "UnityEngine.Sprite"}, - new List(){"BF.Atlas", "RemoveSprite", "UnityEngine.Sprite"}, - new List(){"BF.Atlas", "Contains", "UnityEngine.Sprite"}, - new List(){"BF.Atlas", "Contains", "System.String"}, - new List(){"BF.Atlas", "RemoveNullSprite"}, - new List(){"UnityEngine.Input", "IsJoystickPreconfigured", "System.String"}, - new List(){"UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset", "Create"}, - new List(){"UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset", "Create", "UnityEngine.Rendering.Universal.ScriptableRendererData"}, - new List(){"UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset", "packagePath"}, - new List(){"UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset", "editorResourcesGUID"}, - new List(){"UnityEngine.MeshRenderer", "scaleInLightmap"}, - new List(){"UnityEngine.MeshRenderer", "receiveGI"}, - new List(){"UnityEngine.MeshRenderer", "stitchLightmapSeams"}, - new List(){"UnityEngine.MeshRenderer", "stitchLightmapSeams"}, - new List(){"UnityEngine.ParticleSystemForceField", "FindAll"}, - new List(){"UnityEngine.ParticleSystemRenderer", "supportsMeshInstancing"}, - new List(){"Spine.Unity.SkeletonRenderer", "Start"}, - new List(){"Spine.Unity.SkeletonRenderer", "EditorSkipSkinSync"}, - new List(){"UnityEngine.AudioSource", "PlayOnGamepad", "System.Int32"}, - new List(){"UnityEngine.AudioSource", "DisableGamepadOutput"}, - new List(){"UnityEngine.AudioSource", "SetGamepadSpeakerMixLevel", "System.Int32", "System.Int32"}, - new List(){"UnityEngine.AudioSource", "SetGamepadSpeakerMixLevelDefault", "System.Int32"}, - new List(){"UnityEngine.AudioSource", "SetGamepadSpeakerRestrictedAudio", "System.Int32", "System.Boolean"}, - new List(){"UnityEngine.AudioSource", "SetGamepadSpeakerMixLevelDefault", "System.Int32"}, - new List(){"UnityEngine.AudioSource", "GamepadSpeakerSupportsOutputType", "UnityEngine.GamepadSpeakerOutputType"}, - new List(){"UnityEngine.AudioSource", "gamepadSpeakerOutputType",}, - new List(){"ThinkingAnalytics.ThinkingAnalyticsAPI", "onPostProcessBuild", "UnityEditor.BuildTarget", "System.String"}, - new List(){"Spine.Unity.SkeletonRenderer", "EditorUpdateMeshFilterHideFlags"}, - new List(){"Spine.Unity.SkeletonRenderer", "fixPrefabOverrideViaMeshFilter"}, - new List(){"Spine.Unity.SkeletonRenderer", "fixPrefabOverrideViaMeshFilterGlobal"}, - new List(){"Spine.Unity.SkeletonDataAsset", "errorIfSkeletonFileNullGlobal"}, - new List(){"FBWindowsPhysicalGamepadManager", "state"}, - new List(){"IronSourceBannerEvents", "onAdLoaded", "System.String"}, - new List(){"IronSourceBannerEvents", "onAdLoadFailed", "System.String"}, - new List(){"IronSourceBannerEvents", "onAdClicked", "System.String"}, - new List(){"IronSourceBannerEvents", "onAdScreenPresented", "System.String"}, - new List(){"IronSourceBannerEvents", "onAdScreenDismissed", "System.String"}, - new List(){"IronSourceBannerEvents", "onAdLeftApplication", "System.String"}, - new List(){"IronSourceEvents", "onSdkInitializationCompleted", "System.String"}, - new List(){"IronSourceEvents", "onRewardedVideoAdOpened", "System.String"}, - new List(){"IronSourceEvents", "onRewardedVideoAdClosed", "System.String"}, - new List(){"IronSourceEvents", "onRewardedVideoAdStarted", "System.String"}, - new List(){"IronSourceEvents", "onRewardedVideoAdEnded", "System.String"}, - new List(){"IronSourceEvents", "onRewardedVideoAdShowFailed", "System.String"}, - new List(){"IronSourceEvents", "onRewardedVideoAdRewarded", "System.String"}, - new List(){"IronSourceEvents", "onRewardedVideoAdClicked", "System.String"}, - new List(){"IronSourceEvents", "onRewardedVideoAvailabilityChanged", "System.String"}, - new List(){"IronSourceEvents", "onRewardedVideoAdLoadedDemandOnly", "System.String"}, - new List(){"IronSourceEvents", "onRewardedVideoAdLoadFailedDemandOnly", "System.String"}, - new List(){"IronSourceEvents", "onRewardedVideoAdOpenedDemandOnly", "System.String"}, - new List(){"IronSourceEvents", "onRewardedVideoAdRewardedDemandOnly", "System.String"}, - new List(){"IronSourceEvents", "onRewardedVideoAdShowFailedDemandOnly", "System.String"}, - new List(){"IronSourceEvents", "onRewardedVideoAdClosedDemandOnly", "System.String"}, - new List(){"IronSourceEvents", "onRewardedVideoAdClickedDemandOnly", "System.String"}, - new List(){"IronSourceEvents", "onSegmentReceived", "System.String"}, - new List(){"IronSourceEvents", "onInterstitialAdReady"}, - new List(){"IronSourceEvents", "onInterstitialAdLoadFailed", "System.String"}, - new List(){"IronSourceEvents", "onInterstitialAdOpened", "System.String"}, - new List(){"IronSourceEvents", "onInterstitialAdClosed", "System.String"}, - new List(){"IronSourceEvents", "onInterstitialAdShowSucceeded", "System.String"}, - new List(){"IronSourceEvents", "onInterstitialAdShowFailed", "System.String"}, - new List(){"IronSourceEvents", "onInterstitialAdClicked", "System.String"}, - new List(){"IronSourceEvents", "onInterstitialAdReadyDemandOnly", "System.String"}, - new List(){"IronSourceEvents", "onInterstitialAdLoadFailedDemandOnly", "System.String"}, - new List(){"IronSourceEvents", "onInterstitialAdOpenedDemandOnly", "System.String"}, - new List(){"IronSourceEvents", "onInterstitialAdClosedDemandOnly", "System.String"}, - new List(){"IronSourceEvents", "onInterstitialAdShowFailedDemandOnly", "System.String"}, - new List(){"IronSourceEvents", "onInterstitialAdClickedDemandOnly", "System.String"}, - new List(){"IronSourceEvents", "onOfferwallOpened", "System.String"}, - new List(){"IronSourceEvents", "onOfferwallShowFailed", "System.String"}, - new List(){"IronSourceEvents", "onOfferwallClosed", "System.String"}, - new List(){"IronSourceEvents", "onGetOfferwallCreditsFailed", "System.String"}, - new List(){"IronSourceEvents", "onOfferwallAdCredited", "System.String"}, - new List(){"IronSourceEvents", "onOfferwallAvailable", "System.String"}, - new List(){"IronSourceEvents", "onBannerAdLoaded"}, - new List(){"IronSourceEvents", "onBannerAdLoadFailed", "System.String"}, - new List(){"IronSourceEvents", "onBannerAdClicked"}, - new List(){"IronSourceEvents", "onBannerAdScreenPresented"}, - new List(){"IronSourceEvents", "onBannerAdScreenDismissed"}, - new List(){"IronSourceEvents", "onBannerAdLeftApplication"}, - new List(){"IronSourceEvents", "onImpressionSuccess", "System.String"}, - new List(){"IronSourceEvents", "onRewardedVideoAdLoadFailed", "System.String"}, - new List(){"IronSourceEvents", "onRewardedVideoAdReady", "System.String"}, - new List(){"IronSourceInterstitialEvents", "onAdReady", "System.String"}, - new List(){"IronSourceInterstitialEvents", "onAdLoadFailed", "System.String"}, - new List(){"IronSourceInterstitialEvents", "onAdOpened", "System.String"}, - new List(){"IronSourceInterstitialEvents", "onAdClosed", "System.String"}, - new List(){"IronSourceInterstitialEvents", "onAdShowSucceeded", "System.String"}, - new List(){"IronSourceInterstitialEvents", "onAdShowFailed", "System.String"}, - new List(){"IronSourceInterstitialEvents", "onAdClicked", "System.String"}, - new List(){"IronSourceRewardedVideoEvents", "onAdShowFailed", "System.String"}, - new List(){"IronSourceRewardedVideoEvents", "onAdClosed", "System.String"}, - new List(){"IronSourceRewardedVideoEvents", "onAdRewarded", "System.String"}, - new List(){"IronSourceRewardedVideoEvents", "onAdOpened", "System.String"}, - new List(){"IronSourceRewardedVideoEvents", "onAdClicked", "System.String"}, - new List(){"IronSourceRewardedVideoEvents", "onAdAvailable", "System.String"}, - new List(){"IronSourceRewardedVideoEvents", "onAdUnavailable"}, - new List(){"IronSourceRewardedVideoEvents", "onAdLoadFailed", "System.String"}, - new List(){"IronSourceRewardedVideoEvents", "onAdReady", "System.String"}, - }; - - static bool hasGenericParameter(Type type) - { - if (type.IsGenericTypeDefinition) return true; - if (type.IsGenericParameter) return true; - if (type.IsByRef || type.IsArray) - { - return hasGenericParameter(type.GetElementType()); - } - if (type.IsGenericType) - { - foreach (var typeArg in type.GetGenericArguments()) - { - if (hasGenericParameter(typeArg)) - { - return true; - } - } - } - return false; - } - - static bool typeHasEditorRef(Type type) - { - if (type.Namespace != null && (type.Namespace == "UnityEditor" || type.Namespace.StartsWith("UnityEditor."))) - { - return true; - } - if (type.IsNested) - { - return typeHasEditorRef(type.DeclaringType); - } - if (type.IsByRef || type.IsArray) - { - return typeHasEditorRef(type.GetElementType()); - } - if (type.IsGenericType) - { - foreach (var typeArg in type.GetGenericArguments()) - { - if (typeArg.IsGenericParameter) - { - //skip unsigned type parameter - continue; - } - if (typeHasEditorRef(typeArg)) - { - return true; - } - } - } - return false; - } - - static bool delegateHasEditorRef(Type delegateType) - { - if (typeHasEditorRef(delegateType)) return true; - var method = delegateType.GetMethod("Invoke"); - if (method == null) - { - return false; - } - if (typeHasEditorRef(method.ReturnType)) return true; - return method.GetParameters().Any(pinfo => typeHasEditorRef(pinfo.ParameterType)); - } - } +/* +* Tencent is pleased to support the open source community by making xLua available. +* Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. +* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at +* http://opensource.org/licenses/MIT +* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. +*/ + +using System.Collections.Generic; +using System; +using UnityEngine; +using XLua; +using System.Linq; +using System.Reflection; + +namespace BFEditor +{ + //配置的详细介绍请看Doc下《XLua的配置.doc》 + public static class LuaGenConfig + { + //--------------begin 纯lua编程配置参考---------------------------- + static List exclude = new List { + "HideInInspector", "ExecuteInEditMode", + "AddComponentMenu", "ContextMenu", + "RequireComponent", "DisallowMultipleComponent", + "SerializeField", "AssemblyIsEditorAssembly", + "Attribute", "Types", + "UnitySurrogateSelector", "TrackedReference", + "TypeInferenceRules", "FFTWindow", + "RPC", "Network", "MasterServer", + "BitStream", "HostData", + "ConnectionTesterStatus", "GUI", "EventType", + "EventModifiers", "FontStyle", "TextAlignment", + "TextEditor", "TextEditorDblClickSnapping", + "TextGenerator", "TextClipping", "Gizmos", + "ADBannerView", "ADInterstitialAd", + "Android", "Tizen", "jvalue", + "iPhone", "iOS", "Windows", "CalendarIdentifier", + "CalendarUnit", "CalendarUnit", + "ClusterInput", "FullScreenMovieControlMode", + "FullScreenMovieScalingMode", "Handheld", + "LocalNotification", "NotificationServices", + "RemoteNotificationType", "RemoteNotification", + "SamsungTV", "TextureCompressionQuality", + "TouchScreenKeyboardType", "TouchScreenKeyboard", + "MovieTexture", "UnityEngineInternal", + "Terrain", "Tree", "SplatPrototype", + "DetailPrototype", "DetailRenderMode", + "MeshSubsetCombineUtility", "AOT", "Social", "Enumerator", + "SendMouseEvents", "Cursor", "Flash", "ActionScript", + "OnRequestRebuild", "Ping", + "ShaderVariantCollection", "SimpleJson.Reflection", + "CoroutineTween", "GraphicRebuildTracker", + "Advertisements", "UnityEditor", "WSA", + "EventProvider", "Apple", + "ClusterInput", "Motion", + "UnityEngine.UI.ReflectionMethodsCache", "NativeLeakDetection", + "NativeLeakDetectionMode", "WWWAudioExtensions", "UnityEngine.Experimental", + +// 下面是项目自己补充的不导出的class + "UnityEngine.ClusterSerialization", "UnityEngine.AudioSettings", "UnityEngine.Caching", + "UnityEngine.DrivenRectTransformTracker", "UnityEngine.LightingSettings", "UnityEngine.InputManagerEntry", + "UnityEngine.InputRegistering", "UnityEngine.AnimatorControllerParameter", "UnityEngine.LightProbeGroup", + "UnityEngine.UI.DefaultControls", "UnityEngine.CanvasRenderer.OnRequestRebuild", + "TMPro.TMP_SpriteAssetImporter", "TMPro.TMP_PreBuildProcessor", "TMPro.TMP_PackageUtilities", + "TMPro.TMP_PostBuildProcessHandler", "TMPro.TMP_PackageUtilities", "TMPro.TMP_PackageResourceImporter", + "TMPro.TMP_ProjectConversionUtility", "TMPro.TMP_FontAsset_CreationMenu", "TMPro.TMP_EditorResourceManager", + "TMPro.SortingLayerHelper", + "UnityEngine.CloudStreaming", + "BFEditor.EditorBattleRoleAttackOperate", + "UnityEngine.QualitySettings", + "IronSourceBannerEvents", "IronSourceEvents", "IronSourceInterstitialEvents", "IronSourceRewardedVideoEvents", + "IronSourceAdQualityManifestTools", "TradplusSDK" + }; + + static bool isExcluded(Type type) + { + var fullName = type.FullName; + for (int i = 0; i < exclude.Count; i++) + { + if (fullName != null && fullName.Contains(exclude[i])) + { + return true; + } + } + return false; + } + + [LuaCallCSharp] + public static IEnumerable LuaCallCSharp + { + get + { + List namespaces = new List() // 在这里添加名字空间 + { + "BF", + // "UnityEngine", + // "UnityEngine.UI", + // "UnityEngine.U2D", + // "UnityEngine.Rendering.Universal", + // "TMPro", + // "DG.Tweening", + // "DG.Tweening.Core", + }; + var unityTypes = (from assembly in AppDomain.CurrentDomain.GetAssemblies() + where !(assembly.ManifestModule is System.Reflection.Emit.ModuleBuilder) + from type in assembly.GetExportedTypes() + where type.Namespace != null && namespaces.Contains(type.Namespace) && !isExcluded(type) + && type.BaseType != typeof(MulticastDelegate) && !type.IsInterface && !type.IsEnum + select type); + + string[] customAssemblys = new string[] { + "Assembly-CSharp", + }; + var customTypes = (from assembly in customAssemblys.Select(s => Assembly.Load(s)) + from type in assembly.GetExportedTypes() + where type.Namespace == null || !type.Namespace.StartsWith("XLua") && !isExcluded(type) + && type.BaseType != typeof(MulticastDelegate) && !type.IsInterface && !type.IsEnum + select type); + + var otherTypes = new List() { + typeof(System.Object), + typeof(System.ValueType), + typeof(System.Reflection.BindingFlags), + typeof(System.Uri), + typeof(System.Enum), + typeof(System.DateTime), + typeof(System.DateTimeOffset), + typeof(System.IO.File), + typeof(System.DBNull), + typeof(System.Convert), + typeof(System.DayOfWeek), + typeof(System.Net.NetworkInformation.Ping), + typeof(System.Net.NetworkInformation.IPStatus), + typeof(System.Net.NetworkInformation.PingCompletedEventHandler), + typeof(System.Net.NetworkInformation.PingCompletedEventArgs), + typeof(System.Net.NetworkInformation.PingReply), + typeof(System.ComponentModel.AsyncCompletedEventArgs), + typeof(System.ComponentModel.Component), + typeof(UnityEngine.Events.UnityEvent), + typeof(System.Collections.Generic.List), + typeof(System.Collections.Generic.List), + typeof(System.Collections.Generic.List), + typeof(System.Collections.Generic.List), + typeof(System.Collections.Generic.List), + typeof(System.Collections.Generic.List>), + typeof(System.Collections.Generic.List), + typeof(DG.Tweening.Core.TweenerCore), + typeof(DG.Tweening.Core.TweenerCore), + typeof(System.Action), + typeof(System.Action), + typeof(System.Action), + + typeof(UnityEngine.Camera), + typeof(UnityEngine.Camera.GateFitMode), + typeof(UnityEngine.Camera.GateFitParameters), + typeof(UnityEngine.Camera.StereoscopicEye), + typeof(UnityEngine.Camera.MonoOrStereoscopicEye), + typeof(UnityEngine.Camera.FieldOfViewAxis), + typeof(UnityEngine.Camera.RenderRequest), + typeof(UnityEngine.Camera.RenderRequestMode), + typeof(UnityEngine.Camera.RenderRequestOutputSpace), + typeof(UnityEngine.Camera.RenderRequest), + typeof(UnityEngine.Camera.SceneViewFilterMode), + typeof(UnityEngine.TextCore.FaceInfo), + typeof(UnityEngine.Rendering.LightShadowResolution), + typeof(UnityEngine.RenderTextureFormat), + typeof(UnityEngine.RenderTextureReadWrite), + typeof(UnityEngine.RigidbodyConstraints), + typeof(UnityEngine.TransparencySortMode), + typeof(UnityEngine.SystemInfo), + typeof(UnityEngine.Object), + typeof(UnityEngine.Rect), + typeof(UnityEngine.Vector2), + typeof(UnityEngine.Vector3), + typeof(UnityEngine.Vector4), + typeof(UnityEngine.Quaternion), + typeof(UnityEngine.Matrix4x4), + typeof(UnityEngine.Color), + typeof(UnityEngine.Ray), + typeof(UnityEngine.Bounds), + typeof(UnityEngine.Ray2D), + typeof(UnityEngine.Time), + typeof(UnityEngine.Motion), + typeof(UnityEngine.GameObject), + typeof(UnityEngine.Component), + typeof(UnityEngine.Behaviour), + typeof(UnityEngine.EventSystems.UIBehaviour), + typeof(UnityEngine.Transform), + typeof(UnityEngine.RectTransform), + typeof(UnityEngine.RectTransform.Axis), + typeof(UnityEngine.RectTransform.Edge), + typeof(UnityEngine.Resources), + typeof(UnityEngine.TextAsset), + typeof(UnityEngine.Keyframe), + typeof(UnityEngine.Sprite), + typeof(UnityEngine.AnimatorStateInfo), + typeof(UnityEngine.AnimatorCullingMode), + typeof(UnityEngine.Animation), + typeof(UnityEngine.AnimationCurve), + typeof(UnityEngine.AnimationClip), + typeof(UnityEngine.MonoBehaviour), + typeof(UnityEngine.ParticleSystem), + typeof(UnityEngine.ParticleSystem.MainModule), + typeof(UnityEngine.ParticleSystem.EmissionModule), + typeof(UnityEngine.ParticleSystem.ShapeModule), + typeof(UnityEngine.ParticleSystem.VelocityOverLifetimeModule), + typeof(UnityEngine.ParticleSystem.LimitVelocityOverLifetimeModule), + typeof(UnityEngine.ParticleSystem.InheritVelocityModule), + typeof(UnityEngine.ParticleSystem.ForceOverLifetimeModule), + typeof(UnityEngine.ParticleSystem.ColorOverLifetimeModule), + typeof(UnityEngine.ParticleSystem.ColorBySpeedModule), + typeof(UnityEngine.ParticleSystem.SizeOverLifetimeModule), + typeof(UnityEngine.ParticleSystem.SizeBySpeedModule), + typeof(UnityEngine.ParticleSystem.RotationBySpeedModule), + typeof(UnityEngine.ParticleSystem.RotationOverLifetimeModule), + typeof(UnityEngine.ParticleSystem.ExternalForcesModule), + typeof(UnityEngine.ParticleSystem.NoiseModule), + typeof(UnityEngine.ParticleSystem.CollisionModule), + typeof(UnityEngine.ParticleSystem.TriggerModule), + typeof(UnityEngine.ParticleSystem.SubEmittersModule), + typeof(UnityEngine.ParticleSystem.TextureSheetAnimationModule), + typeof(UnityEngine.ParticleSystem.LightsModule), + typeof(UnityEngine.ParticleSystem.TrailModule), + typeof(UnityEngine.ParticleSystem.CustomDataModule), + typeof(UnityEngine.ParticleSystem.MinMaxCurve), + typeof(UnityEngine.ParticleSystem.Particle), + typeof(UnityEngine.ParticleSystem.Burst), + typeof(UnityEngine.ParticleSystem.MinMaxGradient), + typeof(UnityEngine.ParticleSystem.EmitParams), + typeof(UnityEngine.ParticleSystemRenderer), + typeof(UnityEngine.MeshRenderer), + typeof(UnityEngine.SkinnedMeshRenderer), + typeof(UnityEngine.Renderer), + typeof(UnityEngine.WWW), + typeof(UnityEngine.Light), + typeof(UnityEngine.Mathf), + typeof(UnityEngine.Debug), + typeof(UnityEngine.Screen), + typeof(UnityEngine.Resolution), + typeof(UnityEngine.Shader), + typeof(UnityEngine.ShaderVariantCollection), + typeof(UnityEngine.Playables.PlayableDirector), + typeof(UnityEngine.Playables.PlayableAsset), + typeof(UnityEngine.Playables.Playable), + typeof(UnityEngine.RuntimeAnimatorController), + typeof(UnityEngine.Application), + typeof(UnityEngine.SystemLanguage), + typeof(UnityEngine.AudioClip), + typeof(UnityEngine.SceneManagement.SceneManager), + typeof(UnityEngine.SceneManagement.Scene), + typeof(UnityEngine.AssetBundle), + typeof(UnityEngine.AssetBundleRequest), + typeof(UnityEngine.AudioSource), + typeof(UnityEngine.AsyncOperation), + typeof(UnityEngine.Avatar), + typeof(UnityEngine.Animator), + typeof(UnityEngine.Events.UnityEvent), + typeof(UnityEngine.Events.UnityEvent), + typeof(UnityEngine.Events.UnityEvent), + typeof(UnityEngine.Events.UnityEvent), + typeof(UnityEngine.Events.UnityEvent), + typeof(UnityEngine.Events.UnityEventBase), + typeof(UnityEngine.LayerMask), + typeof(UnityEngine.RenderTextureDescriptor), + typeof(UnityEngine.Material), + typeof(UnityEngine.MaterialPropertyBlock), + typeof(UnityEngine.SpriteRenderer), + typeof(UnityEngine.Mesh), + typeof(UnityEngine.MeshFilter), + typeof(UnityEngine.Rendering.ShadowCastingMode), + typeof(UnityEngine.Video.VideoClip), + typeof(UnityEngine.Video.VideoPlayer), + typeof(UnityEngine.RenderSettings), + typeof(UnityEngine.Canvas), + typeof(UnityEngine.CanvasGroup), + typeof(UnityEngine.CanvasRenderer), + typeof(UnityEngine.LineRenderer), + typeof(UnityEngine.Texture2D), + typeof(UnityEngine.Texture2D.EXRFlags), + typeof(UnityEngine.Font), + typeof(UnityEngine.RenderTexture), + typeof(UnityEngine.Texture), + typeof(UnityEngine.Graphics), + typeof(UnityEngine.Input), + typeof(UnityEngine.KeyCode), + typeof(UnityEngine.Video.VideoClip), + typeof(UnityEngine.PlayerPrefs), + typeof(UnityEngine.ShaderVariantCollection), + typeof(UnityEngine.ShaderVariantCollection.ShaderVariant), + typeof(UnityEngine.NetworkReachability), + typeof(UnityEngine.RuntimePlatform), + typeof(UnityEngine.Rendering.CompareFunction), + typeof(UnityEngine.TextAnchor), + typeof(UnityEngine.LightProbes), + typeof(UnityEngine.Graphics), + typeof(UnityEngine.BoxCollider), + typeof(UnityEngine.RaycastHit), + typeof(UnityEngine.LightmapSettings), + typeof(UnityEngine.LightmapData), + typeof(UnityEngine.LightProbes), + typeof(UnityEngine.ReflectionProbe), + typeof(UnityEngine.BatteryStatus), + typeof(UnityEngine.SystemInfo), + typeof(UnityEngine.Rigidbody), + typeof(UnityEngine.SphereCollider), + typeof(UnityEngine.ScriptableObject), + typeof(UnityEngine.Physics), + typeof(UnityEngine.PhysicMaterial), + typeof(UnityEngine.MeshCollider), + typeof(UnityEngine.UI.CanvasScaler), + typeof(UnityEngine.UI.Dropdown), + typeof(UnityEngine.UI.Dropdown.OptionData), + typeof(UnityEngine.UI.Dropdown.OptionDataList), + typeof(UnityEngine.UI.Dropdown.DropdownEvent), + typeof(UnityEngine.UI.Graphic), + typeof(UnityEngine.UI.GraphicRaycaster), + typeof(UnityEngine.UI.GraphicRaycaster.BlockingObjects), + typeof(UnityEngine.UI.Image), + typeof(UnityEngine.UI.Image.Type), + typeof(UnityEngine.UI.Image.FillMethod), + typeof(UnityEngine.UI.Image.OriginHorizontal), + typeof(UnityEngine.UI.Image.OriginVertical), + typeof(UnityEngine.UI.Image.Origin90), + typeof(UnityEngine.UI.Image.Origin180), + typeof(UnityEngine.UI.Image.Origin360), + typeof(UnityEngine.UI.Button), + typeof(UnityEngine.UI.Button.ButtonClickedEvent), + typeof(UnityEngine.UI.InputField), + typeof(UnityEngine.UI.InputField.ContentType), + typeof(UnityEngine.UI.InputField.InputType), + typeof(UnityEngine.UI.InputField.EndEditEvent), + typeof(UnityEngine.UI.InputField.CharacterValidation), + typeof(UnityEngine.UI.InputField.LineType), + typeof(UnityEngine.UI.InputField.SubmitEvent), + typeof(UnityEngine.UI.InputField.OnChangeEvent), + typeof(UnityEngine.UI.Mask), + typeof(UnityEngine.UI.MaskableGraphic), + typeof(UnityEngine.UI.MaskableGraphic.CullStateChangedEvent), + typeof(UnityEngine.UI.MaskUtilities), + typeof(UnityEngine.UI.RawImage), + typeof(UnityEngine.UI.RectMask2D), + typeof(UnityEngine.UI.Scrollbar), + typeof(UnityEngine.UI.ScrollRect), + typeof(UnityEngine.UI.ScrollRect.MovementType), + typeof(UnityEngine.UI.ScrollRect.ScrollbarVisibility), + typeof(UnityEngine.UI.ScrollRect.ScrollRectEvent), + typeof(UnityEngine.UI.Selectable), + typeof(UnityEngine.UI.Slider), + typeof(UnityEngine.UI.Slider.Direction), + typeof(UnityEngine.UI.Slider.SliderEvent), + typeof(UnityEngine.UI.Text), + typeof(UnityEngine.UI.Toggle), + typeof(UnityEngine.UI.Toggle.ToggleTransition), + typeof(UnityEngine.UI.Toggle.ToggleEvent), + typeof(UnityEngine.UI.ToggleGroup), + typeof(UnityEngine.UI.LayoutElement), + typeof(UnityEngine.UI.GridLayoutGroup), + typeof(UnityEngine.UI.GridLayoutGroup.Corner), + typeof(UnityEngine.UI.GridLayoutGroup.Axis), + typeof(UnityEngine.UI.GridLayoutGroup.Constraint), + typeof(UnityEngine.UI.VerticalLayoutGroup), + typeof(UnityEngine.UI.LayoutGroup), + typeof(UnityEngine.U2D.SpriteAtlas), + + // spine + typeof(Spine.TrackEntry), + typeof(Spine.SkeletonData), + typeof(Spine.Skeleton), + typeof(Spine.Slot), + typeof(Spine.RegionAttachment), + typeof(Spine.Animation), + typeof(Spine.AnimationState), + typeof(Spine.AnimationStateData), + typeof(Spine.AnimationStateData.AnimationPair), + typeof(Spine.AnimationStateData.AnimationPairComparer), + typeof(Spine.AnimationState.TrackEntryDelegate), + typeof(Spine.Unity.SkeletonGraphic), + typeof(Spine.Unity.SkeletonAnimation), + typeof(Spine.Unity.SkeletonDataAsset), + typeof(Spine.Unity.MeshGenerator), + typeof(Spine.MeshAttachment), + typeof(Spine.Unity.MeshGenerator.Settings), + typeof(Spine.Unity.SkeletonRenderer), + typeof(Spine.Unity.SkeletonRenderer.SpriteMaskInteractionMaterials), + typeof(Spine.Unity.BoneFollower), + typeof(Spine.Unity.BoneFollowerGraphic), + typeof(Spine.Unity.BoneFollower.AxisOrientation), + typeof(Spine.Unity.SkeletonGraphic.LayoutMode), + + // TextMeshPro + typeof(TMPro.TextAlignmentOptions), + typeof(TMPro.TMP_FontAsset), + typeof(TMPro.TMP_Character), + typeof(TMPro.TextMeshProUGUI), + typeof(TMPro.TextMeshPro), + typeof(TMPro.TMP_Text), + typeof(TMPro.TMP_Dropdown), + typeof(TMPro.TMP_Dropdown.OptionData), + typeof(TMPro.TMP_Dropdown.OptionDataList), + typeof(TMPro.TMP_Dropdown.DropdownEvent), + typeof(TMPro.TMP_InputField), + typeof(TMPro.TMP_InputField.ContentType), + typeof(TMPro.TMP_InputField.InputType), + typeof(TMPro.TMP_InputField.CharacterValidation), + typeof(TMPro.TMP_InputField.LineType), + typeof(TMPro.TMP_InputField.SubmitEvent), + typeof(TMPro.TMP_InputField.OnChangeEvent), + typeof(TMPro.TMP_InputField.SelectionEvent), + typeof(TMPro.TMP_InputField.TextSelectionEvent), + typeof(TMPro.TMP_InputField.TouchScreenKeyboardEvent), + typeof(TMP_AnimationCurve), + typeof(TMP_Curve), + + // 数数 + typeof(ThinkingAnalytics.ThinkingAnalyticsAPI), + typeof(ThinkingAnalytics.ThinkingAnalyticsAPI.TATimeZone), + typeof(ThinkingAnalytics.ThinkingAnalyticsAPI.TAMode), + typeof(ThinkingAnalytics.ThinkingAnalyticsAPI.NetworkType), + typeof(ThinkingAnalytics.ThinkingAnalyticsAPI.Token), + typeof(ThinkingAnalytics.TDPresetProperties), + + //DOTween + typeof(DG.Tweening.AutoPlay), + typeof(DG.Tweening.AxisConstraint), + typeof(DG.Tweening.Ease), + typeof(DG.Tweening.LogBehaviour), + typeof(DG.Tweening.LoopType), + typeof(DG.Tweening.PathMode), + typeof(DG.Tweening.PathType), + typeof(DG.Tweening.RotateMode), + typeof(DG.Tweening.ScrambleMode), + typeof(DG.Tweening.TweenType), + typeof(DG.Tweening.UpdateType), + typeof(DG.Tweening.DOTween), + typeof(DG.Tweening.Core.DOTweenComponent), + typeof(DG.Tweening.Core.TweenerCore), + typeof(DG.Tweening.Core.TweenerCore), + typeof(DG.Tweening.Core.TweenerCore), + typeof(DG.Tweening.Core.TweenerCore), + typeof(DG.Tweening.Core.TweenerCore), + typeof(DG.Tweening.Core.TweenerCore), + typeof(DG.Tweening.Core.TweenerCore), + typeof(DG.Tweening.DOVirtual), + typeof(DG.Tweening.EaseFactory), + typeof(DG.Tweening.Tweener), + typeof(DG.Tweening.Tween), + typeof(DG.Tweening.Sequence), + typeof(DG.Tweening.TweenParams), + typeof(DG.Tweening.Core.ABSSequentiable), + typeof(DG.Tweening.TweenCallback), + typeof(DG.Tweening.TweenExtensions), + typeof(DG.Tweening.TweenSettingsExtensions), + typeof(DG.Tweening.ShortcutExtensions), + typeof(DG.Tweening.DOTweenModuleUI), + + // BestHTTP + typeof(Http.RequestState), + typeof(BestHTTP.HTTPRequest), + typeof(BestHTTP.HTTPResponse), + typeof(BestHTTP.Connections.HTTP2.HTTP2Response), + typeof(BestHTTP.Forms.HTTPUrlEncodedForm), + typeof(BestHTTP.Forms.HTTPFormBase), + + // 支付 + typeof(UnityEngine.Purchasing.Product), + typeof(UnityEngine.Purchasing.ProductDefinition), + typeof(UnityEngine.Purchasing.ProductMetadata), + typeof(UnityEngine.Purchasing.ProductType), + + typeof(BF.MonoSingleton), + typeof(BF.MonoSingleton), + typeof(BF.BFSlider.FillDirection), + typeof(BF.ScrollRectBaseOld.MovementType), + typeof(BF.ScrollRectBaseOld.ScrollbarVisibility), + typeof(BF.NetServiceType), + typeof(BF.NetIncomingMessageType), + + // Touch + typeof(BF.BFEvent>), + typeof(BF.BFEvent), + typeof(BF.BFEvent), + typeof(BF.TouchEventType), + typeof(BF.SelectEventType), + typeof(BF.NativeCore.ThirdPlatform.FacebookSdk), + typeof(BF.NativeCore.ThirdPlatform.AppsFlyerSdk), + + typeof(AdManager), + + // 震动插件 + // typeof(Lofelt.NiceVibrations.HapticPatterns), + // typeof(Lofelt.NiceVibrations.LofeltHaptics), + // typeof(Lofelt.NiceVibrations.HapticPatterns.PresetType), + + typeof(UnityEngine.Purchasing.Security.AppleStoreKitTestTangle), + typeof(UnityEngine.Purchasing.Security.AppleTangle), + typeof(UnityEngine.SignInWithApple.SignInWithApple.CallbackArgs), + typeof(UnityEngine.SignInWithApple.SignInWithAppleEvent), + typeof(UnityEngine.SignInWithApple.SignInWithApple), + typeof(UnityEngine.SignInWithApple.UserInfo), + typeof(BF.EnumFlagsAttribute), + }; + return unityTypes.Concat(customTypes).Concat(otherTypes); + } + } + + //自动把LuaCallCSharp涉及到的delegate加到CSharpCallLua列表,后续可以直接用lua函数做callback + [CSharpCallLua] + public static List CSharpCallLua + { + get + { + var lua_call_csharp = LuaCallCSharp; + var delegate_types = new List(); + var flag = BindingFlags.Public | BindingFlags.Instance + | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.DeclaredOnly; + foreach (var field in (from type in lua_call_csharp select type).SelectMany(type => type.GetFields(flag))) + { + // 增加过滤黑名单class + if (typeof(Delegate).IsAssignableFrom(field.FieldType) && !isExcluded(field.FieldType)) + { + delegate_types.Add(field.FieldType); + } + } + + foreach (var method in (from type in lua_call_csharp select type).SelectMany(type => type.GetMethods(flag))) + { + // 增加过滤黑名单class + if (typeof(Delegate).IsAssignableFrom(method.ReturnType) && !isExcluded(method.ReturnType)) + { + delegate_types.Add(method.ReturnType); + } + foreach (var param in method.GetParameters()) + { + var paramType = param.ParameterType.IsByRef ? param.ParameterType.GetElementType() : param.ParameterType; + // 增加过滤黑名单class + if (typeof(Delegate).IsAssignableFrom(paramType) && !isExcluded(paramType)) + { + delegate_types.Add(paramType); + } + } + } + return delegate_types.Where(t => t.BaseType == typeof(MulticastDelegate) && !hasGenericParameter(t) && !delegateHasEditorRef(t)).Distinct().ToList(); + } + } + //黑名单 + [BlackList] + public static List> BlackList = new List>() { + new List(){"System.Xml.XmlNodeList", "ItemOf"}, + new List(){"UnityEngine.WWW", "movie"}, +#if UNITY_WEBGL + new List(){"UnityEngine.WWW", "threadPriority"}, +#endif + new List(){"UnityEngine.Texture2D", "alphaIsTransparency"}, + new List(){"UnityEngine.Security", "GetChainOfTrustValue"}, + new List(){"UnityEngine.CanvasRenderer", "onRequestRebuild"}, + new List(){"UnityEngine.Light", "areaSize"}, + new List(){"UnityEngine.Light", "lightmapBakeType"}, + new List(){"UnityEngine.Light", "SetLightDirty"}, + new List(){"UnityEngine.Light", "shadowRadius"}, + new List(){"UnityEngine.Light", "shadowAngle"}, + new List(){"UnityEngine.WWW", "MovieTexture"}, + new List(){"UnityEngine.WWW", "GetMovieTexture"}, + new List(){"UnityEngine.AnimatorOverrideController", "PerformOverrideClipListCleanup"}, +#if !UNITY_WEBPLAYER + new List(){"UnityEngine.Application", "ExternalEval"}, +#endif + new List(){"UnityEngine.GameObject", "networkView"}, //4.6.2 not support + new List(){"UnityEngine.Component", "networkView"}, //4.6.2 not support + new List(){"System.IO.FileInfo", "GetAccessControl", "System.Security.AccessControl.AccessControlSections"}, + new List(){"System.IO.FileInfo", "SetAccessControl", "System.Security.AccessControl.FileSecurity"}, + new List(){"System.IO.File", "Create", "System.String", "System.Int32", "System.IO.FileOptions", "System.Security.AccessControl.FileSecurity"}, + new List(){"System.IO.File", "SetAccessControl", "System.String", "System.Security.AccessControl.FileSecurity"}, + new List(){"System.IO.File", "GetAccessControl", "System.String"}, + new List(){"System.IO.File", "GetAccessControl", "System.String", "System.Security.AccessControl.AccessControlSections"}, + new List(){"System.IO.DirectoryInfo", "GetAccessControl", "System.Security.AccessControl.AccessControlSections"}, + new List(){"System.IO.DirectoryInfo", "SetAccessControl", "System.Security.AccessControl.DirectorySecurity"}, + new List(){"System.IO.DirectoryInfo", "CreateSubdirectory", "System.String", "System.Security.AccessControl.DirectorySecurity"}, + new List(){"System.IO.DirectoryInfo", "Create", "System.Security.AccessControl.DirectorySecurity"}, + new List(){"UnityEngine.MonoBehaviour", "runInEditMode"}, + new List(){"UnityEngine.Texture", "imageContentsHash"}, + new List(){"UnityEngine.UI.Text", "OnRebuildRequested"}, + new List(){"UnityEngine.UI.Graphic", "OnRebuildRequested"}, + new List(){"BF.Atlas", "Clear"}, + new List(){"BF.Atlas", "GetCount"}, + new List(){"BF.Atlas", "AddSprite", "UnityEngine.Sprite"}, + new List(){"BF.Atlas", "RemoveSprite", "UnityEngine.Sprite"}, + new List(){"BF.Atlas", "Contains", "UnityEngine.Sprite"}, + new List(){"BF.Atlas", "Contains", "System.String"}, + new List(){"BF.Atlas", "RemoveNullSprite"}, + new List(){"UnityEngine.Input", "IsJoystickPreconfigured", "System.String"}, + new List(){"UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset", "Create"}, + new List(){"UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset", "Create", "UnityEngine.Rendering.Universal.ScriptableRendererData"}, + new List(){"UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset", "packagePath"}, + new List(){"UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset", "editorResourcesGUID"}, + new List(){"UnityEngine.MeshRenderer", "scaleInLightmap"}, + new List(){"UnityEngine.MeshRenderer", "receiveGI"}, + new List(){"UnityEngine.MeshRenderer", "stitchLightmapSeams"}, + new List(){"UnityEngine.MeshRenderer", "stitchLightmapSeams"}, + new List(){"UnityEngine.ParticleSystemForceField", "FindAll"}, + new List(){"UnityEngine.ParticleSystemRenderer", "supportsMeshInstancing"}, + new List(){"Spine.Unity.SkeletonRenderer", "Start"}, + new List(){"Spine.Unity.SkeletonRenderer", "EditorSkipSkinSync"}, + new List(){"UnityEngine.AudioSource", "PlayOnGamepad", "System.Int32"}, + new List(){"UnityEngine.AudioSource", "DisableGamepadOutput"}, + new List(){"UnityEngine.AudioSource", "SetGamepadSpeakerMixLevel", "System.Int32", "System.Int32"}, + new List(){"UnityEngine.AudioSource", "SetGamepadSpeakerMixLevelDefault", "System.Int32"}, + new List(){"UnityEngine.AudioSource", "SetGamepadSpeakerRestrictedAudio", "System.Int32", "System.Boolean"}, + new List(){"UnityEngine.AudioSource", "SetGamepadSpeakerMixLevelDefault", "System.Int32"}, + new List(){"UnityEngine.AudioSource", "GamepadSpeakerSupportsOutputType", "UnityEngine.GamepadSpeakerOutputType"}, + new List(){"UnityEngine.AudioSource", "gamepadSpeakerOutputType",}, + new List(){"UnityEngine.Handheld", "SetActivityIndicatorStyle", "UnityEngine.AndroidActivityIndicatorStyle"}, + new List(){"UnityEngine.Handheld", "SetActivityIndicatorStyle", "UnityEngine.iOS.ActivityIndicatorStyle"}, + new List(){"ThinkingAnalytics.ThinkingAnalyticsAPI", "onPostProcessBuild", "UnityEditor.BuildTarget", "System.String"}, + new List(){"FBWindowsPhysicalGamepadManager", "state"}, + new List(){"IronSourceBannerEvents", "onAdLoaded", "System.String"}, + new List(){"IronSourceBannerEvents", "onAdLoadFailed", "System.String"}, + new List(){"IronSourceBannerEvents", "onAdClicked", "System.String"}, + new List(){"IronSourceBannerEvents", "onAdScreenPresented", "System.String"}, + new List(){"IronSourceBannerEvents", "onAdScreenDismissed", "System.String"}, + new List(){"IronSourceBannerEvents", "onAdLeftApplication", "System.String"}, + new List(){"IronSourceEvents", "onSdkInitializationCompleted", "System.String"}, + new List(){"IronSourceEvents", "onRewardedVideoAdOpened", "System.String"}, + new List(){"IronSourceEvents", "onRewardedVideoAdClosed", "System.String"}, + new List(){"IronSourceEvents", "onRewardedVideoAdStarted", "System.String"}, + new List(){"IronSourceEvents", "onRewardedVideoAdEnded", "System.String"}, + new List(){"IronSourceEvents", "onRewardedVideoAdShowFailed", "System.String"}, + new List(){"IronSourceEvents", "onRewardedVideoAdRewarded", "System.String"}, + new List(){"IronSourceEvents", "onRewardedVideoAdClicked", "System.String"}, + new List(){"IronSourceEvents", "onRewardedVideoAvailabilityChanged", "System.String"}, + new List(){"IronSourceEvents", "onRewardedVideoAdLoadedDemandOnly", "System.String"}, + new List(){"IronSourceEvents", "onRewardedVideoAdLoadFailedDemandOnly", "System.String"}, + new List(){"IronSourceEvents", "onRewardedVideoAdOpenedDemandOnly", "System.String"}, + new List(){"IronSourceEvents", "onRewardedVideoAdRewardedDemandOnly", "System.String"}, + new List(){"IronSourceEvents", "onRewardedVideoAdShowFailedDemandOnly", "System.String"}, + new List(){"IronSourceEvents", "onRewardedVideoAdClosedDemandOnly", "System.String"}, + new List(){"IronSourceEvents", "onRewardedVideoAdClickedDemandOnly", "System.String"}, + new List(){"IronSourceEvents", "onSegmentReceived", "System.String"}, + new List(){"IronSourceEvents", "onInterstitialAdReady"}, + new List(){"IronSourceEvents", "onInterstitialAdLoadFailed", "System.String"}, + new List(){"IronSourceEvents", "onInterstitialAdOpened", "System.String"}, + new List(){"IronSourceEvents", "onInterstitialAdClosed", "System.String"}, + new List(){"IronSourceEvents", "onInterstitialAdShowSucceeded", "System.String"}, + new List(){"IronSourceEvents", "onInterstitialAdShowFailed", "System.String"}, + new List(){"IronSourceEvents", "onInterstitialAdClicked", "System.String"}, + new List(){"IronSourceEvents", "onInterstitialAdReadyDemandOnly", "System.String"}, + new List(){"IronSourceEvents", "onInterstitialAdLoadFailedDemandOnly", "System.String"}, + new List(){"IronSourceEvents", "onInterstitialAdOpenedDemandOnly", "System.String"}, + new List(){"IronSourceEvents", "onInterstitialAdClosedDemandOnly", "System.String"}, + new List(){"IronSourceEvents", "onInterstitialAdShowFailedDemandOnly", "System.String"}, + new List(){"IronSourceEvents", "onInterstitialAdClickedDemandOnly", "System.String"}, + new List(){"IronSourceEvents", "onOfferwallOpened", "System.String"}, + new List(){"IronSourceEvents", "onOfferwallShowFailed", "System.String"}, + new List(){"IronSourceEvents", "onOfferwallClosed", "System.String"}, + new List(){"IronSourceEvents", "onGetOfferwallCreditsFailed", "System.String"}, + new List(){"IronSourceEvents", "onOfferwallAdCredited", "System.String"}, + new List(){"IronSourceEvents", "onOfferwallAvailable", "System.String"}, + new List(){"IronSourceEvents", "onBannerAdLoaded"}, + new List(){"IronSourceEvents", "onBannerAdLoadFailed", "System.String"}, + new List(){"IronSourceEvents", "onBannerAdClicked"}, + new List(){"IronSourceEvents", "onBannerAdScreenPresented"}, + new List(){"IronSourceEvents", "onBannerAdScreenDismissed"}, + new List(){"IronSourceEvents", "onBannerAdLeftApplication"}, + new List(){"IronSourceEvents", "onImpressionSuccess", "System.String"}, + new List(){"IronSourceEvents", "onRewardedVideoAdLoadFailed", "System.String"}, + new List(){"IronSourceEvents", "onRewardedVideoAdReady", "System.String"}, + new List(){"IronSourceInterstitialEvents", "onAdReady", "System.String"}, + new List(){"IronSourceInterstitialEvents", "onAdLoadFailed", "System.String"}, + new List(){"IronSourceInterstitialEvents", "onAdOpened", "System.String"}, + new List(){"IronSourceInterstitialEvents", "onAdClosed", "System.String"}, + new List(){"IronSourceInterstitialEvents", "onAdShowSucceeded", "System.String"}, + new List(){"IronSourceInterstitialEvents", "onAdShowFailed", "System.String"}, + new List(){"IronSourceInterstitialEvents", "onAdClicked", "System.String"}, + new List(){"IronSourceRewardedVideoEvents", "onAdShowFailed", "System.String"}, + new List(){"IronSourceRewardedVideoEvents", "onAdClosed", "System.String"}, + new List(){"IronSourceRewardedVideoEvents", "onAdRewarded", "System.String"}, + new List(){"IronSourceRewardedVideoEvents", "onAdOpened", "System.String"}, + new List(){"IronSourceRewardedVideoEvents", "onAdClicked", "System.String"}, + new List(){"IronSourceRewardedVideoEvents", "onAdAvailable", "System.String"}, + new List(){"IronSourceRewardedVideoEvents", "onAdUnavailable"}, + new List(){"IronSourceRewardedVideoEvents", "onAdLoadFailed", "System.String"}, + new List(){"IronSourceRewardedVideoEvents", "onAdReady", "System.String"}, + new List(){"UnityEngine.Rendering.Universal.ShaderUtils", "GetShaderGUID", "UnityEngine.Rendering.Universal.ShaderPathID"}, + new List(){"Spine.Unity.SkeletonRenderer", "EditorUpdateMeshFilterHideFlags"}, + new List(){"Spine.Unity.SkeletonRenderer", "fixPrefabOverrideViaMeshFilter"}, + new List(){"Spine.Unity.SkeletonRenderer", "fixPrefabOverrideViaMeshFilterGlobal"}, + new List(){"Spine.Unity.SkeletonDataAsset", "errorIfSkeletonFileNullGlobal"}, + new List(){"Spine.Unity.SkeletonGraphic", "ResetRectToReferenceRectSize"}, + new List(){"Spine.Unity.SkeletonGraphic", "GetReferenceRectSize"}, + new List(){"Spine.Unity.SpineHandles", "DrawReferenceRect", "Spine.Unity.SkeletonGraphic", "UnityEngine.Color"}, + new List(){"Spine.Unity.SkeletonGraphic", "EditReferenceRect"}, + new List(){"Spine.Unity.SkeletonGraphic", "RectTransformSize"}, + }; + + static bool hasGenericParameter(Type type) + { + if (type.IsGenericTypeDefinition) return true; + if (type.IsGenericParameter) return true; + if (type.IsByRef || type.IsArray) + { + return hasGenericParameter(type.GetElementType()); + } + if (type.IsGenericType) + { + foreach (var typeArg in type.GetGenericArguments()) + { + if (hasGenericParameter(typeArg)) + { + return true; + } + } + } + return false; + } + + static bool typeHasEditorRef(Type type) + { + if (type.Namespace != null && (type.Namespace == "UnityEditor" || type.Namespace.StartsWith("UnityEditor."))) + { + return true; + } + if (type.IsNested) + { + return typeHasEditorRef(type.DeclaringType); + } + if (type.IsByRef || type.IsArray) + { + return typeHasEditorRef(type.GetElementType()); + } + if (type.IsGenericType) + { + foreach (var typeArg in type.GetGenericArguments()) + { + if (typeArg.IsGenericParameter) + { + //skip unsigned type parameter + continue; + } + if (typeHasEditorRef(typeArg)) + { + return true; + } + } + } + return false; + } + + static bool delegateHasEditorRef(Type delegateType) + { + if (typeHasEditorRef(delegateType)) return true; + var method = delegateType.GetMethod("Invoke"); + if (method == null) + { + return false; + } + if (typeHasEditorRef(method.ReturnType)) return true; + return method.GetParameters().Any(pinfo => typeHasEditorRef(pinfo.ParameterType)); + } + } } \ No newline at end of file diff --git a/Assets/Editor/SpineSettings.asset b/Assets/Editor/SpineSettings.asset index bf3755766..07b53ddea 100644 --- a/Assets/Editor/SpineSettings.asset +++ b/Assets/Editor/SpineSettings.asset @@ -14,18 +14,22 @@ MonoBehaviour: m_EditorClassIdentifier: defaultScale: 0.01 defaultMix: 0.2 - defaultShader: BF/Spine/Skeleton + defaultShader: Spine/Skeleton defaultZSpacing: 0 defaultInstantiateLoop: 1 showHierarchyIcons: 1 + reloadAfterPlayMode: 1 setTextureImporterSettings: 1 textureSettingsReference: Assets/ThirdParty/Spine/Editor/spine-unity/Editor/ImporterPresets/PMATexturePreset.preset + fixPrefabOverrideViaMeshFilter: 0 + removePrefabPreviewMeshes: 0 blendModeMaterialMultiply: {fileID: 0} blendModeMaterialScreen: {fileID: 0} blendModeMaterialAdditive: {fileID: 0} atlasTxtImportWarning: 1 textureImporterWarning: 1 componentMaterialWarning: 1 + skeletonDataAssetNoFileError: 1 autoReloadSceneSkeletons: 1 handleScale: 1 mecanimEventIncludeFolderName: 1 diff --git a/Assets/ThirdParty/Spine Examples/Images/outline-shaders-heading.png.meta b/Assets/ThirdParty/Spine Examples/Images/outline-shaders-heading.png.meta index 5cee8b48a..12662fa25 100644 --- a/Assets/ThirdParty/Spine Examples/Images/outline-shaders-heading.png.meta +++ b/Assets/ThirdParty/Spine Examples/Images/outline-shaders-heading.png.meta @@ -1,108 +1,103 @@ -fileFormatVersion: 2 -guid: de1fb4dac677a6d45ae2ad12a49091c0 -TextureImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 11 - mipmaps: - mipMapMode: 0 - enableMipMap: 0 - sRGBTexture: 1 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - streamingMipmaps: 0 - streamingMipmapsPriority: 0 - vTOnly: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: 1 - maxTextureSize: 2048 - textureSettings: - serializedVersion: 2 - filterMode: 1 - aniso: 1 - mipBias: 0 - wrapU: 1 - wrapV: 1 - wrapW: 0 - nPOTScale: 0 - lightmap: 0 - compressionQuality: 50 - spriteMode: 1 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spriteGenerateFallbackPhysicsShape: 1 - alphaUsage: 1 - alphaIsTransparency: 1 - spriteTessellationDetail: -1 - textureType: 8 - textureShape: 1 - singleChannelComponent: 0 - flipbookRows: 1 - flipbookColumns: 1 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - ignorePngGamma: 0 - applyGammaDecoding: 1 - platformSettings: - - serializedVersion: 3 - buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - forceMaximumCompressionQuality_BC6H_BC7: 0 - - serializedVersion: 3 - buildTarget: Standalone - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - forceMaximumCompressionQuality_BC6H_BC7: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - bones: [] - spriteID: 5e97eb03825dee720800000000000000 - internalID: 0 - vertices: [] - indices: - edges: [] - weights: [] - secondaryTextures: [] - spritePackingTag: - pSDRemoveMatte: 0 - pSDShowRemoveMatteOption: 0 - userData: - assetBundleName: - assetBundleVariant: +fileFormatVersion: 2 +guid: de1fb4dac677a6d45ae2ad12a49091c0 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: 1 + wrapV: 1 + wrapW: -1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThirdParty/Spine Examples/Other Examples/Animation Tester/SpineAnimationTesterTool.cs b/Assets/ThirdParty/Spine Examples/Other Examples/Animation Tester/SpineAnimationTesterTool.cs index 4ce80557d..e95956c5a 100644 --- a/Assets/ThirdParty/Spine Examples/Other Examples/Animation Tester/SpineAnimationTesterTool.cs +++ b/Assets/ThirdParty/Spine Examples/Other Examples/Animation Tester/SpineAnimationTesterTool.cs @@ -1,162 +1,162 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using Spine; -using Spine.Unity; -using System.Collections; -using System.Collections.Generic; -using System.Text; -using UnityEngine; - -namespace Spine.Unity.Examples { - public class SpineAnimationTesterTool : MonoBehaviour, IHasSkeletonDataAsset, IHasSkeletonComponent { - - public SkeletonAnimation skeletonAnimation; - public SkeletonDataAsset SkeletonDataAsset { get { return skeletonAnimation.SkeletonDataAsset; } } - public ISkeletonComponent SkeletonComponent { get { return skeletonAnimation; } } - - public bool useOverrideMixDuration; - public float overrideMixDuration = 0.2f; - - public bool useOverrideAttachmentThreshold = true; - - [Range(0f, 1f)] - public float attachmentThreshold = 0.5f; - - public bool useOverrideDrawOrderThreshold; - [Range(0f, 1f)] - public float drawOrderThreshold = 0.5f; - - [System.Serializable] - public struct AnimationControl { - [SpineAnimation] - public string animationName; - public bool loop; - public KeyCode key; - - [Space] - public bool useCustomMixDuration; - public float mixDuration; - //public bool useChainToControl; - //public int chainToControl; - } - [System.Serializable] - public class ControlledTrack { - public List controls = new List(); - } - - [Space] - public List trackControls = new List(); - - [Header("UI")] - public UnityEngine.UI.Text boundAnimationsText; - public UnityEngine.UI.Text skeletonNameText; - - void OnValidate () { - // Fill in the SkeletonData asset name - if (skeletonNameText != null) { - if (skeletonAnimation != null && skeletonAnimation.skeletonDataAsset != null) { - skeletonNameText.text = SkeletonDataAsset.name.Replace("_SkeletonData", ""); - } - } - - // Fill in the control list. - if (boundAnimationsText != null) { - StringBuilder boundAnimationsStringBuilder = new StringBuilder(); - boundAnimationsStringBuilder.AppendLine("Animation Controls:"); - - for (int trackIndex = 0; trackIndex < trackControls.Count; trackIndex++) { - - if (trackIndex > 0) - boundAnimationsStringBuilder.AppendLine(); - - boundAnimationsStringBuilder.AppendFormat("---- Track {0} ---- \n", trackIndex); - foreach (AnimationControl ba in trackControls[trackIndex].controls) { - string animationName = ba.animationName; - if (string.IsNullOrEmpty(animationName)) - animationName = "SetEmptyAnimation"; - - boundAnimationsStringBuilder.AppendFormat("[{0}] {1}\n", ba.key.ToString(), animationName); - } - - } - - boundAnimationsText.text = boundAnimationsStringBuilder.ToString(); - - } - - } - - void Start () { - if (useOverrideMixDuration) { - skeletonAnimation.AnimationState.Data.DefaultMix = overrideMixDuration; - } - } - - void Update () { - AnimationState animationState = skeletonAnimation.AnimationState; - - // For each track - for (int trackIndex = 0; trackIndex < trackControls.Count; trackIndex++) { - - // For each control in the track - foreach (AnimationControl control in trackControls[trackIndex].controls) { - - // Check each control, and play the appropriate animation. - if (Input.GetKeyDown(control.key)) { - TrackEntry trackEntry; - if (!string.IsNullOrEmpty(control.animationName)) { - trackEntry = animationState.SetAnimation(trackIndex, control.animationName, control.loop); - - } else { - float mix = control.useCustomMixDuration ? control.mixDuration : animationState.Data.DefaultMix; - trackEntry = animationState.SetEmptyAnimation(trackIndex, mix); - } - - if (trackEntry != null) { - if (control.useCustomMixDuration) - trackEntry.MixDuration = control.mixDuration; - - if (useOverrideAttachmentThreshold) - trackEntry.AttachmentThreshold = attachmentThreshold; - - if (useOverrideDrawOrderThreshold) - trackEntry.DrawOrderThreshold = drawOrderThreshold; - } - - // Don't parse more than one animation per track. - break; - } - } - } - - } - - } -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using Spine; +using Spine.Unity; +using System.Collections; +using System.Collections.Generic; +using System.Text; +using UnityEngine; + +namespace Spine.Unity.Examples { + public class SpineAnimationTesterTool : MonoBehaviour, IHasSkeletonDataAsset, IHasSkeletonComponent { + + public SkeletonAnimation skeletonAnimation; + public SkeletonDataAsset SkeletonDataAsset { get { return skeletonAnimation.SkeletonDataAsset; } } + public ISkeletonComponent SkeletonComponent { get { return skeletonAnimation; } } + + public bool useOverrideMixDuration; + public float overrideMixDuration = 0.2f; + + public bool useOverrideAttachmentThreshold = true; + + [Range(0f, 1f)] + public float attachmentThreshold = 0.5f; + + public bool useOverrideDrawOrderThreshold; + [Range(0f, 1f)] + public float drawOrderThreshold = 0.5f; + + [System.Serializable] + public struct AnimationControl { + [SpineAnimation] + public string animationName; + public bool loop; + public KeyCode key; + + [Space] + public bool useCustomMixDuration; + public float mixDuration; + //public bool useChainToControl; + //public int chainToControl; + } + [System.Serializable] + public class ControlledTrack { + public List controls = new List(); + } + + [Space] + public List trackControls = new List(); + + [Header("UI")] + public UnityEngine.UI.Text boundAnimationsText; + public UnityEngine.UI.Text skeletonNameText; + + void OnValidate () { + // Fill in the SkeletonData asset name + if (skeletonNameText != null) { + if (skeletonAnimation != null && skeletonAnimation.skeletonDataAsset != null) { + skeletonNameText.text = SkeletonDataAsset.name.Replace("_SkeletonData", ""); + } + } + + // Fill in the control list. + if (boundAnimationsText != null) { + StringBuilder boundAnimationsStringBuilder = new StringBuilder(); + boundAnimationsStringBuilder.AppendLine("Animation Controls:"); + + for (int trackIndex = 0; trackIndex < trackControls.Count; trackIndex++) { + + if (trackIndex > 0) + boundAnimationsStringBuilder.AppendLine(); + + boundAnimationsStringBuilder.AppendFormat("---- Track {0} ---- \n", trackIndex); + foreach (AnimationControl ba in trackControls[trackIndex].controls) { + string animationName = ba.animationName; + if (string.IsNullOrEmpty(animationName)) + animationName = "SetEmptyAnimation"; + + boundAnimationsStringBuilder.AppendFormat("[{0}] {1}\n", ba.key.ToString(), animationName); + } + + } + + boundAnimationsText.text = boundAnimationsStringBuilder.ToString(); + + } + + } + + void Start () { + if (useOverrideMixDuration) { + skeletonAnimation.AnimationState.Data.DefaultMix = overrideMixDuration; + } + } + + void Update () { + AnimationState animationState = skeletonAnimation.AnimationState; + + // For each track + for (int trackIndex = 0; trackIndex < trackControls.Count; trackIndex++) { + + // For each control in the track + foreach (AnimationControl control in trackControls[trackIndex].controls) { + + // Check each control, and play the appropriate animation. + if (Input.GetKeyDown(control.key)) { + TrackEntry trackEntry; + if (!string.IsNullOrEmpty(control.animationName)) { + trackEntry = animationState.SetAnimation(trackIndex, control.animationName, control.loop); + + } else { + float mix = control.useCustomMixDuration ? control.mixDuration : animationState.Data.DefaultMix; + trackEntry = animationState.SetEmptyAnimation(trackIndex, mix); + } + + if (trackEntry != null) { + if (control.useCustomMixDuration) + trackEntry.MixDuration = control.mixDuration; + + if (useOverrideAttachmentThreshold) + trackEntry.AttachmentThreshold = attachmentThreshold; + + if (useOverrideDrawOrderThreshold) + trackEntry.DrawOrderThreshold = drawOrderThreshold; + } + + // Don't parse more than one animation per track. + break; + } + } + } + + } + + } +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/AttackSpineboy.cs b/Assets/ThirdParty/Spine Examples/Scripts/AttackSpineboy.cs index 96e71ea6b..5320f3b85 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/AttackSpineboy.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/AttackSpineboy.cs @@ -1,71 +1,71 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using UnityEngine; -using UnityEngine.UI; - -namespace Spine.Unity.Examples { - public class AttackSpineboy : MonoBehaviour { - - public SkeletonAnimation spineboy; - public SkeletonAnimation attackerSpineboy; - public SpineGauge gauge; - public Text healthText; - - int currentHealth = 100; - const int maxHealth = 100; - - public AnimationReferenceAsset shoot, hit, idle, death; - - public UnityEngine.Events.UnityEvent onAttack; - - void Update () { - if (Input.GetKeyDown(KeyCode.Space)) { - currentHealth -= 10; - healthText.text = currentHealth + "/" + maxHealth; - - attackerSpineboy.AnimationState.SetAnimation(1, shoot, false); - attackerSpineboy.AnimationState.AddEmptyAnimation(1, 0.5f, 2f); - - if (currentHealth > 0) { - spineboy.AnimationState.SetAnimation(0, hit, false); - spineboy.AnimationState.AddAnimation(0, idle, true, 0); - gauge.fillPercent = (float)currentHealth / (float)maxHealth; - onAttack.Invoke(); - } else { - if (currentHealth >= 0) { - gauge.fillPercent = 0; - spineboy.AnimationState.SetAnimation(0, death, false).TrackEnd = float.PositiveInfinity; - } - } - } - } - } - -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using UnityEngine; +using UnityEngine.UI; + +namespace Spine.Unity.Examples { + public class AttackSpineboy : MonoBehaviour { + + public SkeletonAnimation spineboy; + public SkeletonAnimation attackerSpineboy; + public SpineGauge gauge; + public Text healthText; + + int currentHealth = 100; + const int maxHealth = 100; + + public AnimationReferenceAsset shoot, hit, idle, death; + + public UnityEngine.Events.UnityEvent onAttack; + + void Update () { + if (Input.GetKeyDown(KeyCode.Space)) { + currentHealth -= 10; + healthText.text = currentHealth + "/" + maxHealth; + + attackerSpineboy.AnimationState.SetAnimation(1, shoot, false); + attackerSpineboy.AnimationState.AddEmptyAnimation(1, 0.5f, 2f); + + if (currentHealth > 0) { + spineboy.AnimationState.SetAnimation(0, hit, false); + spineboy.AnimationState.AddAnimation(0, idle, true, 0); + gauge.fillPercent = (float)currentHealth / (float)maxHealth; + onAttack.Invoke(); + } else { + if (currentHealth >= 0) { + gauge.fillPercent = 0; + spineboy.AnimationState.SetAnimation(0, death, false).TrackEnd = float.PositiveInfinity; + } + } + } + } + } + +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/DraggableTransform.cs b/Assets/ThirdParty/Spine Examples/Scripts/DraggableTransform.cs index 890df4439..637c86b56 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/DraggableTransform.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/DraggableTransform.cs @@ -1,56 +1,56 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace Spine.Unity.Examples { - public class DraggableTransform : MonoBehaviour { - - Vector2 mousePreviousWorld, mouseDeltaWorld; - Camera mainCamera; - - void Start () { - mainCamera = Camera.main; - } - - void Update () { - Vector2 mouseCurrent = Input.mousePosition; - Vector2 mouseCurrentWorld = mainCamera.ScreenToWorldPoint(new Vector3(mouseCurrent.x, mouseCurrent.y, -mainCamera.transform.position.z)); - - mouseDeltaWorld = mouseCurrentWorld - mousePreviousWorld; - mousePreviousWorld = mouseCurrentWorld; - } - - void OnMouseDrag () { - transform.Translate(mouseDeltaWorld); - } - } -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Spine.Unity.Examples { + public class DraggableTransform : MonoBehaviour { + + Vector2 mousePreviousWorld, mouseDeltaWorld; + Camera mainCamera; + + void Start () { + mainCamera = Camera.main; + } + + void Update () { + Vector2 mouseCurrent = Input.mousePosition; + Vector2 mouseCurrentWorld = mainCamera.ScreenToWorldPoint(new Vector3(mouseCurrent.x, mouseCurrent.y, -mainCamera.transform.position.z)); + + mouseDeltaWorld = mouseCurrentWorld - mousePreviousWorld; + mousePreviousWorld = mouseCurrentWorld; + } + + void OnMouseDrag () { + transform.Translate(mouseDeltaWorld); + } + } +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/FootSoldierExample.cs b/Assets/ThirdParty/Spine Examples/Scripts/FootSoldierExample.cs index 628c13576..d893eb8b9 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/FootSoldierExample.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/FootSoldierExample.cs @@ -1,103 +1,103 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -// Contributed by: Mitch Thompson - -using Spine.Unity; -using System.Collections; -using UnityEngine; - -namespace Spine.Unity.Examples { - public class FootSoldierExample : MonoBehaviour { - [SpineAnimation("Idle")] - public string idleAnimation; - - [SpineAnimation] - public string attackAnimation; - - [SpineAnimation] - public string moveAnimation; - - [SpineSlot] - public string eyesSlot; - - [SpineAttachment(currentSkinOnly: true, slotField: "eyesSlot")] - public string eyesOpenAttachment; - - [SpineAttachment(currentSkinOnly: true, slotField: "eyesSlot")] - public string blinkAttachment; - - [Range(0, 0.2f)] - public float blinkDuration = 0.05f; - - public KeyCode attackKey = KeyCode.Mouse0; - public KeyCode rightKey = KeyCode.D; - public KeyCode leftKey = KeyCode.A; - - public float moveSpeed = 3; - - SkeletonAnimation skeletonAnimation; - - void Awake () { - skeletonAnimation = GetComponent(); - skeletonAnimation.OnRebuild += Apply; - } - - void Apply (SkeletonRenderer skeletonRenderer) { - StartCoroutine(Blink()); - } - - void Update () { - if (Input.GetKey(attackKey)) { - skeletonAnimation.AnimationName = attackAnimation; - } else { - if (Input.GetKey(rightKey)) { - skeletonAnimation.AnimationName = moveAnimation; - skeletonAnimation.Skeleton.ScaleX = 1; - transform.Translate(moveSpeed * Time.deltaTime, 0, 0); - } else if (Input.GetKey(leftKey)) { - skeletonAnimation.AnimationName = moveAnimation; - skeletonAnimation.Skeleton.ScaleX = -1; - transform.Translate(-moveSpeed * Time.deltaTime, 0, 0); - } else { - skeletonAnimation.AnimationName = idleAnimation; - } - } - } - - IEnumerator Blink () { - while (true) { - yield return new WaitForSeconds(Random.Range(0.25f, 3f)); - skeletonAnimation.Skeleton.SetAttachment(eyesSlot, blinkAttachment); - yield return new WaitForSeconds(blinkDuration); - skeletonAnimation.Skeleton.SetAttachment(eyesSlot, eyesOpenAttachment); - } - } - } -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +// Contributed by: Mitch Thompson + +using Spine.Unity; +using System.Collections; +using UnityEngine; + +namespace Spine.Unity.Examples { + public class FootSoldierExample : MonoBehaviour { + [SpineAnimation("Idle")] + public string idleAnimation; + + [SpineAnimation] + public string attackAnimation; + + [SpineAnimation] + public string moveAnimation; + + [SpineSlot] + public string eyesSlot; + + [SpineAttachment(currentSkinOnly: true, slotField: "eyesSlot")] + public string eyesOpenAttachment; + + [SpineAttachment(currentSkinOnly: true, slotField: "eyesSlot")] + public string blinkAttachment; + + [Range(0, 0.2f)] + public float blinkDuration = 0.05f; + + public KeyCode attackKey = KeyCode.Mouse0; + public KeyCode rightKey = KeyCode.D; + public KeyCode leftKey = KeyCode.A; + + public float moveSpeed = 3; + + SkeletonAnimation skeletonAnimation; + + void Awake () { + skeletonAnimation = GetComponent(); + skeletonAnimation.OnRebuild += Apply; + } + + void Apply (SkeletonRenderer skeletonRenderer) { + StartCoroutine(Blink()); + } + + void Update () { + if (Input.GetKey(attackKey)) { + skeletonAnimation.AnimationName = attackAnimation; + } else { + if (Input.GetKey(rightKey)) { + skeletonAnimation.AnimationName = moveAnimation; + skeletonAnimation.Skeleton.ScaleX = 1; + transform.Translate(moveSpeed * Time.deltaTime, 0, 0); + } else if (Input.GetKey(leftKey)) { + skeletonAnimation.AnimationName = moveAnimation; + skeletonAnimation.Skeleton.ScaleX = -1; + transform.Translate(-moveSpeed * Time.deltaTime, 0, 0); + } else { + skeletonAnimation.AnimationName = idleAnimation; + } + } + } + + IEnumerator Blink () { + while (true) { + yield return new WaitForSeconds(Random.Range(0.25f, 3f)); + skeletonAnimation.Skeleton.SetAttachment(eyesSlot, blinkAttachment); + yield return new WaitForSeconds(blinkDuration); + skeletonAnimation.Skeleton.SetAttachment(eyesSlot, eyesOpenAttachment); + } + } + } +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/BasicPlatformerController.cs b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/BasicPlatformerController.cs index 846e443ac..e7dc70ab8 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/BasicPlatformerController.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/BasicPlatformerController.cs @@ -1,220 +1,220 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using Spine.Unity; -using UnityEngine; -using UnityEngine.Events; - -namespace Spine.Unity.Examples { - - [RequireComponent(typeof(CharacterController))] - public class BasicPlatformerController : MonoBehaviour { - - public enum CharacterState { - None, - Idle, - Walk, - Run, - Crouch, - Rise, - Fall, - Attack - } - - [Header("Components")] - public CharacterController controller; - - [Header("Controls")] - public string XAxis = "Horizontal"; - public string YAxis = "Vertical"; - public string JumpButton = "Jump"; - - [Header("Moving")] - public float walkSpeed = 1.5f; - public float runSpeed = 7f; - public float gravityScale = 6.6f; - - [Header("Jumping")] - public float jumpSpeed = 25; - public float minimumJumpDuration = 0.5f; - public float jumpInterruptFactor = 0.5f; - public float forceCrouchVelocity = 25; - public float forceCrouchDuration = 0.5f; - - [Header("Animation")] - public SkeletonAnimationHandleExample animationHandle; - - // Events - public event UnityAction OnJump, OnLand, OnHardLand; - - Vector2 input = default(Vector2); - Vector3 velocity = default(Vector3); - float minimumJumpEndTime = 0; - float forceCrouchEndTime; - bool wasGrounded = false; - - CharacterState previousState, currentState; - - void Update () { - float dt = Time.deltaTime; - bool isGrounded = controller.isGrounded; - bool landed = !wasGrounded && isGrounded; - - // Dummy input. - input.x = Input.GetAxis(XAxis); - input.y = Input.GetAxis(YAxis); - bool inputJumpStop = Input.GetButtonUp(JumpButton); - bool inputJumpStart = Input.GetButtonDown(JumpButton); - bool doCrouch = (isGrounded && input.y < -0.5f) || (forceCrouchEndTime > Time.time); - bool doJumpInterrupt = false; - bool doJump = false; - bool hardLand = false; - - if (landed) { - if (-velocity.y > forceCrouchVelocity) { - hardLand = true; - doCrouch = true; - forceCrouchEndTime = Time.time + forceCrouchDuration; - } - } - - if (!doCrouch) { - if (isGrounded) { - if (inputJumpStart) { - doJump = true; - } - } else { - doJumpInterrupt = inputJumpStop && Time.time < minimumJumpEndTime; - } - } - - // Dummy physics and controller using UnityEngine.CharacterController. - Vector3 gravityDeltaVelocity = Physics.gravity * gravityScale * dt; - - if (doJump) { - velocity.y = jumpSpeed; - minimumJumpEndTime = Time.time + minimumJumpDuration; - } else if (doJumpInterrupt) { - if (velocity.y > 0) - velocity.y *= jumpInterruptFactor; - } - - velocity.x = 0; - if (!doCrouch) { - if (input.x != 0) { - velocity.x = Mathf.Abs(input.x) > 0.6f ? runSpeed : walkSpeed; - velocity.x *= Mathf.Sign(input.x); - } - } - - - if (!isGrounded) { - if (wasGrounded) { - if (velocity.y < 0) - velocity.y = 0; - } else { - velocity += gravityDeltaVelocity; - } - } - controller.Move(velocity * dt); - wasGrounded = isGrounded; - - // Determine and store character state - if (isGrounded) { - if (doCrouch) { - currentState = CharacterState.Crouch; - } else { - if (input.x == 0) - currentState = CharacterState.Idle; - else - currentState = Mathf.Abs(input.x) > 0.6f ? CharacterState.Run : CharacterState.Walk; - } - } else { - currentState = velocity.y > 0 ? CharacterState.Rise : CharacterState.Fall; - } - - bool stateChanged = previousState != currentState; - previousState = currentState; - - // Animation - // Do not modify character parameters or state in this phase. Just read them. - // Detect changes in state, and communicate with animation handle if it changes. - if (stateChanged) - HandleStateChanged(); - - if (input.x != 0) - animationHandle.SetFlip(input.x); - - // Fire events. - if (doJump) { - OnJump.Invoke(); - } - if (landed) { - if (hardLand) { - OnHardLand.Invoke(); - } else { - OnLand.Invoke(); - } - } - } - - void HandleStateChanged () { - // When the state changes, notify the animation handle of the new state. - string stateName = null; - switch (currentState) { - case CharacterState.Idle: - stateName = "idle"; - break; - case CharacterState.Walk: - stateName = "walk"; - break; - case CharacterState.Run: - stateName = "run"; - break; - case CharacterState.Crouch: - stateName = "crouch"; - break; - case CharacterState.Rise: - stateName = "rise"; - break; - case CharacterState.Fall: - stateName = "fall"; - break; - case CharacterState.Attack: - stateName = "attack"; - break; - default: - break; - } - - animationHandle.PlayAnimationForState(stateName, 0); - } - - } -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using Spine.Unity; +using UnityEngine; +using UnityEngine.Events; + +namespace Spine.Unity.Examples { + + [RequireComponent(typeof(CharacterController))] + public class BasicPlatformerController : MonoBehaviour { + + public enum CharacterState { + None, + Idle, + Walk, + Run, + Crouch, + Rise, + Fall, + Attack + } + + [Header("Components")] + public CharacterController controller; + + [Header("Controls")] + public string XAxis = "Horizontal"; + public string YAxis = "Vertical"; + public string JumpButton = "Jump"; + + [Header("Moving")] + public float walkSpeed = 1.5f; + public float runSpeed = 7f; + public float gravityScale = 6.6f; + + [Header("Jumping")] + public float jumpSpeed = 25; + public float minimumJumpDuration = 0.5f; + public float jumpInterruptFactor = 0.5f; + public float forceCrouchVelocity = 25; + public float forceCrouchDuration = 0.5f; + + [Header("Animation")] + public SkeletonAnimationHandleExample animationHandle; + + // Events + public event UnityAction OnJump, OnLand, OnHardLand; + + Vector2 input = default(Vector2); + Vector3 velocity = default(Vector3); + float minimumJumpEndTime = 0; + float forceCrouchEndTime; + bool wasGrounded = false; + + CharacterState previousState, currentState; + + void Update () { + float dt = Time.deltaTime; + bool isGrounded = controller.isGrounded; + bool landed = !wasGrounded && isGrounded; + + // Dummy input. + input.x = Input.GetAxis(XAxis); + input.y = Input.GetAxis(YAxis); + bool inputJumpStop = Input.GetButtonUp(JumpButton); + bool inputJumpStart = Input.GetButtonDown(JumpButton); + bool doCrouch = (isGrounded && input.y < -0.5f) || (forceCrouchEndTime > Time.time); + bool doJumpInterrupt = false; + bool doJump = false; + bool hardLand = false; + + if (landed) { + if (-velocity.y > forceCrouchVelocity) { + hardLand = true; + doCrouch = true; + forceCrouchEndTime = Time.time + forceCrouchDuration; + } + } + + if (!doCrouch) { + if (isGrounded) { + if (inputJumpStart) { + doJump = true; + } + } else { + doJumpInterrupt = inputJumpStop && Time.time < minimumJumpEndTime; + } + } + + // Dummy physics and controller using UnityEngine.CharacterController. + Vector3 gravityDeltaVelocity = Physics.gravity * gravityScale * dt; + + if (doJump) { + velocity.y = jumpSpeed; + minimumJumpEndTime = Time.time + minimumJumpDuration; + } else if (doJumpInterrupt) { + if (velocity.y > 0) + velocity.y *= jumpInterruptFactor; + } + + velocity.x = 0; + if (!doCrouch) { + if (input.x != 0) { + velocity.x = Mathf.Abs(input.x) > 0.6f ? runSpeed : walkSpeed; + velocity.x *= Mathf.Sign(input.x); + } + } + + + if (!isGrounded) { + if (wasGrounded) { + if (velocity.y < 0) + velocity.y = 0; + } else { + velocity += gravityDeltaVelocity; + } + } + controller.Move(velocity * dt); + wasGrounded = isGrounded; + + // Determine and store character state + if (isGrounded) { + if (doCrouch) { + currentState = CharacterState.Crouch; + } else { + if (input.x == 0) + currentState = CharacterState.Idle; + else + currentState = Mathf.Abs(input.x) > 0.6f ? CharacterState.Run : CharacterState.Walk; + } + } else { + currentState = velocity.y > 0 ? CharacterState.Rise : CharacterState.Fall; + } + + bool stateChanged = previousState != currentState; + previousState = currentState; + + // Animation + // Do not modify character parameters or state in this phase. Just read them. + // Detect changes in state, and communicate with animation handle if it changes. + if (stateChanged) + HandleStateChanged(); + + if (input.x != 0) + animationHandle.SetFlip(input.x); + + // Fire events. + if (doJump) { + OnJump.Invoke(); + } + if (landed) { + if (hardLand) { + OnHardLand.Invoke(); + } else { + OnLand.Invoke(); + } + } + } + + void HandleStateChanged () { + // When the state changes, notify the animation handle of the new state. + string stateName = null; + switch (currentState) { + case CharacterState.Idle: + stateName = "idle"; + break; + case CharacterState.Walk: + stateName = "walk"; + break; + case CharacterState.Run: + stateName = "run"; + break; + case CharacterState.Crouch: + stateName = "crouch"; + break; + case CharacterState.Rise: + stateName = "rise"; + break; + case CharacterState.Fall: + stateName = "fall"; + break; + case CharacterState.Attack: + stateName = "attack"; + break; + default: + break; + } + + animationHandle.PlayAnimationForState(stateName, 0); + } + + } +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/ConstrainedCamera.cs b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/ConstrainedCamera.cs index 5590a1976..315600de0 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/ConstrainedCamera.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/ConstrainedCamera.cs @@ -1,52 +1,52 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -// Contributed by: Mitch Thompson - -using UnityEngine; - -namespace Spine.Unity.Examples { - public class ConstrainedCamera : MonoBehaviour { - public Transform target; - public Vector3 offset; - public Vector3 min; - public Vector3 max; - public float smoothing = 5f; - - // Update is called once per frame - void LateUpdate () { - Vector3 goalPoint = target.position + offset; - goalPoint.x = Mathf.Clamp(goalPoint.x, min.x, max.x); - goalPoint.y = Mathf.Clamp(goalPoint.y, min.y, max.y); - goalPoint.z = Mathf.Clamp(goalPoint.z, min.z, max.z); - - transform.position = Vector3.Lerp(transform.position, goalPoint, smoothing * Time.deltaTime); - } - } -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +// Contributed by: Mitch Thompson + +using UnityEngine; + +namespace Spine.Unity.Examples { + public class ConstrainedCamera : MonoBehaviour { + public Transform target; + public Vector3 offset; + public Vector3 min; + public Vector3 max; + public float smoothing = 5f; + + // Update is called once per frame + void LateUpdate () { + Vector3 goalPoint = target.position + offset; + goalPoint.x = Mathf.Clamp(goalPoint.x, min.x, max.x); + goalPoint.y = Mathf.Clamp(goalPoint.y, min.y, max.y); + goalPoint.z = Mathf.Clamp(goalPoint.z, min.z, max.z); + + transform.position = Vector3.Lerp(transform.position, goalPoint, smoothing * Time.deltaTime); + } + } +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/Raptor.cs b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/Raptor.cs index 6c3a0ce86..643040ed1 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/Raptor.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/Raptor.cs @@ -1,66 +1,66 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using Spine.Unity; -using System.Collections; -using UnityEngine; - -namespace Spine.Unity.Examples { - public class Raptor : MonoBehaviour { - - #region Inspector - public AnimationReferenceAsset walk; - public AnimationReferenceAsset gungrab; - public AnimationReferenceAsset gunkeep; - #endregion - - SkeletonAnimation skeletonAnimation; - - void Start () { - skeletonAnimation = GetComponent(); - StartCoroutine(GunGrabRoutine()); - } - - IEnumerator GunGrabRoutine () { - // Play the walk animation on track 0. - skeletonAnimation.AnimationState.SetAnimation(0, walk, true); - - // Repeatedly play the gungrab and gunkeep animation on track 1. - while (true) { - yield return new WaitForSeconds(Random.Range(0.5f, 3f)); - skeletonAnimation.AnimationState.SetAnimation(1, gungrab, false); - - yield return new WaitForSeconds(Random.Range(0.5f, 3f)); - skeletonAnimation.AnimationState.SetAnimation(1, gunkeep, false); - } - - } - - } -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using Spine.Unity; +using System.Collections; +using UnityEngine; + +namespace Spine.Unity.Examples { + public class Raptor : MonoBehaviour { + + #region Inspector + public AnimationReferenceAsset walk; + public AnimationReferenceAsset gungrab; + public AnimationReferenceAsset gunkeep; + #endregion + + SkeletonAnimation skeletonAnimation; + + void Start () { + skeletonAnimation = GetComponent(); + StartCoroutine(GunGrabRoutine()); + } + + IEnumerator GunGrabRoutine () { + // Play the walk animation on track 0. + skeletonAnimation.AnimationState.SetAnimation(0, walk, true); + + // Repeatedly play the gungrab and gunkeep animation on track 1. + while (true) { + yield return new WaitForSeconds(Random.Range(0.5f, 3f)); + skeletonAnimation.AnimationState.SetAnimation(1, gungrab, false); + + yield return new WaitForSeconds(Random.Range(0.5f, 3f)); + skeletonAnimation.AnimationState.SetAnimation(1, gunkeep, false); + } + + } + + } +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineBeginnerTwo.cs b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineBeginnerTwo.cs index 388979b4d..35e7eff95 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineBeginnerTwo.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineBeginnerTwo.cs @@ -1,109 +1,109 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using Spine.Unity; -using System.Collections; -using UnityEngine; - -namespace Spine.Unity.Examples { - public class SpineBeginnerTwo : MonoBehaviour { - - #region Inspector - // [SpineAnimation] attribute allows an Inspector dropdown of Spine animation names coming form SkeletonAnimation. - [SpineAnimation] - public string runAnimationName; - - [SpineAnimation] - public string idleAnimationName; - - [SpineAnimation] - public string walkAnimationName; - - [SpineAnimation] - public string shootAnimationName; - - [Header("Transitions")] - [SpineAnimation] - public string idleTurnAnimationName; - - [SpineAnimation] - public string runToIdleAnimationName; - - public float runWalkDuration = 1.5f; - #endregion - - SkeletonAnimation skeletonAnimation; - - // Spine.AnimationState and Spine.Skeleton are not Unity-serialized objects. You will not see them as fields in the inspector. - public Spine.AnimationState spineAnimationState; - public Spine.Skeleton skeleton; - - void Start () { - // Make sure you get these AnimationState and Skeleton references in Start or Later. - // Getting and using them in Awake is not guaranteed by default execution order. - skeletonAnimation = GetComponent(); - spineAnimationState = skeletonAnimation.AnimationState; - skeleton = skeletonAnimation.Skeleton; - - StartCoroutine(DoDemoRoutine()); - } - - /// This is an infinitely repeating Unity Coroutine. Read the Unity documentation on Coroutines to learn more. - IEnumerator DoDemoRoutine () { - while (true) { - // SetAnimation is the basic way to set an animation. - // SetAnimation sets the animation and starts playing it from the beginning. - // Common Mistake: If you keep calling it in Update, it will keep showing the first pose of the animation, do don't do that. - - spineAnimationState.SetAnimation(0, walkAnimationName, true); - yield return new WaitForSeconds(runWalkDuration); - - spineAnimationState.SetAnimation(0, runAnimationName, true); - yield return new WaitForSeconds(runWalkDuration); - - // AddAnimation queues up an animation to play after the previous one ends. - spineAnimationState.SetAnimation(0, runToIdleAnimationName, false); - spineAnimationState.AddAnimation(0, idleAnimationName, true, 0); - yield return new WaitForSeconds(1f); - - skeleton.ScaleX = -1; // skeleton allows you to flip the skeleton. - spineAnimationState.SetAnimation(0, idleTurnAnimationName, false); - spineAnimationState.AddAnimation(0, idleAnimationName, true, 0); - yield return new WaitForSeconds(0.5f); - skeleton.ScaleX = 1; - spineAnimationState.SetAnimation(0, idleTurnAnimationName, false); - spineAnimationState.AddAnimation(0, idleAnimationName, true, 0); - yield return new WaitForSeconds(0.5f); - - } - } - - } - -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using Spine.Unity; +using System.Collections; +using UnityEngine; + +namespace Spine.Unity.Examples { + public class SpineBeginnerTwo : MonoBehaviour { + + #region Inspector + // [SpineAnimation] attribute allows an Inspector dropdown of Spine animation names coming form SkeletonAnimation. + [SpineAnimation] + public string runAnimationName; + + [SpineAnimation] + public string idleAnimationName; + + [SpineAnimation] + public string walkAnimationName; + + [SpineAnimation] + public string shootAnimationName; + + [Header("Transitions")] + [SpineAnimation] + public string idleTurnAnimationName; + + [SpineAnimation] + public string runToIdleAnimationName; + + public float runWalkDuration = 1.5f; + #endregion + + SkeletonAnimation skeletonAnimation; + + // Spine.AnimationState and Spine.Skeleton are not Unity-serialized objects. You will not see them as fields in the inspector. + public Spine.AnimationState spineAnimationState; + public Spine.Skeleton skeleton; + + void Start () { + // Make sure you get these AnimationState and Skeleton references in Start or Later. + // Getting and using them in Awake is not guaranteed by default execution order. + skeletonAnimation = GetComponent(); + spineAnimationState = skeletonAnimation.AnimationState; + skeleton = skeletonAnimation.Skeleton; + + StartCoroutine(DoDemoRoutine()); + } + + /// This is an infinitely repeating Unity Coroutine. Read the Unity documentation on Coroutines to learn more. + IEnumerator DoDemoRoutine () { + while (true) { + // SetAnimation is the basic way to set an animation. + // SetAnimation sets the animation and starts playing it from the beginning. + // Common Mistake: If you keep calling it in Update, it will keep showing the first pose of the animation, do don't do that. + + spineAnimationState.SetAnimation(0, walkAnimationName, true); + yield return new WaitForSeconds(runWalkDuration); + + spineAnimationState.SetAnimation(0, runAnimationName, true); + yield return new WaitForSeconds(runWalkDuration); + + // AddAnimation queues up an animation to play after the previous one ends. + spineAnimationState.SetAnimation(0, runToIdleAnimationName, false); + spineAnimationState.AddAnimation(0, idleAnimationName, true, 0); + yield return new WaitForSeconds(1f); + + skeleton.ScaleX = -1; // skeleton allows you to flip the skeleton. + spineAnimationState.SetAnimation(0, idleTurnAnimationName, false); + spineAnimationState.AddAnimation(0, idleAnimationName, true, 0); + yield return new WaitForSeconds(0.5f); + skeleton.ScaleX = 1; + spineAnimationState.SetAnimation(0, idleTurnAnimationName, false); + spineAnimationState.AddAnimation(0, idleAnimationName, true, 0); + yield return new WaitForSeconds(0.5f); + + } + } + + } + +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineBlinkPlayer.cs b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineBlinkPlayer.cs index 93ec7dd6d..47a2a876c 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineBlinkPlayer.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineBlinkPlayer.cs @@ -1,52 +1,52 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using Spine.Unity; -using System.Collections; -using UnityEngine; - -namespace Spine.Unity.Examples { - public class SpineBlinkPlayer : MonoBehaviour { - const int BlinkTrack = 1; - - public AnimationReferenceAsset blinkAnimation; - public float minimumDelay = 0.15f; - public float maximumDelay = 3f; - - IEnumerator Start () { - SkeletonAnimation skeletonAnimation = GetComponent(); - if (skeletonAnimation == null) yield break; - while (true) { - skeletonAnimation.AnimationState.SetAnimation(SpineBlinkPlayer.BlinkTrack, blinkAnimation, false); - yield return new WaitForSeconds(Random.Range(minimumDelay, maximumDelay)); - } - } - - } -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using Spine.Unity; +using System.Collections; +using UnityEngine; + +namespace Spine.Unity.Examples { + public class SpineBlinkPlayer : MonoBehaviour { + const int BlinkTrack = 1; + + public AnimationReferenceAsset blinkAnimation; + public float minimumDelay = 0.15f; + public float maximumDelay = 3f; + + IEnumerator Start () { + SkeletonAnimation skeletonAnimation = GetComponent(); + if (skeletonAnimation == null) yield break; + while (true) { + skeletonAnimation.AnimationState.SetAnimation(SpineBlinkPlayer.BlinkTrack, blinkAnimation, false); + yield return new WaitForSeconds(Random.Range(minimumDelay, maximumDelay)); + } + } + + } +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerInput.cs b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerInput.cs index 55d8db026..f79a635cb 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerInput.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerInput.cs @@ -1,68 +1,68 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using System.Collections; -using UnityEngine; - -namespace Spine.Unity.Examples { - public class SpineboyBeginnerInput : MonoBehaviour { - #region Inspector - public string horizontalAxis = "Horizontal"; - public string attackButton = "Fire1"; - public string aimButton = "Fire2"; - public string jumpButton = "Jump"; - - public SpineboyBeginnerModel model; - - void OnValidate () { - if (model == null) - model = GetComponent(); - } - #endregion - - void Update () { - if (model == null) return; - - float currentHorizontal = Input.GetAxisRaw(horizontalAxis); - model.TryMove(currentHorizontal); - - if (Input.GetButton(attackButton)) - model.TryShoot(); - - if (Input.GetButtonDown(aimButton)) - model.StartAim(); - if (Input.GetButtonUp(aimButton)) - model.StopAim(); - - if (Input.GetButtonDown(jumpButton)) - model.TryJump(); - } - } - -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using System.Collections; +using UnityEngine; + +namespace Spine.Unity.Examples { + public class SpineboyBeginnerInput : MonoBehaviour { + #region Inspector + public string horizontalAxis = "Horizontal"; + public string attackButton = "Fire1"; + public string aimButton = "Fire2"; + public string jumpButton = "Jump"; + + public SpineboyBeginnerModel model; + + void OnValidate () { + if (model == null) + model = GetComponent(); + } + #endregion + + void Update () { + if (model == null) return; + + float currentHorizontal = Input.GetAxisRaw(horizontalAxis); + model.TryMove(currentHorizontal); + + if (Input.GetButton(attackButton)) + model.TryShoot(); + + if (Input.GetButtonDown(aimButton)) + model.StartAim(); + if (Input.GetButtonUp(aimButton)) + model.StopAim(); + + if (Input.GetButtonDown(jumpButton)) + model.TryJump(); + } + } + +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerModel.cs b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerModel.cs index f50ae5107..1ae691094 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerModel.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerModel.cs @@ -1,124 +1,124 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using System.Collections; -using UnityEngine; - -namespace Spine.Unity.Examples { - [SelectionBase] - public class SpineboyBeginnerModel : MonoBehaviour { - - #region Inspector - [Header("Current State")] - public SpineBeginnerBodyState state; - public bool facingLeft; - [Range(-1f, 1f)] - public float currentSpeed; - - [Header("Balance")] - public float shootInterval = 0.12f; - #endregion - - float lastShootTime; - public event System.Action ShootEvent; // Lets other scripts know when Spineboy is shooting. Check C# Documentation to learn more about events and delegates. - public event System.Action StartAimEvent; // Lets other scripts know when Spineboy is aiming. - public event System.Action StopAimEvent; // Lets other scripts know when Spineboy is no longer aiming. - - #region API - public void TryJump () { - StartCoroutine(JumpRoutine()); - } - - public void TryShoot () { - float currentTime = Time.time; - - if (currentTime - lastShootTime > shootInterval) { - lastShootTime = currentTime; - if (ShootEvent != null) ShootEvent(); // Fire the "ShootEvent" event. - } - } - - public void StartAim () { - if (StartAimEvent != null) StartAimEvent(); // Fire the "StartAimEvent" event. - } - - public void StopAim () { - if (StopAimEvent != null) StopAimEvent(); // Fire the "StopAimEvent" event. - } - - public void TryMove (float speed) { - currentSpeed = speed; // show the "speed" in the Inspector. - - if (speed != 0) { - bool speedIsNegative = (speed < 0f); - facingLeft = speedIsNegative; // Change facing direction whenever speed is not 0. - } - - if (state != SpineBeginnerBodyState.Jumping) { - state = (speed == 0) ? SpineBeginnerBodyState.Idle : SpineBeginnerBodyState.Running; - } - - } - #endregion - - IEnumerator JumpRoutine () { - if (state == SpineBeginnerBodyState.Jumping) yield break; // Don't jump when already jumping. - - state = SpineBeginnerBodyState.Jumping; - - // Fake jumping. - { - Vector3 pos = transform.localPosition; - const float jumpTime = 1.2f; - const float half = jumpTime * 0.5f; - const float jumpPower = 20f; - for (float t = 0; t < half; t += Time.deltaTime) { - float d = jumpPower * (half - t); - transform.Translate((d * Time.deltaTime) * Vector3.up); - yield return null; - } - for (float t = 0; t < half; t += Time.deltaTime) { - float d = jumpPower * t; - transform.Translate((d * Time.deltaTime) * Vector3.down); - yield return null; - } - transform.localPosition = pos; - } - - state = SpineBeginnerBodyState.Idle; - } - - } - - public enum SpineBeginnerBodyState { - Idle, - Running, - Jumping - } -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using System.Collections; +using UnityEngine; + +namespace Spine.Unity.Examples { + [SelectionBase] + public class SpineboyBeginnerModel : MonoBehaviour { + + #region Inspector + [Header("Current State")] + public SpineBeginnerBodyState state; + public bool facingLeft; + [Range(-1f, 1f)] + public float currentSpeed; + + [Header("Balance")] + public float shootInterval = 0.12f; + #endregion + + float lastShootTime; + public event System.Action ShootEvent; // Lets other scripts know when Spineboy is shooting. Check C# Documentation to learn more about events and delegates. + public event System.Action StartAimEvent; // Lets other scripts know when Spineboy is aiming. + public event System.Action StopAimEvent; // Lets other scripts know when Spineboy is no longer aiming. + + #region API + public void TryJump () { + StartCoroutine(JumpRoutine()); + } + + public void TryShoot () { + float currentTime = Time.time; + + if (currentTime - lastShootTime > shootInterval) { + lastShootTime = currentTime; + if (ShootEvent != null) ShootEvent(); // Fire the "ShootEvent" event. + } + } + + public void StartAim () { + if (StartAimEvent != null) StartAimEvent(); // Fire the "StartAimEvent" event. + } + + public void StopAim () { + if (StopAimEvent != null) StopAimEvent(); // Fire the "StopAimEvent" event. + } + + public void TryMove (float speed) { + currentSpeed = speed; // show the "speed" in the Inspector. + + if (speed != 0) { + bool speedIsNegative = (speed < 0f); + facingLeft = speedIsNegative; // Change facing direction whenever speed is not 0. + } + + if (state != SpineBeginnerBodyState.Jumping) { + state = (speed == 0) ? SpineBeginnerBodyState.Idle : SpineBeginnerBodyState.Running; + } + + } + #endregion + + IEnumerator JumpRoutine () { + if (state == SpineBeginnerBodyState.Jumping) yield break; // Don't jump when already jumping. + + state = SpineBeginnerBodyState.Jumping; + + // Fake jumping. + { + Vector3 pos = transform.localPosition; + const float jumpTime = 1.2f; + const float half = jumpTime * 0.5f; + const float jumpPower = 20f; + for (float t = 0; t < half; t += Time.deltaTime) { + float d = jumpPower * (half - t); + transform.Translate((d * Time.deltaTime) * Vector3.up); + yield return null; + } + for (float t = 0; t < half; t += Time.deltaTime) { + float d = jumpPower * t; + transform.Translate((d * Time.deltaTime) * Vector3.down); + yield return null; + } + transform.localPosition = pos; + } + + state = SpineBeginnerBodyState.Idle; + } + + } + + public enum SpineBeginnerBodyState { + Idle, + Running, + Jumping + } +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerView.cs b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerView.cs index 486d5850b..f37b0e3ea 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerView.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerView.cs @@ -1,167 +1,167 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using Spine.Unity; -using System.Collections; -using UnityEngine; - -namespace Spine.Unity.Examples { - public class SpineboyBeginnerView : MonoBehaviour { - - #region Inspector - [Header("Components")] - public SpineboyBeginnerModel model; - public SkeletonAnimation skeletonAnimation; - - public AnimationReferenceAsset run, idle, aim, shoot, jump; - public EventDataReferenceAsset footstepEvent; - - [Header("Audio")] - public float footstepPitchOffset = 0.2f; - public float gunsoundPitchOffset = 0.13f; - public AudioSource footstepSource, gunSource, jumpSource; - - [Header("Effects")] - public ParticleSystem gunParticles; - #endregion - - SpineBeginnerBodyState previousViewState; - - void Start () { - if (skeletonAnimation == null) return; - model.ShootEvent += PlayShoot; - model.StartAimEvent += StartPlayingAim; - model.StopAimEvent += StopPlayingAim; - skeletonAnimation.AnimationState.Event += HandleEvent; - } - - void HandleEvent (Spine.TrackEntry trackEntry, Spine.Event e) { - if (e.Data == footstepEvent.EventData) - PlayFootstepSound(); - } - - void Update () { - if (skeletonAnimation == null) return; - if (model == null) return; - - if ((skeletonAnimation.skeleton.ScaleX < 0) != model.facingLeft) { // Detect changes in model.facingLeft - Turn(model.facingLeft); - } - - // Detect changes in model.state - SpineBeginnerBodyState currentModelState = model.state; - - if (previousViewState != currentModelState) { - PlayNewStableAnimation(); - } - - previousViewState = currentModelState; - } - - void PlayNewStableAnimation () { - SpineBeginnerBodyState newModelState = model.state; - Animation nextAnimation; - - // Add conditionals to not interrupt transient animations. - - if (previousViewState == SpineBeginnerBodyState.Jumping && newModelState != SpineBeginnerBodyState.Jumping) { - PlayFootstepSound(); - } - - if (newModelState == SpineBeginnerBodyState.Jumping) { - jumpSource.Play(); - nextAnimation = jump; - } else { - if (newModelState == SpineBeginnerBodyState.Running) { - nextAnimation = run; - } else { - nextAnimation = idle; - } - } - - skeletonAnimation.AnimationState.SetAnimation(0, nextAnimation, true); - } - - void PlayFootstepSound () { - footstepSource.Play(); - footstepSource.pitch = GetRandomPitch(footstepPitchOffset); - } - - [ContextMenu("Check Tracks")] - void CheckTracks () { - AnimationState state = skeletonAnimation.AnimationState; - Debug.Log(state.GetCurrent(0)); - Debug.Log(state.GetCurrent(1)); - } - - #region Transient Actions - public void PlayShoot () { - // Play the shoot animation on track 1. - TrackEntry shootTrack = skeletonAnimation.AnimationState.SetAnimation(1, shoot, false); - shootTrack.AttachmentThreshold = 1f; - shootTrack.MixDuration = 0f; - skeletonAnimation.state.AddEmptyAnimation(1, 0.5f, 0.1f); - - // Play the aim animation on track 2 to aim at the mouse target. - TrackEntry aimTrack = skeletonAnimation.AnimationState.SetAnimation(2, aim, false); - aimTrack.AttachmentThreshold = 1f; - aimTrack.MixDuration = 0f; - skeletonAnimation.state.AddEmptyAnimation(2, 0.5f, 0.1f); - - gunSource.pitch = GetRandomPitch(gunsoundPitchOffset); - gunSource.Play(); - //gunParticles.randomSeed = (uint)Random.Range(0, 100); - gunParticles.Play(); - } - - public void StartPlayingAim () { - // Play the aim animation on track 2 to aim at the mouse target. - TrackEntry aimTrack = skeletonAnimation.AnimationState.SetAnimation(2, aim, true); - aimTrack.AttachmentThreshold = 1f; - aimTrack.MixDuration = 0f; - } - - public void StopPlayingAim () { - skeletonAnimation.state.AddEmptyAnimation(2, 0.5f, 0.1f); - } - - public void Turn (bool facingLeft) { - skeletonAnimation.Skeleton.ScaleX = facingLeft ? -1f : 1f; - // Maybe play a transient turning animation too, then call ChangeStableAnimation. - } - #endregion - - #region Utility - public float GetRandomPitch (float maxPitchOffset) { - return 1f + Random.Range(-maxPitchOffset, maxPitchOffset); - } - #endregion - } - -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using Spine.Unity; +using System.Collections; +using UnityEngine; + +namespace Spine.Unity.Examples { + public class SpineboyBeginnerView : MonoBehaviour { + + #region Inspector + [Header("Components")] + public SpineboyBeginnerModel model; + public SkeletonAnimation skeletonAnimation; + + public AnimationReferenceAsset run, idle, aim, shoot, jump; + public EventDataReferenceAsset footstepEvent; + + [Header("Audio")] + public float footstepPitchOffset = 0.2f; + public float gunsoundPitchOffset = 0.13f; + public AudioSource footstepSource, gunSource, jumpSource; + + [Header("Effects")] + public ParticleSystem gunParticles; + #endregion + + SpineBeginnerBodyState previousViewState; + + void Start () { + if (skeletonAnimation == null) return; + model.ShootEvent += PlayShoot; + model.StartAimEvent += StartPlayingAim; + model.StopAimEvent += StopPlayingAim; + skeletonAnimation.AnimationState.Event += HandleEvent; + } + + void HandleEvent (Spine.TrackEntry trackEntry, Spine.Event e) { + if (e.Data == footstepEvent.EventData) + PlayFootstepSound(); + } + + void Update () { + if (skeletonAnimation == null) return; + if (model == null) return; + + if ((skeletonAnimation.skeleton.ScaleX < 0) != model.facingLeft) { // Detect changes in model.facingLeft + Turn(model.facingLeft); + } + + // Detect changes in model.state + SpineBeginnerBodyState currentModelState = model.state; + + if (previousViewState != currentModelState) { + PlayNewStableAnimation(); + } + + previousViewState = currentModelState; + } + + void PlayNewStableAnimation () { + SpineBeginnerBodyState newModelState = model.state; + Animation nextAnimation; + + // Add conditionals to not interrupt transient animations. + + if (previousViewState == SpineBeginnerBodyState.Jumping && newModelState != SpineBeginnerBodyState.Jumping) { + PlayFootstepSound(); + } + + if (newModelState == SpineBeginnerBodyState.Jumping) { + jumpSource.Play(); + nextAnimation = jump; + } else { + if (newModelState == SpineBeginnerBodyState.Running) { + nextAnimation = run; + } else { + nextAnimation = idle; + } + } + + skeletonAnimation.AnimationState.SetAnimation(0, nextAnimation, true); + } + + void PlayFootstepSound () { + footstepSource.Play(); + footstepSource.pitch = GetRandomPitch(footstepPitchOffset); + } + + [ContextMenu("Check Tracks")] + void CheckTracks () { + AnimationState state = skeletonAnimation.AnimationState; + Debug.Log(state.GetCurrent(0)); + Debug.Log(state.GetCurrent(1)); + } + + #region Transient Actions + public void PlayShoot () { + // Play the shoot animation on track 1. + TrackEntry shootTrack = skeletonAnimation.AnimationState.SetAnimation(1, shoot, false); + shootTrack.AttachmentThreshold = 1f; + shootTrack.MixDuration = 0f; + skeletonAnimation.state.AddEmptyAnimation(1, 0.5f, 0.1f); + + // Play the aim animation on track 2 to aim at the mouse target. + TrackEntry aimTrack = skeletonAnimation.AnimationState.SetAnimation(2, aim, false); + aimTrack.AttachmentThreshold = 1f; + aimTrack.MixDuration = 0f; + skeletonAnimation.state.AddEmptyAnimation(2, 0.5f, 0.1f); + + gunSource.pitch = GetRandomPitch(gunsoundPitchOffset); + gunSource.Play(); + //gunParticles.randomSeed = (uint)Random.Range(0, 100); + gunParticles.Play(); + } + + public void StartPlayingAim () { + // Play the aim animation on track 2 to aim at the mouse target. + TrackEntry aimTrack = skeletonAnimation.AnimationState.SetAnimation(2, aim, true); + aimTrack.AttachmentThreshold = 1f; + aimTrack.MixDuration = 0f; + } + + public void StopPlayingAim () { + skeletonAnimation.state.AddEmptyAnimation(2, 0.5f, 0.1f); + } + + public void Turn (bool facingLeft) { + skeletonAnimation.Skeleton.ScaleX = facingLeft ? -1f : 1f; + // Maybe play a transient turning animation too, then call ChangeStableAnimation. + } + #endregion + + #region Utility + public float GetRandomPitch (float maxPitchOffset) { + return 1f + Random.Range(-maxPitchOffset, maxPitchOffset); + } + #endregion + } + +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerViewGraphic.cs b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerViewGraphic.cs new file mode 100644 index 000000000..8f89716a4 --- /dev/null +++ b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerViewGraphic.cs @@ -0,0 +1,167 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using Spine.Unity; +using System.Collections; +using UnityEngine; + +namespace Spine.Unity.Examples { + public class SpineboyBeginnerViewGraphic : MonoBehaviour { + + #region Inspector + [Header("Components")] + public SpineboyBeginnerModel model; + public SkeletonGraphic skeletonGraphic; + + public AnimationReferenceAsset run, idle, aim, shoot, jump; + public EventDataReferenceAsset footstepEvent; + + [Header("Audio")] + public float footstepPitchOffset = 0.2f; + public float gunsoundPitchOffset = 0.13f; + public AudioSource footstepSource, gunSource, jumpSource; + + [Header("Effects")] + public ParticleSystem gunParticles; + #endregion + + SpineBeginnerBodyState previousViewState; + + void Start () { + if (skeletonGraphic == null) return; + model.ShootEvent += PlayShoot; + model.StartAimEvent += StartPlayingAim; + model.StopAimEvent += StopPlayingAim; + skeletonGraphic.AnimationState.Event += HandleEvent; + } + + void HandleEvent (Spine.TrackEntry trackEntry, Spine.Event e) { + if (e.Data == footstepEvent.EventData) + PlayFootstepSound(); + } + + void Update () { + if (skeletonGraphic == null) return; + if (model == null) return; + + if ((skeletonGraphic.Skeleton.ScaleX < 0) != model.facingLeft) { // Detect changes in model.facingLeft + Turn(model.facingLeft); + } + + // Detect changes in model.state + SpineBeginnerBodyState currentModelState = model.state; + + if (previousViewState != currentModelState) { + PlayNewStableAnimation(); + } + + previousViewState = currentModelState; + } + + void PlayNewStableAnimation () { + SpineBeginnerBodyState newModelState = model.state; + Animation nextAnimation; + + // Add conditionals to not interrupt transient animations. + + if (previousViewState == SpineBeginnerBodyState.Jumping && newModelState != SpineBeginnerBodyState.Jumping) { + PlayFootstepSound(); + } + + if (newModelState == SpineBeginnerBodyState.Jumping) { + jumpSource.Play(); + nextAnimation = jump; + } else { + if (newModelState == SpineBeginnerBodyState.Running) { + nextAnimation = run; + } else { + nextAnimation = idle; + } + } + + skeletonGraphic.AnimationState.SetAnimation(0, nextAnimation, true); + } + + void PlayFootstepSound () { + footstepSource.Play(); + footstepSource.pitch = GetRandomPitch(footstepPitchOffset); + } + + [ContextMenu("Check Tracks")] + void CheckTracks () { + AnimationState state = skeletonGraphic.AnimationState; + Debug.Log(state.GetCurrent(0)); + Debug.Log(state.GetCurrent(1)); + } + + #region Transient Actions + public void PlayShoot () { + // Play the shoot animation on track 1. + TrackEntry shootTrack = skeletonGraphic.AnimationState.SetAnimation(1, shoot, false); + shootTrack.AttachmentThreshold = 1f; + shootTrack.MixDuration = 0f; + skeletonGraphic.AnimationState.AddEmptyAnimation(1, 0.5f, 0.1f); + + // Play the aim animation on track 2 to aim at the mouse target. + TrackEntry aimTrack = skeletonGraphic.AnimationState.SetAnimation(2, aim, false); + aimTrack.AttachmentThreshold = 1f; + aimTrack.MixDuration = 0f; + skeletonGraphic.AnimationState.AddEmptyAnimation(2, 0.5f, 0.1f); + + gunSource.pitch = GetRandomPitch(gunsoundPitchOffset); + gunSource.Play(); + //gunParticles.randomSeed = (uint)Random.Range(0, 100); + gunParticles.Play(); + } + + public void StartPlayingAim () { + // Play the aim animation on track 2 to aim at the mouse target. + TrackEntry aimTrack = skeletonGraphic.AnimationState.SetAnimation(2, aim, true); + aimTrack.AttachmentThreshold = 1f; + aimTrack.MixDuration = 0f; + } + + public void StopPlayingAim () { + skeletonGraphic.AnimationState.AddEmptyAnimation(2, 0.5f, 0.1f); + } + + public void Turn (bool facingLeft) { + skeletonGraphic.Skeleton.ScaleX = facingLeft ? -1f : 1f; + // Maybe play a transient turning animation too, then call ChangeStableAnimation. + } + #endregion + + #region Utility + public float GetRandomPitch (float maxPitchOffset) { + return 1f + Random.Range(-maxPitchOffset, maxPitchOffset); + } + #endregion + } + +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerViewGraphic.cs.meta b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerViewGraphic.cs.meta new file mode 100644 index 000000000..a5e517ccf --- /dev/null +++ b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyBeginnerViewGraphic.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 795971ea6ab1f214eac09ad8814226e6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs index 45b690b63..8d7ecfdc6 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetController.cs @@ -1,61 +1,61 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using UnityEngine; - -namespace Spine.Unity.Examples { - public class SpineboyTargetController : MonoBehaviour { - - public SkeletonAnimation skeletonAnimation; - - [SpineBone(dataField: "skeletonAnimation")] - public string boneName; - public Camera cam; - - Bone bone; - - void OnValidate () { - if (skeletonAnimation == null) skeletonAnimation = GetComponent(); - } - - void Start () { - bone = skeletonAnimation.Skeleton.FindBone(boneName); - } - - void Update () { - Vector3 mousePosition = Input.mousePosition; - Vector3 worldMousePosition = cam.ScreenToWorldPoint(mousePosition); - Vector3 skeletonSpacePoint = skeletonAnimation.transform.InverseTransformPoint(worldMousePosition); - skeletonSpacePoint.x *= skeletonAnimation.Skeleton.ScaleX; - skeletonSpacePoint.y *= skeletonAnimation.Skeleton.ScaleY; - bone.SetLocalPosition(skeletonSpacePoint); - } - } - -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using UnityEngine; + +namespace Spine.Unity.Examples { + public class SpineboyTargetController : MonoBehaviour { + + public SkeletonAnimation skeletonAnimation; + + [SpineBone(dataField: "skeletonAnimation")] + public string boneName; + public Camera cam; + + Bone bone; + + void OnValidate () { + if (skeletonAnimation == null) skeletonAnimation = GetComponent(); + } + + void Start () { + bone = skeletonAnimation.Skeleton.FindBone(boneName); + } + + void Update () { + Vector3 mousePosition = Input.mousePosition; + Vector3 worldMousePosition = cam.ScreenToWorldPoint(mousePosition); + Vector3 skeletonSpacePoint = skeletonAnimation.transform.InverseTransformPoint(worldMousePosition); + skeletonSpacePoint.x *= skeletonAnimation.Skeleton.ScaleX; + skeletonSpacePoint.y *= skeletonAnimation.Skeleton.ScaleY; + bone.SetLocalPosition(skeletonSpacePoint); + } + } + +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetControllerGraphic.cs b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetControllerGraphic.cs new file mode 100644 index 000000000..f42cba85a --- /dev/null +++ b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetControllerGraphic.cs @@ -0,0 +1,64 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using UnityEngine; + +namespace Spine.Unity.Examples { + public class SpineboyTargetControllerGraphic : MonoBehaviour { + + public SkeletonGraphic skeletonGraphic; + + [SpineBone(dataField: "skeletonGraphic")] + public string boneName; + public Camera cam; + public Canvas canvas; + + Bone bone; + + void OnValidate () { + if (skeletonGraphic == null) skeletonGraphic = GetComponent(); + } + + void Start () { + bone = skeletonGraphic.Skeleton.FindBone(boneName); + } + + void Update () { + Vector3 mousePosition = Input.mousePosition; + Vector2 localRectPosition; + RectTransformUtility.ScreenPointToLocalPointInRectangle( + skeletonGraphic.rectTransform, mousePosition, null, out localRectPosition); + Vector3 skeletonSpacePoint = localRectPosition / skeletonGraphic.MeshScale; + skeletonSpacePoint.x *= skeletonGraphic.Skeleton.ScaleX; + skeletonSpacePoint.y *= skeletonGraphic.Skeleton.ScaleY; + bone.SetLocalPosition(skeletonSpacePoint); + } + } + +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetControllerGraphic.cs.meta b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetControllerGraphic.cs.meta new file mode 100644 index 000000000..eef421123 --- /dev/null +++ b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/SpineboyTargetControllerGraphic.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e58811512f2bea64988af3798e27f1d8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/TransitionDictionaryExample.cs b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/TransitionDictionaryExample.cs index 3e618490b..200bea6a0 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/TransitionDictionaryExample.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/Getting Started Scripts/TransitionDictionaryExample.cs @@ -1,64 +1,64 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace Spine.Unity.Examples { - - // This is an example of how you could store animation transitions for use in your animation system. - // More ideally, this would be stored in a ScriptableObject in asset form rather than in a MonoBehaviour. - public sealed class TransitionDictionaryExample : MonoBehaviour { - - [System.Serializable] - public struct SerializedEntry { - public AnimationReferenceAsset from; - public AnimationReferenceAsset to; - public AnimationReferenceAsset transition; - } - - [SerializeField] - List transitions = new List(); - readonly Dictionary dictionary = new Dictionary(); - - void Start () { - dictionary.Clear(); - foreach (SerializedEntry e in transitions) { - dictionary.Add(new AnimationStateData.AnimationPair(e.from.Animation, e.to.Animation), e.transition.Animation); - } - } - - public Animation GetTransition (Animation from, Animation to) { - Animation result; - dictionary.TryGetValue(new AnimationStateData.AnimationPair(from, to), out result); - return result; - } - } -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Spine.Unity.Examples { + + // This is an example of how you could store animation transitions for use in your animation system. + // More ideally, this would be stored in a ScriptableObject in asset form rather than in a MonoBehaviour. + public sealed class TransitionDictionaryExample : MonoBehaviour { + + [System.Serializable] + public struct SerializedEntry { + public AnimationReferenceAsset from; + public AnimationReferenceAsset to; + public AnimationReferenceAsset transition; + } + + [SerializeField] + List transitions = new List(); + readonly Dictionary dictionary = new Dictionary(); + + void Start () { + dictionary.Clear(); + foreach (SerializedEntry e in transitions) { + dictionary.Add(new AnimationStateData.AnimationPair(e.from.Animation, e.to.Animation), e.transition.Animation); + } + } + + public Animation GetTransition (Animation from, Animation to) { + Animation result; + dictionary.TryGetValue(new AnimationStateData.AnimationPair(from, to), out result); + return result; + } + } +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Goblins.cs b/Assets/ThirdParty/Spine Examples/Scripts/Goblins.cs index 64240e8d8..96448ebfd 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/Goblins.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/Goblins.cs @@ -1,67 +1,67 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using Spine; -using Spine.Unity; -using UnityEngine; - -namespace Spine.Unity.Examples { - public class Goblins : MonoBehaviour { - SkeletonAnimation skeletonAnimation; - Bone headBone; - bool girlSkin; - - [Range(-360, 360)] - public float extraRotation; - - public void Start () { - skeletonAnimation = GetComponent(); - headBone = skeletonAnimation.Skeleton.FindBone("head"); - skeletonAnimation.UpdateLocal += UpdateLocal; - } - - // This is called after the animation is applied to the skeleton and can be used to adjust the bones dynamically. - public void UpdateLocal (ISkeletonAnimation skeletonRenderer) { - headBone.Rotation += extraRotation; - } - - public void OnMouseDown () { - skeletonAnimation.Skeleton.SetSkin(girlSkin ? "goblin" : "goblingirl"); - skeletonAnimation.Skeleton.SetSlotsToSetupPose(); - - girlSkin = !girlSkin; - - if (girlSkin) { - skeletonAnimation.Skeleton.SetAttachment("right-hand-item", null); - skeletonAnimation.Skeleton.SetAttachment("left-hand-item", "spear"); - } else - skeletonAnimation.Skeleton.SetAttachment("left-hand-item", "dagger"); - } - } -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using Spine; +using Spine.Unity; +using UnityEngine; + +namespace Spine.Unity.Examples { + public class Goblins : MonoBehaviour { + SkeletonAnimation skeletonAnimation; + Bone headBone; + bool girlSkin; + + [Range(-360, 360)] + public float extraRotation; + + public void Start () { + skeletonAnimation = GetComponent(); + headBone = skeletonAnimation.Skeleton.FindBone("head"); + skeletonAnimation.UpdateLocal += UpdateLocal; + } + + // This is called after the animation is applied to the skeleton and can be used to adjust the bones dynamically. + public void UpdateLocal (ISkeletonAnimation skeletonRenderer) { + headBone.Rotation += extraRotation; + } + + public void OnMouseDown () { + skeletonAnimation.Skeleton.SetSkin(girlSkin ? "goblin" : "goblingirl"); + skeletonAnimation.Skeleton.SetSlotsToSetupPose(); + + girlSkin = !girlSkin; + + if (girlSkin) { + skeletonAnimation.Skeleton.SetAttachment("right-hand-item", null); + skeletonAnimation.Skeleton.SetAttachment("left-hand-item", "spear"); + } else + skeletonAnimation.Skeleton.SetAttachment("left-hand-item", "dagger"); + } + } +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/HandleEventWithAudioExample.cs b/Assets/ThirdParty/Spine Examples/Scripts/HandleEventWithAudioExample.cs index f90b1f559..26d785e86 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/HandleEventWithAudioExample.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/HandleEventWithAudioExample.cs @@ -1,83 +1,83 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace Spine.Unity.Examples { - public class HandleEventWithAudioExample : MonoBehaviour { - - public SkeletonAnimation skeletonAnimation; - [SpineEvent(dataField: "skeletonAnimation", fallbackToTextField: true)] - public string eventName; - - [Space] - public AudioSource audioSource; - public AudioClip audioClip; - public float basePitch = 1f; - public float randomPitchOffset = 0.1f; - - [Space] - public bool logDebugMessage = false; - - Spine.EventData eventData; - - void OnValidate () { - if (skeletonAnimation == null) GetComponent(); - if (audioSource == null) GetComponent(); - } - - void Start () { - if (audioSource == null) return; - if (skeletonAnimation == null) return; - skeletonAnimation.Initialize(false); - if (!skeletonAnimation.valid) return; - - eventData = skeletonAnimation.Skeleton.Data.FindEvent(eventName); - skeletonAnimation.AnimationState.Event += HandleAnimationStateEvent; - } - - private void HandleAnimationStateEvent (TrackEntry trackEntry, Event e) { - if (logDebugMessage) Debug.Log("Event fired! " + e.Data.Name); - //bool eventMatch = string.Equals(e.Data.Name, eventName, System.StringComparison.Ordinal); // Testing recommendation: String compare. - bool eventMatch = (eventData == e.Data); // Performance recommendation: Match cached reference instead of string. - if (eventMatch) { - Play(); - } - } - - public void Play () { - audioSource.pitch = basePitch + Random.Range(-randomPitchOffset, randomPitchOffset); - audioSource.clip = audioClip; - audioSource.Play(); - } - } - -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Spine.Unity.Examples { + public class HandleEventWithAudioExample : MonoBehaviour { + + public SkeletonAnimation skeletonAnimation; + [SpineEvent(dataField: "skeletonAnimation", fallbackToTextField: true)] + public string eventName; + + [Space] + public AudioSource audioSource; + public AudioClip audioClip; + public float basePitch = 1f; + public float randomPitchOffset = 0.1f; + + [Space] + public bool logDebugMessage = false; + + Spine.EventData eventData; + + void OnValidate () { + if (skeletonAnimation == null) GetComponent(); + if (audioSource == null) GetComponent(); + } + + void Start () { + if (audioSource == null) return; + if (skeletonAnimation == null) return; + skeletonAnimation.Initialize(false); + if (!skeletonAnimation.valid) return; + + eventData = skeletonAnimation.Skeleton.Data.FindEvent(eventName); + skeletonAnimation.AnimationState.Event += HandleAnimationStateEvent; + } + + private void HandleAnimationStateEvent (TrackEntry trackEntry, Event e) { + if (logDebugMessage) Debug.Log("Event fired! " + e.Data.Name); + //bool eventMatch = string.Equals(e.Data.Name, eventName, System.StringComparison.Ordinal); // Testing recommendation: String compare. + bool eventMatch = (eventData == e.Data); // Performance recommendation: Match cached reference instead of string. + if (eventMatch) { + Play(); + } + } + + public void Play () { + audioSource.pitch = basePitch + Random.Range(-randomPitchOffset, randomPitchOffset); + audioSource.clip = audioClip; + audioSource.Play(); + } + } + +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/HeroEffectsHandlerExample.cs b/Assets/ThirdParty/Spine Examples/Scripts/HeroEffectsHandlerExample.cs index 383eb945a..1e5729dec 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/HeroEffectsHandlerExample.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/HeroEffectsHandlerExample.cs @@ -1,47 +1,47 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using UnityEngine; -using UnityEngine.Events; - -namespace Spine.Unity.Examples { - public class HeroEffectsHandlerExample : MonoBehaviour { - public BasicPlatformerController eventSource; - public UnityEvent OnJump, OnLand, OnHardLand; - - public void Awake () { - if (eventSource == null) - return; - - eventSource.OnLand += OnLand.Invoke; - eventSource.OnJump += OnJump.Invoke; - eventSource.OnHardLand += OnHardLand.Invoke; - } - } -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using UnityEngine; +using UnityEngine.Events; + +namespace Spine.Unity.Examples { + public class HeroEffectsHandlerExample : MonoBehaviour { + public BasicPlatformerController eventSource; + public UnityEvent OnJump, OnLand, OnHardLand; + + public void Awake () { + if (eventSource == null) + return; + + eventSource.OnLand += OnLand.Invoke; + eventSource.OnJump += OnJump.Invoke; + eventSource.OnHardLand += OnHardLand.Invoke; + } + } +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/HurtFlashEffect.cs b/Assets/ThirdParty/Spine Examples/Scripts/HurtFlashEffect.cs index 48ad33317..89085e2cc 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/HurtFlashEffect.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/HurtFlashEffect.cs @@ -1,77 +1,77 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class HurtFlashEffect : MonoBehaviour { - - const int DefaultFlashCount = 3; - - public int flashCount = DefaultFlashCount; - public Color flashColor = Color.white; - [Range(1f / 120f, 1f / 15f)] - public float interval = 1f / 60f; - public string fillPhaseProperty = "_FillPhase"; - public string fillColorProperty = "_FillColor"; - - MaterialPropertyBlock mpb; - MeshRenderer meshRenderer; - - public void Flash () { - if (mpb == null) mpb = new MaterialPropertyBlock(); - if (meshRenderer == null) meshRenderer = GetComponent(); - meshRenderer.GetPropertyBlock(mpb); - - StartCoroutine(FlashRoutine()); - } - - IEnumerator FlashRoutine () { - if (flashCount < 0) flashCount = DefaultFlashCount; - int fillPhase = Shader.PropertyToID(fillPhaseProperty); - int fillColor = Shader.PropertyToID(fillColorProperty); - - WaitForSeconds wait = new WaitForSeconds(interval); - - for (int i = 0; i < flashCount; i++) { - mpb.SetColor(fillColor, flashColor); - mpb.SetFloat(fillPhase, 1f); - meshRenderer.SetPropertyBlock(mpb); - yield return wait; - - mpb.SetFloat(fillPhase, 0f); - meshRenderer.SetPropertyBlock(mpb); - yield return wait; - } - - yield return null; - } - -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class HurtFlashEffect : MonoBehaviour { + + const int DefaultFlashCount = 3; + + public int flashCount = DefaultFlashCount; + public Color flashColor = Color.white; + [Range(1f / 120f, 1f / 15f)] + public float interval = 1f / 60f; + public string fillPhaseProperty = "_FillPhase"; + public string fillColorProperty = "_FillColor"; + + MaterialPropertyBlock mpb; + MeshRenderer meshRenderer; + + public void Flash () { + if (mpb == null) mpb = new MaterialPropertyBlock(); + if (meshRenderer == null) meshRenderer = GetComponent(); + meshRenderer.GetPropertyBlock(mpb); + + StartCoroutine(FlashRoutine()); + } + + IEnumerator FlashRoutine () { + if (flashCount < 0) flashCount = DefaultFlashCount; + int fillPhase = Shader.PropertyToID(fillPhaseProperty); + int fillColor = Shader.PropertyToID(fillColorProperty); + + WaitForSeconds wait = new WaitForSeconds(interval); + + for (int i = 0; i < flashCount; i++) { + mpb.SetColor(fillColor, flashColor); + mpb.SetFloat(fillPhase, 1f); + meshRenderer.SetPropertyBlock(mpb); + yield return wait; + + mpb.SetFloat(fillPhase, 0f); + meshRenderer.SetPropertyBlock(mpb); + yield return wait; + } + + yield return null; + } + +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/MaterialPropertyBlockExample.cs b/Assets/ThirdParty/Spine Examples/Scripts/MaterialPropertyBlockExample.cs index c5c6ca3b8..96129f45f 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/MaterialPropertyBlockExample.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/MaterialPropertyBlockExample.cs @@ -1,62 +1,62 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace Spine.Unity.Examples { - public class MaterialPropertyBlockExample : MonoBehaviour { - - public float timeInterval = 1f; - public Gradient randomColors = new Gradient(); - public string colorPropertyName = "_FillColor"; - - MaterialPropertyBlock mpb; - float timeToNextColor = 0; - - void Start () { - mpb = new MaterialPropertyBlock(); - } - - void Update () { - if (timeToNextColor <= 0) { - timeToNextColor = timeInterval; - - Color newColor = randomColors.Evaluate(UnityEngine.Random.value); - mpb.SetColor(colorPropertyName, newColor); - GetComponent().SetPropertyBlock(mpb); - } - - timeToNextColor -= Time.deltaTime; - } - - } - -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Spine.Unity.Examples { + public class MaterialPropertyBlockExample : MonoBehaviour { + + public float timeInterval = 1f; + public Gradient randomColors = new Gradient(); + public string colorPropertyName = "_FillColor"; + + MaterialPropertyBlock mpb; + float timeToNextColor = 0; + + void Start () { + mpb = new MaterialPropertyBlock(); + } + + void Update () { + if (timeToNextColor <= 0) { + timeToNextColor = timeInterval; + + Color newColor = randomColors.Evaluate(UnityEngine.Random.value); + mpb.SetColor(colorPropertyName, newColor); + GetComponent().SetPropertyBlock(mpb); + } + + timeToNextColor -= Time.deltaTime; + } + + } + +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/MaterialReplacementExample.cs b/Assets/ThirdParty/Spine Examples/Scripts/MaterialReplacementExample.cs index 66e54c18f..5bba076ea 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/MaterialReplacementExample.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/MaterialReplacementExample.cs @@ -1,82 +1,82 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace Spine.Unity.Examples { - public class MaterialReplacementExample : MonoBehaviour { - - public Material originalMaterial; - public Material replacementMaterial; - public bool replacementEnabled = true; - public SkeletonAnimation skeletonAnimation; - - [Space] - public string phasePropertyName = "_FillPhase"; - [Range(0f, 1f)] public float phase = 1f; - - bool previousEnabled; - MaterialPropertyBlock mpb; - - void Start () { - // Use the code below to programmatically query the original material. - // Note: using MeshRenderer.material will fail since it creates an instance copy of the Material, - // MeshRenderer.sharedMaterial might also fail when called too early or when no Attachments - // are visible in the initial first frame. - if (originalMaterial == null) - originalMaterial = skeletonAnimation.SkeletonDataAsset.atlasAssets[0].PrimaryMaterial; - - previousEnabled = replacementEnabled; - SetReplacementEnabled(replacementEnabled); - mpb = new MaterialPropertyBlock(); - } - - void Update () { - mpb.SetFloat(phasePropertyName, phase); - GetComponent().SetPropertyBlock(mpb); - - if (previousEnabled != replacementEnabled) - SetReplacementEnabled(replacementEnabled); - - previousEnabled = replacementEnabled; - - } - - void SetReplacementEnabled (bool active) { - if (replacementEnabled) { - skeletonAnimation.CustomMaterialOverride[originalMaterial] = replacementMaterial; - } else { - skeletonAnimation.CustomMaterialOverride.Remove(originalMaterial); - } - } - - } -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Spine.Unity.Examples { + public class MaterialReplacementExample : MonoBehaviour { + + public Material originalMaterial; + public Material replacementMaterial; + public bool replacementEnabled = true; + public SkeletonAnimation skeletonAnimation; + + [Space] + public string phasePropertyName = "_FillPhase"; + [Range(0f, 1f)] public float phase = 1f; + + bool previousEnabled; + MaterialPropertyBlock mpb; + + void Start () { + // Use the code below to programmatically query the original material. + // Note: using MeshRenderer.material will fail since it creates an instance copy of the Material, + // MeshRenderer.sharedMaterial might also fail when called too early or when no Attachments + // are visible in the initial first frame. + if (originalMaterial == null) + originalMaterial = skeletonAnimation.SkeletonDataAsset.atlasAssets[0].PrimaryMaterial; + + previousEnabled = replacementEnabled; + SetReplacementEnabled(replacementEnabled); + mpb = new MaterialPropertyBlock(); + } + + void Update () { + mpb.SetFloat(phasePropertyName, phase); + GetComponent().SetPropertyBlock(mpb); + + if (previousEnabled != replacementEnabled) + SetReplacementEnabled(replacementEnabled); + + previousEnabled = replacementEnabled; + + } + + void SetReplacementEnabled (bool active) { + if (replacementEnabled) { + skeletonAnimation.CustomMaterialOverride[originalMaterial] = replacementMaterial; + } else { + skeletonAnimation.CustomMaterialOverride.Remove(originalMaterial); + } + } + + } +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Mecanim as Logic/DummyMecanimControllerExample.cs b/Assets/ThirdParty/Spine Examples/Scripts/Mecanim as Logic/DummyMecanimControllerExample.cs index 9736a93a2..c1e2c3999 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/Mecanim as Logic/DummyMecanimControllerExample.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/Mecanim as Logic/DummyMecanimControllerExample.cs @@ -1,104 +1,104 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace Spine.Unity.Examples { - public class DummyMecanimControllerExample : MonoBehaviour { - - public Animator logicAnimator; - public SkeletonAnimationHandleExample animationHandle; - - [Header("Controls")] - public KeyCode walkButton = KeyCode.LeftShift; - public KeyCode jumpButton = KeyCode.Space; - - [Header("Animator Properties")] - public string horizontalSpeedProperty = "Speed"; - public string verticalSpeedProperty = "VerticalSpeed"; - public string groundedProperty = "Grounded"; - - [Header("Fake Physics")] - public float jumpDuration = 1.5f; - public Vector2 speed; - public bool isGrounded; - - void Awake () { - isGrounded = true; - } - - void Update () { - float x = Input.GetAxisRaw("Horizontal"); - if (Input.GetKey(walkButton)) { - x *= 0.4f; - } - - speed.x = x; - - // Flip skeleton. - if (x != 0) { - animationHandle.SetFlip(x); - } - - if (Input.GetKeyDown(jumpButton)) { - if (isGrounded) - StartCoroutine(FakeJump()); - } - - logicAnimator.SetFloat(horizontalSpeedProperty, Mathf.Abs(speed.x)); - logicAnimator.SetFloat(verticalSpeedProperty, speed.y); - logicAnimator.SetBool(groundedProperty, isGrounded); - } - - IEnumerator FakeJump () { - // Rise - isGrounded = false; - speed.y = 10f; - float durationLeft = jumpDuration * 0.5f; - while (durationLeft > 0) { - durationLeft -= Time.deltaTime; - if (!Input.GetKey(jumpButton)) break; - yield return null; - } - - // Fall - speed.y = -10f; - float fallDuration = (jumpDuration * 0.5f) - durationLeft; - yield return new WaitForSeconds(fallDuration); - - // Land - speed.y = 0f; - isGrounded = true; - yield return null; - } - } - -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Spine.Unity.Examples { + public class DummyMecanimControllerExample : MonoBehaviour { + + public Animator logicAnimator; + public SkeletonAnimationHandleExample animationHandle; + + [Header("Controls")] + public KeyCode walkButton = KeyCode.LeftShift; + public KeyCode jumpButton = KeyCode.Space; + + [Header("Animator Properties")] + public string horizontalSpeedProperty = "Speed"; + public string verticalSpeedProperty = "VerticalSpeed"; + public string groundedProperty = "Grounded"; + + [Header("Fake Physics")] + public float jumpDuration = 1.5f; + public Vector2 speed; + public bool isGrounded; + + void Awake () { + isGrounded = true; + } + + void Update () { + float x = Input.GetAxisRaw("Horizontal"); + if (Input.GetKey(walkButton)) { + x *= 0.4f; + } + + speed.x = x; + + // Flip skeleton. + if (x != 0) { + animationHandle.SetFlip(x); + } + + if (Input.GetKeyDown(jumpButton)) { + if (isGrounded) + StartCoroutine(FakeJump()); + } + + logicAnimator.SetFloat(horizontalSpeedProperty, Mathf.Abs(speed.x)); + logicAnimator.SetFloat(verticalSpeedProperty, speed.y); + logicAnimator.SetBool(groundedProperty, isGrounded); + } + + IEnumerator FakeJump () { + // Rise + isGrounded = false; + speed.y = 10f; + float durationLeft = jumpDuration * 0.5f; + while (durationLeft > 0) { + durationLeft -= Time.deltaTime; + if (!Input.GetKey(jumpButton)) break; + yield return null; + } + + // Fall + speed.y = -10f; + float fallDuration = (jumpDuration * 0.5f) - durationLeft; + yield return new WaitForSeconds(fallDuration); + + // Land + speed.y = 0f; + isGrounded = true; + yield return null; + } + } + +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Mecanim as Logic/MecanimToAnimationHandleExample.cs b/Assets/ThirdParty/Spine Examples/Scripts/Mecanim as Logic/MecanimToAnimationHandleExample.cs index 0057d1e12..0bf109bb5 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/Mecanim as Logic/MecanimToAnimationHandleExample.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/Mecanim as Logic/MecanimToAnimationHandleExample.cs @@ -1,51 +1,51 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace Spine.Unity.Examples { - - // This StateMachineBehaviour handles sending the Mecanim state information to the component that handles playing the Spine animations. - public class MecanimToAnimationHandleExample : StateMachineBehaviour { - SkeletonAnimationHandleExample animationHandle; - bool initialized; - - override public void OnStateEnter (Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { - if (!initialized) { - animationHandle = animator.GetComponent(); - initialized = true; - } - - animationHandle.PlayAnimationForState(stateInfo.shortNameHash, layerIndex); - } - } - -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Spine.Unity.Examples { + + // This StateMachineBehaviour handles sending the Mecanim state information to the component that handles playing the Spine animations. + public class MecanimToAnimationHandleExample : StateMachineBehaviour { + SkeletonAnimationHandleExample animationHandle; + bool initialized; + + override public void OnStateEnter (Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { + if (!initialized) { + animationHandle = animator.GetComponent(); + initialized = true; + } + + animationHandle.PlayAnimationForState(stateInfo.shortNameHash, layerIndex); + } + } + +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Mecanim as Logic/SkeletonAnimationHandleExample.cs b/Assets/ThirdParty/Spine Examples/Scripts/Mecanim as Logic/SkeletonAnimationHandleExample.cs index 16fe06108..4aa677109 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/Mecanim as Logic/SkeletonAnimationHandleExample.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/Mecanim as Logic/SkeletonAnimationHandleExample.cs @@ -1,164 +1,164 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using System.Collections.Generic; -using UnityEngine; - -namespace Spine.Unity.Examples { - - // This is an example of an animation handle. This is implemented with strings as state names. - // Strings can serve as the identifier when Mecanim is used as the state machine and state source. - // If you don't use Mecanim, using custom ScriptableObjects may be a more efficient way to store information about the state and its connection with specific Spine animations. - - // This animation handle implementation also comes with a dummy implementation of transition-handling. - public class SkeletonAnimationHandleExample : MonoBehaviour { - public SkeletonAnimation skeletonAnimation; - public List statesAndAnimations = new List(); - public List transitions = new List(); // Alternately, an AnimationPair-Animation Dictionary (commented out) can be used for more efficient lookups. - - [System.Serializable] - public class StateNameToAnimationReference { - public string stateName; - public AnimationReferenceAsset animation; - } - - [System.Serializable] - public class AnimationTransition { - public AnimationReferenceAsset from; - public AnimationReferenceAsset to; - public AnimationReferenceAsset transition; - } - - //readonly Dictionary transitionDictionary = new Dictionary(Spine.AnimationStateData.AnimationPairComparer.Instance); - - public Spine.Animation TargetAnimation { get; private set; } - - void Awake () { - // Initialize AnimationReferenceAssets - foreach (StateNameToAnimationReference entry in statesAndAnimations) { - entry.animation.Initialize(); - } - foreach (AnimationTransition entry in transitions) { - entry.from.Initialize(); - entry.to.Initialize(); - entry.transition.Initialize(); - } - - // Build Dictionary - //foreach (AnimationTransition entry in transitions) { - // transitionDictionary.Add(new AnimationStateData.AnimationPair(entry.from.Animation, entry.to.Animation), entry.transition.Animation); - //} - } - - /// Sets the horizontal flip state of the skeleton based on a nonzero float. If negative, the skeleton is flipped. If positive, the skeleton is not flipped. - public void SetFlip (float horizontal) { - if (horizontal != 0) { - skeletonAnimation.Skeleton.ScaleX = horizontal > 0 ? 1f : -1f; - } - } - - /// Plays an animation based on the state name. - public void PlayAnimationForState (string stateShortName, int layerIndex) { - PlayAnimationForState(StringToHash(stateShortName), layerIndex); - } - - /// Plays an animation based on the hash of the state name. - public void PlayAnimationForState (int shortNameHash, int layerIndex) { - Animation foundAnimation = GetAnimationForState(shortNameHash); - if (foundAnimation == null) - return; - - PlayNewAnimation(foundAnimation, layerIndex); - } - - /// Gets a Spine Animation based on the state name. - public Spine.Animation GetAnimationForState (string stateShortName) { - return GetAnimationForState(StringToHash(stateShortName)); - } - - /// Gets a Spine Animation based on the hash of the state name. - public Spine.Animation GetAnimationForState (int shortNameHash) { - StateNameToAnimationReference foundState = statesAndAnimations.Find(entry => StringToHash(entry.stateName) == shortNameHash); - return (foundState == null) ? null : foundState.animation; - } - - /// Play an animation. If a transition animation is defined, the transition is played before the target animation being passed. - public void PlayNewAnimation (Spine.Animation target, int layerIndex) { - Spine.Animation transition = null; - Spine.Animation current = null; - - current = GetCurrentAnimation(layerIndex); - if (current != null) - transition = TryGetTransition(current, target); - - if (transition != null) { - skeletonAnimation.AnimationState.SetAnimation(layerIndex, transition, false); - skeletonAnimation.AnimationState.AddAnimation(layerIndex, target, true, 0f); - } else { - skeletonAnimation.AnimationState.SetAnimation(layerIndex, target, true); - } - - this.TargetAnimation = target; - } - - /// Play a non-looping animation once then continue playing the state animation. - public void PlayOneShot (Spine.Animation oneShot, int layerIndex) { - AnimationState state = skeletonAnimation.AnimationState; - state.SetAnimation(0, oneShot, false); - - Animation transition = TryGetTransition(oneShot, TargetAnimation); - if (transition != null) - state.AddAnimation(0, transition, false, 0f); - - state.AddAnimation(0, this.TargetAnimation, true, 0f); - } - - Spine.Animation TryGetTransition (Spine.Animation from, Spine.Animation to) { - foreach (AnimationTransition transition in transitions) { - if (transition.from.Animation == from && transition.to.Animation == to) { - return transition.transition.Animation; - } - } - return null; - - //Spine.Animation foundTransition = null; - //transitionDictionary.TryGetValue(new AnimationStateData.AnimationPair(from, to), out foundTransition); - //return foundTransition; - } - - Spine.Animation GetCurrentAnimation (int layerIndex) { - TrackEntry currentTrackEntry = skeletonAnimation.AnimationState.GetCurrent(layerIndex); - return (currentTrackEntry != null) ? currentTrackEntry.Animation : null; - } - - int StringToHash (string s) { - return Animator.StringToHash(s); - } - } -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using System.Collections.Generic; +using UnityEngine; + +namespace Spine.Unity.Examples { + + // This is an example of an animation handle. This is implemented with strings as state names. + // Strings can serve as the identifier when Mecanim is used as the state machine and state source. + // If you don't use Mecanim, using custom ScriptableObjects may be a more efficient way to store information about the state and its connection with specific Spine animations. + + // This animation handle implementation also comes with a dummy implementation of transition-handling. + public class SkeletonAnimationHandleExample : MonoBehaviour { + public SkeletonAnimation skeletonAnimation; + public List statesAndAnimations = new List(); + public List transitions = new List(); // Alternately, an AnimationPair-Animation Dictionary (commented out) can be used for more efficient lookups. + + [System.Serializable] + public class StateNameToAnimationReference { + public string stateName; + public AnimationReferenceAsset animation; + } + + [System.Serializable] + public class AnimationTransition { + public AnimationReferenceAsset from; + public AnimationReferenceAsset to; + public AnimationReferenceAsset transition; + } + + //readonly Dictionary transitionDictionary = new Dictionary(Spine.AnimationStateData.AnimationPairComparer.Instance); + + public Spine.Animation TargetAnimation { get; private set; } + + void Awake () { + // Initialize AnimationReferenceAssets + foreach (StateNameToAnimationReference entry in statesAndAnimations) { + entry.animation.Initialize(); + } + foreach (AnimationTransition entry in transitions) { + entry.from.Initialize(); + entry.to.Initialize(); + entry.transition.Initialize(); + } + + // Build Dictionary + //foreach (AnimationTransition entry in transitions) { + // transitionDictionary.Add(new AnimationStateData.AnimationPair(entry.from.Animation, entry.to.Animation), entry.transition.Animation); + //} + } + + /// Sets the horizontal flip state of the skeleton based on a nonzero float. If negative, the skeleton is flipped. If positive, the skeleton is not flipped. + public void SetFlip (float horizontal) { + if (horizontal != 0) { + skeletonAnimation.Skeleton.ScaleX = horizontal > 0 ? 1f : -1f; + } + } + + /// Plays an animation based on the state name. + public void PlayAnimationForState (string stateShortName, int layerIndex) { + PlayAnimationForState(StringToHash(stateShortName), layerIndex); + } + + /// Plays an animation based on the hash of the state name. + public void PlayAnimationForState (int shortNameHash, int layerIndex) { + Animation foundAnimation = GetAnimationForState(shortNameHash); + if (foundAnimation == null) + return; + + PlayNewAnimation(foundAnimation, layerIndex); + } + + /// Gets a Spine Animation based on the state name. + public Spine.Animation GetAnimationForState (string stateShortName) { + return GetAnimationForState(StringToHash(stateShortName)); + } + + /// Gets a Spine Animation based on the hash of the state name. + public Spine.Animation GetAnimationForState (int shortNameHash) { + StateNameToAnimationReference foundState = statesAndAnimations.Find(entry => StringToHash(entry.stateName) == shortNameHash); + return (foundState == null) ? null : foundState.animation; + } + + /// Play an animation. If a transition animation is defined, the transition is played before the target animation being passed. + public void PlayNewAnimation (Spine.Animation target, int layerIndex) { + Spine.Animation transition = null; + Spine.Animation current = null; + + current = GetCurrentAnimation(layerIndex); + if (current != null) + transition = TryGetTransition(current, target); + + if (transition != null) { + skeletonAnimation.AnimationState.SetAnimation(layerIndex, transition, false); + skeletonAnimation.AnimationState.AddAnimation(layerIndex, target, true, 0f); + } else { + skeletonAnimation.AnimationState.SetAnimation(layerIndex, target, true); + } + + this.TargetAnimation = target; + } + + /// Play a non-looping animation once then continue playing the state animation. + public void PlayOneShot (Spine.Animation oneShot, int layerIndex) { + AnimationState state = skeletonAnimation.AnimationState; + state.SetAnimation(0, oneShot, false); + + Animation transition = TryGetTransition(oneShot, TargetAnimation); + if (transition != null) + state.AddAnimation(0, transition, false, 0f); + + state.AddAnimation(0, this.TargetAnimation, true, 0f); + } + + Spine.Animation TryGetTransition (Spine.Animation from, Spine.Animation to) { + foreach (AnimationTransition transition in transitions) { + if (transition.from.Animation == from && transition.to.Animation == to) { + return transition.transition.Animation; + } + } + return null; + + //Spine.Animation foundTransition = null; + //transitionDictionary.TryGetValue(new AnimationStateData.AnimationPair(from, to), out foundTransition); + //return foundTransition; + } + + Spine.Animation GetCurrentAnimation (int layerIndex) { + TrackEntry currentTrackEntry = skeletonAnimation.AnimationState.GetCurrent(layerIndex); + return (currentTrackEntry != null) ? currentTrackEntry.Animation : null; + } + + int StringToHash (string s) { + return Animator.StringToHash(s); + } + } +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/MecanimAnimationMatchModifier/AnimationMatchModifierAsset.cs b/Assets/ThirdParty/Spine Examples/Scripts/MecanimAnimationMatchModifier/AnimationMatchModifierAsset.cs index ec72027ea..9847fc7de 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/MecanimAnimationMatchModifier/AnimationMatchModifierAsset.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/MecanimAnimationMatchModifier/AnimationMatchModifierAsset.cs @@ -1,237 +1,237 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using Spine; -using Spine.Unity; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace Spine.Unity.Examples { - - //[CreateAssetMenu(menuName = "Spine/SkeletonData Modifiers/Animation Match", order = 200)] - public class AnimationMatchModifierAsset : SkeletonDataModifierAsset { - - public bool matchAllAnimations = true; - - public override void Apply (SkeletonData skeletonData) { - if (matchAllAnimations) - AnimationTools.MatchAnimationTimelines(skeletonData.Animations, skeletonData); - } - - public static class AnimationTools { - - #region Filler Timelines - /// - /// Matches the animation timelines across the given set of animations. - /// This allows unkeyed properties to assume setup pose when animations are naively mixed using Animation.Apply. - /// - /// An enumerable collection animations whose timelines will be matched. - /// The SkeletonData where the animations belong. - public static void MatchAnimationTimelines (IEnumerable animations, SkeletonData skeletonData) { - if (animations == null) return; - if (skeletonData == null) throw new System.ArgumentNullException("skeletonData", "Timelines can't be matched without a SkeletonData source."); - - // Build a reference collection of timelines to match - // and a collection of dummy timelines that can be used to fill-in missing items. - Dictionary timelineDictionary = new Dictionary(); - foreach (Animation animation in animations) { - foreach (Timeline timeline in animation.Timelines) { - if (timeline is EventTimeline) continue; - - foreach (string propertyId in timeline.PropertyIds) { - if (!timelineDictionary.ContainsKey(propertyId)) { - timelineDictionary.Add(propertyId, GetFillerTimeline(timeline, skeletonData)); - } - } - } - } - List idsToMatch = new List(timelineDictionary.Keys); - - // For each animation in the list, check for and add missing timelines. - HashSet currentAnimationIDs = new HashSet(); - foreach (Animation animation in animations) { - currentAnimationIDs.Clear(); - foreach (Timeline timeline in animation.Timelines) { - if (timeline is EventTimeline) continue; - foreach (string propertyId in timeline.PropertyIds) { - currentAnimationIDs.Add(propertyId); - } - } - - ExposedList animationTimelines = animation.Timelines; - foreach (string propertyId in idsToMatch) { - if (!currentAnimationIDs.Contains(propertyId)) - animationTimelines.Add(timelineDictionary[propertyId]); - } - } - - // These are locals, but sometimes Unity's GC does weird stuff. So let's clean up. - timelineDictionary.Clear(); - timelineDictionary = null; - idsToMatch.Clear(); - idsToMatch = null; - currentAnimationIDs.Clear(); - currentAnimationIDs = null; - } - - static Timeline GetFillerTimeline (Timeline timeline, SkeletonData skeletonData) { - if (timeline is RotateTimeline) - return GetFillerTimeline((RotateTimeline)timeline, skeletonData); - if (timeline is TranslateTimeline) - return GetFillerTimeline((TranslateTimeline)timeline, skeletonData); - if (timeline is ScaleTimeline) - return GetFillerTimeline((ScaleTimeline)timeline, skeletonData); - if (timeline is ShearTimeline) - return GetFillerTimeline((ShearTimeline)timeline, skeletonData); - if (timeline is AttachmentTimeline) - return GetFillerTimeline((AttachmentTimeline)timeline, skeletonData); - if (timeline is RGBATimeline) - return GetFillerTimeline((RGBATimeline)timeline, skeletonData); - if (timeline is RGBA2Timeline) - return GetFillerTimeline((RGBA2Timeline)timeline, skeletonData); - if (timeline is DeformTimeline) - return GetFillerTimeline((DeformTimeline)timeline, skeletonData); - if (timeline is DrawOrderTimeline) - return GetFillerTimeline((DrawOrderTimeline)timeline, skeletonData); - if (timeline is IkConstraintTimeline) - return GetFillerTimeline((IkConstraintTimeline)timeline, skeletonData); - if (timeline is TransformConstraintTimeline) - return GetFillerTimeline((TransformConstraintTimeline)timeline, skeletonData); - if (timeline is PathConstraintPositionTimeline) - return GetFillerTimeline((PathConstraintPositionTimeline)timeline, skeletonData); - if (timeline is PathConstraintSpacingTimeline) - return GetFillerTimeline((PathConstraintSpacingTimeline)timeline, skeletonData); - if (timeline is PathConstraintMixTimeline) - return GetFillerTimeline((PathConstraintMixTimeline)timeline, skeletonData); - return null; - } - - static RotateTimeline GetFillerTimeline (RotateTimeline timeline, SkeletonData skeletonData) { - RotateTimeline t = new RotateTimeline(1, 0, timeline.BoneIndex); - t.SetFrame(0, 0, 0); - return t; - } - - static TranslateTimeline GetFillerTimeline (TranslateTimeline timeline, SkeletonData skeletonData) { - TranslateTimeline t = new TranslateTimeline(1, 0, timeline.BoneIndex); - t.SetFrame(0, 0, 0, 0); - return t; - } - - static ScaleTimeline GetFillerTimeline (ScaleTimeline timeline, SkeletonData skeletonData) { - ScaleTimeline t = new ScaleTimeline(1, 0, timeline.BoneIndex); - t.SetFrame(0, 0, 0, 0); - return t; - } - - static ShearTimeline GetFillerTimeline (ShearTimeline timeline, SkeletonData skeletonData) { - ShearTimeline t = new ShearTimeline(1, 0, timeline.BoneIndex); - t.SetFrame(0, 0, 0, 0); - return t; - } - - static AttachmentTimeline GetFillerTimeline (AttachmentTimeline timeline, SkeletonData skeletonData) { - AttachmentTimeline t = new AttachmentTimeline(1, timeline.SlotIndex); - SlotData slotData = skeletonData.Slots.Items[t.SlotIndex]; - t.SetFrame(0, 0, slotData.AttachmentName); - return t; - } - - static RGBATimeline GetFillerTimeline (RGBATimeline timeline, SkeletonData skeletonData) { - RGBATimeline t = new RGBATimeline(1, 0, timeline.SlotIndex); - SlotData slotData = skeletonData.Slots.Items[t.SlotIndex]; - t.SetFrame(0, 0, slotData.R, slotData.G, slotData.B, slotData.A); - return t; - } - - static RGBA2Timeline GetFillerTimeline (RGBA2Timeline timeline, SkeletonData skeletonData) { - RGBA2Timeline t = new RGBA2Timeline(1, 0, timeline.SlotIndex); - SlotData slotData = skeletonData.Slots.Items[t.SlotIndex]; - t.SetFrame(0, 0, slotData.R, slotData.G, slotData.B, slotData.A, slotData.R2, slotData.G2, slotData.B2); - return t; - } - - static DeformTimeline GetFillerTimeline (DeformTimeline timeline, SkeletonData skeletonData) { - DeformTimeline t = new DeformTimeline(1, 0, timeline.SlotIndex, timeline.Attachment); - if (t.Attachment.IsWeighted()) { - t.SetFrame(0, 0, new float[t.Attachment.Vertices.Length]); - } else { - t.SetFrame(0, 0, t.Attachment.Vertices.Clone() as float[]); - } - - return t; - } - - static DrawOrderTimeline GetFillerTimeline (DrawOrderTimeline timeline, SkeletonData skeletonData) { - DrawOrderTimeline t = new DrawOrderTimeline(1); - t.SetFrame(0, 0, null); // null means use setup pose in DrawOrderTimeline.Apply. - return t; - } - - static IkConstraintTimeline GetFillerTimeline (IkConstraintTimeline timeline, SkeletonData skeletonData) { - IkConstraintTimeline t = new IkConstraintTimeline(1, 0, timeline.IkConstraintIndex); - IkConstraintData ikConstraintData = skeletonData.IkConstraints.Items[timeline.IkConstraintIndex]; - t.SetFrame(0, 0, ikConstraintData.Mix, ikConstraintData.Softness, ikConstraintData.BendDirection, ikConstraintData.Compress, ikConstraintData.Stretch); - return t; - } - - static TransformConstraintTimeline GetFillerTimeline (TransformConstraintTimeline timeline, SkeletonData skeletonData) { - TransformConstraintTimeline t = new TransformConstraintTimeline(1, 0, timeline.TransformConstraintIndex); - TransformConstraintData data = skeletonData.TransformConstraints.Items[timeline.TransformConstraintIndex]; - t.SetFrame(0, 0, data.MixRotate, data.MixX, data.MixY, data.MixScaleX, data.MixScaleY, data.MixShearY); - return t; - } - - static PathConstraintPositionTimeline GetFillerTimeline (PathConstraintPositionTimeline timeline, SkeletonData skeletonData) { - PathConstraintPositionTimeline t = new PathConstraintPositionTimeline(1, 0, timeline.PathConstraintIndex); - PathConstraintData data = skeletonData.PathConstraints.Items[timeline.PathConstraintIndex]; - t.SetFrame(0, 0, data.Position); - return t; - } - - static PathConstraintSpacingTimeline GetFillerTimeline (PathConstraintSpacingTimeline timeline, SkeletonData skeletonData) { - PathConstraintSpacingTimeline t = new PathConstraintSpacingTimeline(1, 0, timeline.PathConstraintIndex); - PathConstraintData data = skeletonData.PathConstraints.Items[timeline.PathConstraintIndex]; - t.SetFrame(0, 0, data.Spacing); - return t; - } - - static PathConstraintMixTimeline GetFillerTimeline (PathConstraintMixTimeline timeline, SkeletonData skeletonData) { - PathConstraintMixTimeline t = new PathConstraintMixTimeline(1, 0, timeline.PathConstraintIndex); - PathConstraintData data = skeletonData.PathConstraints.Items[timeline.PathConstraintIndex]; - t.SetFrame(0, 0, data.RotateMix, data.MixX, data.MixY); - return t; - } - #endregion - } - - } - -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using Spine; +using Spine.Unity; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Spine.Unity.Examples { + + //[CreateAssetMenu(menuName = "Spine/SkeletonData Modifiers/Animation Match", order = 200)] + public class AnimationMatchModifierAsset : SkeletonDataModifierAsset { + + public bool matchAllAnimations = true; + + public override void Apply (SkeletonData skeletonData) { + if (matchAllAnimations) + AnimationTools.MatchAnimationTimelines(skeletonData.Animations, skeletonData); + } + + public static class AnimationTools { + + #region Filler Timelines + /// + /// Matches the animation timelines across the given set of animations. + /// This allows unkeyed properties to assume setup pose when animations are naively mixed using Animation.Apply. + /// + /// An enumerable collection animations whose timelines will be matched. + /// The SkeletonData where the animations belong. + public static void MatchAnimationTimelines (IEnumerable animations, SkeletonData skeletonData) { + if (animations == null) return; + if (skeletonData == null) throw new System.ArgumentNullException("skeletonData", "Timelines can't be matched without a SkeletonData source."); + + // Build a reference collection of timelines to match + // and a collection of dummy timelines that can be used to fill-in missing items. + Dictionary timelineDictionary = new Dictionary(); + foreach (Animation animation in animations) { + foreach (Timeline timeline in animation.Timelines) { + if (timeline is EventTimeline) continue; + + foreach (string propertyId in timeline.PropertyIds) { + if (!timelineDictionary.ContainsKey(propertyId)) { + timelineDictionary.Add(propertyId, GetFillerTimeline(timeline, skeletonData)); + } + } + } + } + List idsToMatch = new List(timelineDictionary.Keys); + + // For each animation in the list, check for and add missing timelines. + HashSet currentAnimationIDs = new HashSet(); + foreach (Animation animation in animations) { + currentAnimationIDs.Clear(); + foreach (Timeline timeline in animation.Timelines) { + if (timeline is EventTimeline) continue; + foreach (string propertyId in timeline.PropertyIds) { + currentAnimationIDs.Add(propertyId); + } + } + + ExposedList animationTimelines = animation.Timelines; + foreach (string propertyId in idsToMatch) { + if (!currentAnimationIDs.Contains(propertyId)) + animationTimelines.Add(timelineDictionary[propertyId]); + } + } + + // These are locals, but sometimes Unity's GC does weird stuff. So let's clean up. + timelineDictionary.Clear(); + timelineDictionary = null; + idsToMatch.Clear(); + idsToMatch = null; + currentAnimationIDs.Clear(); + currentAnimationIDs = null; + } + + static Timeline GetFillerTimeline (Timeline timeline, SkeletonData skeletonData) { + if (timeline is RotateTimeline) + return GetFillerTimeline((RotateTimeline)timeline, skeletonData); + if (timeline is TranslateTimeline) + return GetFillerTimeline((TranslateTimeline)timeline, skeletonData); + if (timeline is ScaleTimeline) + return GetFillerTimeline((ScaleTimeline)timeline, skeletonData); + if (timeline is ShearTimeline) + return GetFillerTimeline((ShearTimeline)timeline, skeletonData); + if (timeline is AttachmentTimeline) + return GetFillerTimeline((AttachmentTimeline)timeline, skeletonData); + if (timeline is RGBATimeline) + return GetFillerTimeline((RGBATimeline)timeline, skeletonData); + if (timeline is RGBA2Timeline) + return GetFillerTimeline((RGBA2Timeline)timeline, skeletonData); + if (timeline is DeformTimeline) + return GetFillerTimeline((DeformTimeline)timeline, skeletonData); + if (timeline is DrawOrderTimeline) + return GetFillerTimeline((DrawOrderTimeline)timeline, skeletonData); + if (timeline is IkConstraintTimeline) + return GetFillerTimeline((IkConstraintTimeline)timeline, skeletonData); + if (timeline is TransformConstraintTimeline) + return GetFillerTimeline((TransformConstraintTimeline)timeline, skeletonData); + if (timeline is PathConstraintPositionTimeline) + return GetFillerTimeline((PathConstraintPositionTimeline)timeline, skeletonData); + if (timeline is PathConstraintSpacingTimeline) + return GetFillerTimeline((PathConstraintSpacingTimeline)timeline, skeletonData); + if (timeline is PathConstraintMixTimeline) + return GetFillerTimeline((PathConstraintMixTimeline)timeline, skeletonData); + return null; + } + + static RotateTimeline GetFillerTimeline (RotateTimeline timeline, SkeletonData skeletonData) { + RotateTimeline t = new RotateTimeline(1, 0, timeline.BoneIndex); + t.SetFrame(0, 0, 0); + return t; + } + + static TranslateTimeline GetFillerTimeline (TranslateTimeline timeline, SkeletonData skeletonData) { + TranslateTimeline t = new TranslateTimeline(1, 0, timeline.BoneIndex); + t.SetFrame(0, 0, 0, 0); + return t; + } + + static ScaleTimeline GetFillerTimeline (ScaleTimeline timeline, SkeletonData skeletonData) { + ScaleTimeline t = new ScaleTimeline(1, 0, timeline.BoneIndex); + t.SetFrame(0, 0, 0, 0); + return t; + } + + static ShearTimeline GetFillerTimeline (ShearTimeline timeline, SkeletonData skeletonData) { + ShearTimeline t = new ShearTimeline(1, 0, timeline.BoneIndex); + t.SetFrame(0, 0, 0, 0); + return t; + } + + static AttachmentTimeline GetFillerTimeline (AttachmentTimeline timeline, SkeletonData skeletonData) { + AttachmentTimeline t = new AttachmentTimeline(1, timeline.SlotIndex); + SlotData slotData = skeletonData.Slots.Items[t.SlotIndex]; + t.SetFrame(0, 0, slotData.AttachmentName); + return t; + } + + static RGBATimeline GetFillerTimeline (RGBATimeline timeline, SkeletonData skeletonData) { + RGBATimeline t = new RGBATimeline(1, 0, timeline.SlotIndex); + SlotData slotData = skeletonData.Slots.Items[t.SlotIndex]; + t.SetFrame(0, 0, slotData.R, slotData.G, slotData.B, slotData.A); + return t; + } + + static RGBA2Timeline GetFillerTimeline (RGBA2Timeline timeline, SkeletonData skeletonData) { + RGBA2Timeline t = new RGBA2Timeline(1, 0, timeline.SlotIndex); + SlotData slotData = skeletonData.Slots.Items[t.SlotIndex]; + t.SetFrame(0, 0, slotData.R, slotData.G, slotData.B, slotData.A, slotData.R2, slotData.G2, slotData.B2); + return t; + } + + static DeformTimeline GetFillerTimeline (DeformTimeline timeline, SkeletonData skeletonData) { + DeformTimeline t = new DeformTimeline(1, 0, timeline.SlotIndex, timeline.Attachment); + if (t.Attachment.IsWeighted()) { + t.SetFrame(0, 0, new float[t.Attachment.Vertices.Length]); + } else { + t.SetFrame(0, 0, t.Attachment.Vertices.Clone() as float[]); + } + + return t; + } + + static DrawOrderTimeline GetFillerTimeline (DrawOrderTimeline timeline, SkeletonData skeletonData) { + DrawOrderTimeline t = new DrawOrderTimeline(1); + t.SetFrame(0, 0, null); // null means use setup pose in DrawOrderTimeline.Apply. + return t; + } + + static IkConstraintTimeline GetFillerTimeline (IkConstraintTimeline timeline, SkeletonData skeletonData) { + IkConstraintTimeline t = new IkConstraintTimeline(1, 0, timeline.IkConstraintIndex); + IkConstraintData ikConstraintData = skeletonData.IkConstraints.Items[timeline.IkConstraintIndex]; + t.SetFrame(0, 0, ikConstraintData.Mix, ikConstraintData.Softness, ikConstraintData.BendDirection, ikConstraintData.Compress, ikConstraintData.Stretch); + return t; + } + + static TransformConstraintTimeline GetFillerTimeline (TransformConstraintTimeline timeline, SkeletonData skeletonData) { + TransformConstraintTimeline t = new TransformConstraintTimeline(1, 0, timeline.TransformConstraintIndex); + TransformConstraintData data = skeletonData.TransformConstraints.Items[timeline.TransformConstraintIndex]; + t.SetFrame(0, 0, data.MixRotate, data.MixX, data.MixY, data.MixScaleX, data.MixScaleY, data.MixShearY); + return t; + } + + static PathConstraintPositionTimeline GetFillerTimeline (PathConstraintPositionTimeline timeline, SkeletonData skeletonData) { + PathConstraintPositionTimeline t = new PathConstraintPositionTimeline(1, 0, timeline.PathConstraintIndex); + PathConstraintData data = skeletonData.PathConstraints.Items[timeline.PathConstraintIndex]; + t.SetFrame(0, 0, data.Position); + return t; + } + + static PathConstraintSpacingTimeline GetFillerTimeline (PathConstraintSpacingTimeline timeline, SkeletonData skeletonData) { + PathConstraintSpacingTimeline t = new PathConstraintSpacingTimeline(1, 0, timeline.PathConstraintIndex); + PathConstraintData data = skeletonData.PathConstraints.Items[timeline.PathConstraintIndex]; + t.SetFrame(0, 0, data.Spacing); + return t; + } + + static PathConstraintMixTimeline GetFillerTimeline (PathConstraintMixTimeline timeline, SkeletonData skeletonData) { + PathConstraintMixTimeline t = new PathConstraintMixTimeline(1, 0, timeline.PathConstraintIndex); + PathConstraintData data = skeletonData.PathConstraints.Items[timeline.PathConstraintIndex]; + t.SetFrame(0, 0, data.RotateMix, data.MixX, data.MixY); + return t; + } + #endregion + } + + } + +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Mix and Match Character Customize/EquipAssetExample.cs b/Assets/ThirdParty/Spine Examples/Scripts/Mix and Match Character Customize/EquipAssetExample.cs index 96c1de22d..3b4db0eb1 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/Mix and Match Character Customize/EquipAssetExample.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/Mix and Match Character Customize/EquipAssetExample.cs @@ -1,41 +1,41 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace Spine.Unity.Examples { - public class EquipAssetExample : ScriptableObject { - public EquipSystemExample.EquipType equipType; - public Sprite sprite; - public string description; - public int yourStats; - } -} +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated July 28, 2023. Replaces all prior versions. + * + * Copyright (c) 2013-2023, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software or + * otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE + * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Spine.Unity.Examples { + public class EquipAssetExample : ScriptableObject { + public EquipSystemExample.EquipType equipType; + public Sprite sprite; + public string description; + public int yourStats; + } +} diff --git a/Assets/ThirdParty/Spine Examples/Scripts/Mix and Match Character Customize/EquipButtonExample.cs b/Assets/ThirdParty/Spine Examples/Scripts/Mix and Match Character Customize/EquipButtonExample.cs index fd264f9a4..fd1d47429 100644 --- a/Assets/ThirdParty/Spine Examples/Scripts/Mix and Match Character Customize/EquipButtonExample.cs +++ b/Assets/ThirdParty/Spine Examples/Scripts/Mix and Match Character Customize/EquipButtonExample.cs @@ -1,60 +1,60 @@ -/****************************************************************************** - * Spine Runtimes License Agreement - * Last updated September 24, 2021. Replaces all prior versions. - * - * Copyright (c) 2013-2021, Esoteric Software LLC - * - * Integration of the Spine Runtimes into software or otherwise creating - * derivative works of the Spine Runtimes is permitted under the terms and - * conditions of Section 2 of the Spine Editor License Agreement: - * http://esotericsoftware.com/spine-editor-license - * - * Otherwise, it is permitted to integrate the Spine Runtimes into software - * or otherwise create derivative works of the Spine Runtimes (collectively, - * "Products"), provided that each user of the Products must obtain their own - * Spine Editor license and redistribution of the Products in any form must - * include this license and copyright notice. - * - * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, - * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -using UnityEngine.UI; - -namespace Spine.Unity.Examples { - public class EquipButtonExample : MonoBehaviour { - public EquipAssetExample asset; - public EquipSystemExample equipSystem; - public Image inventoryImage; - - void OnValidate () { - MatchImage(); - } - - void MatchImage () { - if (inventoryImage != null) - inventoryImage.sprite = asset.sprite; - } - - void Start () { - MatchImage(); - - Button button = GetComponent