diff options
Diffstat (limited to 'Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application')
6 files changed, 277 insertions, 0 deletions
diff --git a/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application/AssetResourcesFile.cs b/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application/AssetResourcesFile.cs new file mode 100644 index 00000000..7f5392be --- /dev/null +++ b/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application/AssetResourcesFile.cs @@ -0,0 +1,120 @@ +#if UNITY_EDITOR +using UnityEngine; +using UnityEditor; +using System; +using System.Collections.Generic; +using System.IO; + +namespace UMotionEditor +{ + public class AssetResourcesFile : ScriptableObject + { + //******************************************************************************** + // Public Properties + //******************************************************************************** + + //******************************************************************************** + // Private Properties + //******************************************************************************** + + #pragma warning disable 0649 // Suppress "Field 'field' is never assigned to, and will always have its default value 'value'" + [Serializable] + private struct ResourceDefinition + { + public string Name; + public UnityEngine.Object Reference; + } + #pragma warning restore 0649 + + //---------------------- + // Inspector + //---------------------- + [SerializeField]private List<ResourceDefinition> resourcesList = new List<ResourceDefinition>(); + [SerializeField]private List<ResourceDefinition> optionalResourcesList = new List<ResourceDefinition>(); + private Dictionary<string, UnityEngine.Object> resourcesDictionary = new Dictionary<string, UnityEngine.Object>(); + + //---------------------- + // Internal + //---------------------- + + //******************************************************************************** + // Public Methods + //******************************************************************************** + + public static AssetResourcesFile FindAssetResourcesFile() + { + string[] resourceFilesGUID = AssetDatabase.FindAssets("UMotionResources t:AssetResourcesFile"); + + if (resourceFilesGUID.Length > 1) + { + throw new UnityException("More than one resource file was found. Please remove all UMotion files and install UMotion again."); + } + else if (resourceFilesGUID.Length == 0) + { + throw new UnityException("Resource file not found. Please install UMotion again."); + } + else + { + AssetResourcesFile resourceFile = AssetDatabase.LoadAssetAtPath<AssetResourcesFile>(AssetDatabase.GUIDToAssetPath(resourceFilesGUID[0])); + + resourceFile.InitializeDictionary(); + + return resourceFile; + } + } + + public string GetEditorDataPath() + { + string resourcesPath = AssetDatabase.GetAssetPath(this); + + string dataPath = Path.GetDirectoryName(resourcesPath); + dataPath = Path.Combine(Path.GetDirectoryName(dataPath), "Data"); + + return dataPath; + } + + public T GetResource<T>(string name, bool required = true) where T : UnityEngine.Object + { + T loadedObject = null; + UnityEngine.Object obj; + if (resourcesDictionary.TryGetValue(name, out obj)) + { + loadedObject = obj as T; + } + + if (required && (loadedObject == null)) + { + throw new Exception(string.Format("Resource \"{0}\" can not be loaded.", name)); + } + else + { + return loadedObject; + } + } + + //******************************************************************************** + // Private Methods + //******************************************************************************** + + private void InitializeDictionary() + { + resourcesDictionary.Clear(); + foreach (ResourceDefinition resourceDef in resourcesList) + { + if (resourceDef.Reference == null) + { + throw new UnityException(string.Format("Required resource \"{0}\" not found. Please reinstall UMotion.", resourceDef.Name)); + } + else + { + resourcesDictionary.Add(resourceDef.Name, resourceDef.Reference); + } + } + foreach (ResourceDefinition resourceDef in optionalResourcesList) + { + resourcesDictionary.Add(resourceDef.Name, resourceDef.Reference); + } + } + } +} +#endif
\ No newline at end of file diff --git a/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application/AssetResourcesFile.cs.meta b/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application/AssetResourcesFile.cs.meta new file mode 100644 index 00000000..51a5302c --- /dev/null +++ b/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application/AssetResourcesFile.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c4518f215ae949c4e9341e0353fc63b2 +timeCreated: 1518871555 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application/UMotionSourceApplication.asmdef b/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application/UMotionSourceApplication.asmdef new file mode 100644 index 00000000..4542f3cd --- /dev/null +++ b/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application/UMotionSourceApplication.asmdef @@ -0,0 +1,8 @@ +{ + "name": "UMotionSourceApplication", + "references": [], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [] +}
\ No newline at end of file diff --git a/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application/UMotionSourceApplication.asmdef.meta b/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application/UMotionSourceApplication.asmdef.meta new file mode 100644 index 00000000..736fcd69 --- /dev/null +++ b/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application/UMotionSourceApplication.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8a7b60ba7421eeb4e9d4e0809ac8ccbd +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application/VersionCompatibilityUtility.cs b/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application/VersionCompatibilityUtility.cs new file mode 100644 index 00000000..ee7861ff --- /dev/null +++ b/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application/VersionCompatibilityUtility.cs @@ -0,0 +1,118 @@ +#if UNITY_EDITOR +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using UnityEngine; + +namespace UMotionEditor +{ + public static class VersionCompatibilityUtility + { + #if !UNITY_2017_4_OR_NEWER + #error "This Unity version is not supported by UMotion. Please update to Unity 2017.4 or higher." + #endif + + //******************************************************************************** + // Public Properties + //******************************************************************************** + + public enum EditorPlatform + { + Windows = 0, + Mac, + Linux, + Invalid + } + + public static EditorPlatform CurrentEditorPlatform + { + get + { + switch (Application.platform) + { + case RuntimePlatform.WindowsEditor: + return EditorPlatform.Windows; + + case RuntimePlatform.OSXEditor: + return EditorPlatform.Mac; + + case RuntimePlatform.LinuxEditor: + return EditorPlatform.Linux; + + default: + return EditorPlatform.Invalid; + } + } + } + + public static bool Unity2018_1_OrNewer + { + get + { + #if UNITY_2018_1_OR_NEWER + return true; + #else + return false; + #endif + } + } + + public static bool Unity2018_3_OrNewer + { + get + { + #if UNITY_2018_3_OR_NEWER + return true; + #else + return false; + #endif + } + } + + public static bool Unity2019_1_Or_Newer + { + get + { + #if UNITY_2019_1_OR_NEWER + return true; + #else + return false; + #endif + } + } + + public static bool UsesScriptableRenderPipeline + { + get + { + #if UNITY_2019_1_OR_NEWER + return (UnityEngine.Rendering.RenderPipelineManager.currentPipeline != null); + #else + #if UNITY_2018_1_OR_NEWER + return (UnityEngine.Experimental.Rendering.RenderPipelineManager.currentPipeline != null); + #else + return false; + #endif + #endif + } + } + + public static string GetCurrentAssemblyName() + { + return Assembly.GetExecutingAssembly().GetName().Name; + } + + //******************************************************************************** + // Private Properties + //******************************************************************************** + + //******************************************************************************** + // Public Methods + //******************************************************************************** + + //******************************************************************************** + // Private Methods + //******************************************************************************** + } +} +#endif
\ No newline at end of file diff --git a/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application/VersionCompatibilityUtility.cs.meta b/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application/VersionCompatibilityUtility.cs.meta new file mode 100644 index 00000000..b9cea14f --- /dev/null +++ b/Assets/ThirdParty/UMotion/UMotionEditor/Scripts/Application/VersionCompatibilityUtility.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fec42e10ecaca094ba9237b4c4b68039 +timeCreated: 1513775087 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |