├── .gitignore ├── Assets ├── Spriter2UnityDX.meta └── Spriter2UnityDX │ ├── Editor.meta │ ├── Editor │ ├── AnimationBuilder.cs │ ├── AnimationBuilder.cs.meta │ ├── CustomEditors.cs │ ├── CustomEditors.cs.meta │ ├── PrefabBuilder.cs │ ├── PrefabBuilder.cs.meta │ ├── S2USettings.cs │ ├── S2USettings.cs.meta │ ├── ScmlImportOptions.cs │ ├── ScmlPostProcessor.cs │ ├── ScmlPostProcessor.cs.meta │ ├── ScmlSupport.cs │ ├── ScmlSupport.cs.meta │ ├── Settings.asset │ └── Settings.asset.meta │ ├── Runtime.meta │ └── Runtime │ ├── EntityRenderer.cs │ ├── EntityRenderer.cs.meta │ ├── SortingOrderUpdater.cs │ ├── SortingOrderUpdater.cs.meta │ ├── TextureController.cs │ └── TextureController.cs.meta ├── Packages └── Spriter2UnityDX.unitypackage ├── ProjectSettings ├── AudioManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset └── TimeManager.asset └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.sln 2 | *.userprefs 3 | Temp 4 | Library 5 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 62962d9a9d33b4ee4a10cd6e6c6d6ba4 3 | folderAsset: yes 4 | timeCreated: 1429463858 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eadd26d153e534745861f0e4bf1abbad 3 | folderAsset: yes 4 | timeCreated: 1429463893 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Editor/AnimationBuilder.cs: -------------------------------------------------------------------------------- 1 | //This project is open source. Anyone can use any part of this code however they wish 2 | //Feel free to use this code in your own projects, or expand on this code 3 | //If you have any improvements to the code itself, please visit 4 | //https://github.com/Dharengo/Spriter2UnityDX and share your suggestions by creating a fork 5 | //-Dengar/Dharengo 6 | 7 | using UnityEngine; 8 | using UnityEditor; 9 | using UnityEditor.Animations; 10 | using System; 11 | using System.Collections.Generic; 12 | using Object = UnityEngine.Object; 13 | 14 | namespace Spriter2UnityDX.Animations { 15 | using Importing; 16 | //Exactly what's written on the tin 17 | public class AnimationBuilder : UnityEngine.Object { 18 | //Only one of these is made for each Entity, and these globals are the same for every 19 | //Animation that belongs to these entities 20 | private ScmlProcessingInfo ProcessingInfo; 21 | private const float inf = float.PositiveInfinity; 22 | private IDictionary> Folders; 23 | private IDictionary Transforms; 24 | private string PrefabPath; 25 | private string AnimationsPath; 26 | private Transform Root; 27 | private IDictionary OriginalClips = new Dictionary (); 28 | private IDictionary DefaultBones; 29 | private IDictionary DefaultSprites; 30 | private AnimatorController Controller; 31 | private bool ModdedController = false; 32 | 33 | public AnimationBuilder (ScmlProcessingInfo info, IDictionary> folders, 34 | IDictionary transforms, IDictionary defaultBones, 35 | IDictionary defaultSprites, 36 | string prefabPath, AnimatorController controller) { 37 | ProcessingInfo = info; Folders = folders; Transforms = transforms; PrefabPath = prefabPath; 38 | DefaultBones = defaultBones; DefaultSprites = defaultSprites; 39 | Root = Transforms ["rootTransform"]; Controller = controller; 40 | AnimationsPath = PrefabPath.Substring (0, PrefabPath.LastIndexOf ('.')) + "_Anims"; 41 | 42 | foreach (var item in GetOrigClips ()) { 43 | var clip = item as AnimationClip; 44 | if (clip != null) OriginalClips [clip.name] = clip; 45 | } 46 | } 47 | 48 | public Object[] GetOrigClips () { 49 | switch (S2USettings.GetOrCreateSettings().ImportOption) { 50 | case AnimationImportOption.NestedInPrefab : 51 | return AssetDatabase.LoadAllAssetRepresentationsAtPath(PrefabPath); 52 | case AnimationImportOption.SeparateFolder : 53 | return AssetDatabase.LoadAllAssetsAtPath(AnimationsPath); 54 | } 55 | return null; 56 | } 57 | 58 | public void Build (Animation animation, IDictionary timeLines) { 59 | var clip = new AnimationClip (); 60 | clip.name = animation.name; 61 | var pendingTransforms = new Dictionary (Transforms); //This Dictionary will shrink in size for every transform 62 | foreach (var key in animation.mainlineKeys) { //that is considered "used" 63 | var parentTimelines = new Dictionary> (); 64 | var brefs = new Queue (key.boneRefs ?? new Ref [0]); 65 | while (brefs.Count > 0) { 66 | var bref = brefs.Dequeue (); 67 | if (bref.parent < 0 || parentTimelines.ContainsKey (bref.parent)) { 68 | var timeLine = timeLines [bref.timeline]; 69 | parentTimelines [bref.id] = new List (timeLine.keys); 70 | Transform bone; 71 | if (pendingTransforms.TryGetValue (timeLine.name, out bone)) { //Skip it if it's already "used" 72 | List parentTimeline; 73 | parentTimelines.TryGetValue (bref.parent, out parentTimeline); 74 | SetCurves (bone, DefaultBones [timeLine.name], parentTimeline, timeLine, clip, animation); 75 | pendingTransforms.Remove (timeLine.name); 76 | } 77 | } 78 | else brefs.Enqueue (bref); 79 | } 80 | foreach (var sref in key.objectRefs) { 81 | var timeLine = timeLines [sref.timeline]; 82 | Transform sprite; 83 | if (pendingTransforms.TryGetValue (timeLine.name, out sprite)) { 84 | var defaultZ = sref.z_index; 85 | List parentTimeline; 86 | parentTimelines.TryGetValue (sref.parent, out parentTimeline); 87 | SetCurves (sprite, DefaultSprites [timeLine.name], parentTimeline, timeLine, clip, animation, ref defaultZ); 88 | SetAdditionalCurves (sprite, animation.mainlineKeys, timeLine, clip, defaultZ); 89 | pendingTransforms.Remove (timeLine.name); 90 | } 91 | } 92 | foreach (var kvPair in pendingTransforms) { //Disable the remaining tansforms if they are sprites and not already disabled 93 | if (DefaultSprites.ContainsKey (kvPair.Key) && kvPair.Value.gameObject.activeSelf) { 94 | var curve = new AnimationCurve (new Keyframe (0f, 0f, inf, inf)); 95 | clip.SetCurve (GetPathToChild (kvPair.Value), typeof(GameObject), "m_IsActive", curve); 96 | } 97 | } 98 | } 99 | var settings = AnimationUtility.GetAnimationClipSettings (clip); 100 | settings.stopTime = animation.length; //Set the animation's length and other settings 101 | if (animation.looping) { 102 | clip.wrapMode = WrapMode.Loop; 103 | settings.loopTime = true; 104 | } 105 | else clip.wrapMode = WrapMode.ClampForever; 106 | AnimationUtility.SetAnimationClipSettings (clip, settings); 107 | if (OriginalClips.ContainsKey (animation.name)) { //If the clip already exists, copy this clip into the old one 108 | var oldClip = OriginalClips [animation.name]; 109 | var cachedEvents = oldClip.events; 110 | EditorUtility.CopySerialized (clip, oldClip); 111 | clip = oldClip; 112 | AnimationUtility.SetAnimationEvents (clip, cachedEvents); 113 | ProcessingInfo.ModifiedAnims.Add (clip); 114 | } else { 115 | switch (S2USettings.GetOrCreateSettings().ImportOption) { 116 | case AnimationImportOption.NestedInPrefab : 117 | AssetDatabase.AddObjectToAsset (clip, PrefabPath); //Otherwise create a new one 118 | break; 119 | case AnimationImportOption.SeparateFolder : 120 | if (!AssetDatabase.IsValidFolder (AnimationsPath)) { 121 | var splitIndex = AnimationsPath.LastIndexOf ('/'); 122 | var path = AnimationsPath.Substring (0, splitIndex); 123 | var newFolder = AnimationsPath.Substring (splitIndex + 1); 124 | AssetDatabase.CreateFolder (path, newFolder); 125 | } 126 | AssetDatabase.CreateAsset (clip, string.Format ("{0}/{1}.anim", AnimationsPath, clip.name)); 127 | break; 128 | } 129 | ProcessingInfo.NewAnims.Add (clip); 130 | } 131 | if (!ArrayUtility.Contains (Controller.animationClips, clip)) { //Don't add the clip if it's already there 132 | var state = GetStateFromController (clip.name); //Find a state of the same name 133 | if (state != null) state.motion = clip; //If it exists, replace it 134 | else Controller.AddMotion (clip); //Otherwise add it as a new state 135 | if (!ModdedController) { 136 | if (!ProcessingInfo.NewControllers.Contains (Controller) && !ProcessingInfo.ModifiedControllers.Contains (Controller)) 137 | ProcessingInfo.ModifiedControllers.Add (Controller); 138 | ModdedController = true; 139 | } 140 | } 141 | } 142 | 143 | private void SetCurves (Transform child, SpatialInfo defaultInfo, List parentTimeline, TimeLine timeLine, AnimationClip clip, Animation animation) { 144 | var defZ = 0f; 145 | SetCurves (child, defaultInfo, parentTimeline, timeLine, clip, animation, ref defZ); 146 | } 147 | 148 | private void SetCurves (Transform child, SpatialInfo defaultInfo, List parentTimeline, TimeLine timeLine, AnimationClip clip, Animation animation, ref float defaultZ) { 149 | var childPath = GetPathToChild (child); 150 | foreach (var kvPair in GetCurves (timeLine, defaultInfo, parentTimeline)) { //Makes sure that curves are only added for properties 151 | switch (kvPair.Key) { //that actually mutate in the animation 152 | case ChangedValues.PositionX : 153 | SetKeys (kvPair.Value, timeLine, x => x.x, animation); 154 | clip.SetCurve (childPath, typeof(Transform), "localPosition.x", kvPair.Value); 155 | break; 156 | case ChangedValues.PositionY : 157 | SetKeys (kvPair.Value, timeLine, x => x.y, animation); 158 | clip.SetCurve (childPath, typeof(Transform), "localPosition.y", kvPair.Value); 159 | break; 160 | case ChangedValues.PositionZ : 161 | kvPair.Value.AddKey (0f, defaultZ); 162 | clip.SetCurve (childPath, typeof(Transform), "localPosition.z", kvPair.Value); 163 | defaultZ = inf; //Lets the next method know this value has been set 164 | break; 165 | case ChangedValues.RotationZ : 166 | SetKeys (kvPair.Value, timeLine, x => x.rotation.z, animation); 167 | clip.SetCurve (childPath, typeof(Transform), "localRotation.z", kvPair.Value); 168 | break; 169 | case ChangedValues.RotationW : 170 | SetKeys (kvPair.Value, timeLine, x => x.rotation.w, animation); 171 | clip.SetCurve (childPath, typeof(Transform), "localRotation.w", kvPair.Value); 172 | break; 173 | case ChangedValues.ScaleX : 174 | SetKeys (kvPair.Value, timeLine, x => x.scale_x, animation); 175 | clip.SetCurve (childPath, typeof(Transform), "localScale.x", kvPair.Value); 176 | break; 177 | case ChangedValues.ScaleY : 178 | SetKeys (kvPair.Value, timeLine, x => x.scale_y, animation); 179 | clip.SetCurve (childPath, typeof(Transform), "localScale.y", kvPair.Value); 180 | break; 181 | case ChangedValues.ScaleZ : 182 | kvPair.Value.AddKey (0f, 1f); 183 | clip.SetCurve (childPath, typeof(Transform), "localScale.z", kvPair.Value); 184 | break; 185 | case ChangedValues.Alpha : 186 | SetKeys (kvPair.Value, timeLine, x => x.a, animation); 187 | clip.SetCurve (childPath, typeof(SpriteRenderer), "m_Color.a", kvPair.Value); 188 | break; 189 | case ChangedValues.Sprite : 190 | if (ScmlImportOptions.options != null && ScmlImportOptions.options.useUnitySpriteSwapping) 191 | { 192 | SetSpriteSwapKeys(child, timeLine, clip, animation); 193 | } 194 | else { 195 | var swapper = child.GetComponent(); 196 | if (swapper == null) 197 | { //Add a Texture Controller if one doesn't already exist 198 | swapper = child.gameObject.AddComponent(); 199 | var info = (SpriteInfo)defaultInfo; 200 | swapper.Sprites = new[] { Folders[info.folder][info.file] }; 201 | } 202 | SetKeys(kvPair.Value, timeLine, ref swapper.Sprites, animation); 203 | clip.SetCurve(childPath, typeof(TextureController), "DisplayedSprite", kvPair.Value); 204 | } 205 | break; 206 | } 207 | } 208 | clip.EnsureQuaternionContinuity (); 209 | } 210 | 211 | //This is for curves that are tracked slightly differently from regular curves: Active curve and Z-index curve 212 | private void SetAdditionalCurves (Transform child, MainLineKey[] keys, TimeLine timeLine, AnimationClip clip, float defaultZ) { 213 | var positionChanged = false; 214 | var kfsZ = new List (); 215 | var changedZ = false; 216 | var active = child.gameObject.activeSelf; //If the sprite or bone isn't present in the mainline, 217 | var kfsActive = new List (); //Disable the GameObject if it isn't already disabled 218 | var childPath = GetPathToChild (child); 219 | foreach (var key in keys) { //If it is present, enable the GameObject if it isn't already enabled 220 | var mref = ArrayUtility.Find (key.objectRefs, x => x.timeline == timeLine.id); 221 | if (mref != null) { 222 | if (defaultZ == inf) { 223 | defaultZ = mref.z_index; 224 | positionChanged = true; 225 | } 226 | if (!changedZ && mref.z_index != defaultZ) { 227 | changedZ = true; 228 | if (key.time > 0) kfsZ.Add (new Keyframe (0f, defaultZ, inf, inf)); 229 | } 230 | if (changedZ) 231 | kfsZ.Add (new Keyframe (key.time, mref.z_index, inf, inf)); 232 | if (!active) { 233 | if (kfsActive.Count <= 0 && key.time > 0) kfsActive.Add (new Keyframe (0f, 0f, inf, inf)); 234 | kfsActive.Add (new Keyframe (key.time, 1f, inf, inf)); 235 | active = true; 236 | } 237 | } 238 | else if (active) { 239 | if (kfsActive.Count <= 0 && key.time > 0) kfsActive.Add (new Keyframe (0f, 1f, inf, inf)); 240 | kfsActive.Add (new Keyframe (key.time, 0f, inf, inf)); 241 | active = false; 242 | } 243 | } //Only add these curves if there is actually a mutation 244 | if (kfsZ.Count > 0) { 245 | clip.SetCurve (childPath, typeof(Transform), "localPosition.z", new AnimationCurve (kfsZ.ToArray ())); 246 | if (!positionChanged) { 247 | var info = timeLine.keys [0].info; //If these curves don't actually exist, add some empty ones 248 | clip.SetCurve (childPath, typeof(Transform), "localPosition.x", new AnimationCurve (new Keyframe (0f, info.x))); 249 | clip.SetCurve (childPath, typeof(Transform), "localPosition.y", new AnimationCurve (new Keyframe (0f, info.y))); 250 | } 251 | } 252 | if (kfsActive.Count > 0) clip.SetCurve (childPath, typeof(GameObject), "m_IsActive", new AnimationCurve (kfsActive.ToArray ())); 253 | } 254 | 255 | private void SetKeys (AnimationCurve curve, TimeLine timeLine, Func infoValue, Animation animation) { 256 | foreach (var key in timeLine.keys) { //Create a keyframe for every key on its personal TimeLine 257 | curve.AddKey (key.time, infoValue (key.info)); 258 | } 259 | var lastIndex = (animation.looping) ? 0 : timeLine.keys.Length - 1; //Depending on the loop type, duplicate the first or last frame 260 | curve.AddKey (animation.length, infoValue (timeLine.keys [lastIndex].info)); //At the end of the curve 261 | } 262 | 263 | private void SetKeys (AnimationCurve curve, TimeLine timeLine, ref Sprite[] sprites, Animation animation) { 264 | foreach (var key in timeLine.keys) { //Create a key for every key on its personal TimeLine 265 | var info = (SpriteInfo)key.info; 266 | curve.AddKey (new Keyframe (key.time, GetIndexOrAdd (ref sprites, Folders [info.folder] [info.file]), inf, inf)); 267 | } //InTangent and OutTangent are set to Infinity to make transitions instant instead of gradual 268 | var lastIndex = (animation.looping) ? 0 : timeLine.keys.Length - 1; 269 | var lastInfo = (SpriteInfo)timeLine.keys [lastIndex].info; 270 | curve.AddKey (new Keyframe (animation.length, GetIndexOrAdd (ref sprites, Folders [lastInfo.folder] [lastInfo.file]), inf, inf)); 271 | } 272 | 273 | void SetSpriteSwapKeys(Transform child, TimeLine timeLine, AnimationClip clip, Animation animation) 274 | { 275 | // Create ObjectReferenceCurve for swapping sprites. This curve will save data in object form instead of floats like regular AnimationCurve. 276 | var keyframes = new List(); 277 | foreach (var key in timeLine.keys) 278 | { 279 | var info = (SpriteInfo)key.info; 280 | var sprite = Folders[info.folder][info.file]; 281 | keyframes.Add(new ObjectReferenceKeyframe { time = key.time, value = sprite }); 282 | } 283 | var lastIndex = (animation.looping) ? 0 : timeLine.keys.Length - 1; 284 | var lastInfo = (SpriteInfo)timeLine.keys[lastIndex].info; 285 | keyframes.Add(new ObjectReferenceKeyframe { time = animation.length, value = Folders[lastInfo.folder][lastInfo.file] }); 286 | AnimationUtility.SetObjectReferenceCurve(clip, new EditorCurveBinding { path = GetPathToChild(child), propertyName = "m_Sprite", type = typeof(SpriteRenderer) }, keyframes.ToArray()); 287 | } 288 | 289 | private int GetIndexOrAdd (ref Sprite[] sprites, Sprite sprite) { 290 | var index = ArrayUtility.IndexOf (sprites, sprite); //If the array already contains the sprite, return index 291 | if (index < 0) { //Otherwise, add sprite to array, then return index 292 | ArrayUtility.Add (ref sprites, sprite); 293 | index = ArrayUtility.IndexOf (sprites, sprite); 294 | } 295 | return index; 296 | } 297 | 298 | private AnimatorState GetStateFromController (string clipName) { 299 | foreach (var layer in Controller.layers) { 300 | var state = GetStateFromMachine (layer.stateMachine, clipName); 301 | if (state != null) return state; 302 | } 303 | return null; 304 | } 305 | 306 | private AnimatorState GetStateFromMachine (AnimatorStateMachine machine, string clipName) { 307 | foreach (var state in machine.states) { 308 | if (state.state.name == clipName) return state.state; 309 | } 310 | foreach (var cmachine in machine.stateMachines) { 311 | var state = GetStateFromMachine (cmachine.stateMachine, clipName); 312 | if (state!= null) return state; 313 | } 314 | return null; 315 | } 316 | 317 | private IDictionary ChildPaths = new Dictionary (); 318 | private string GetPathToChild (Transform child) { //Caches the relative paths to children so they only have to be calculated once 319 | string path; 320 | if (ChildPaths.TryGetValue (child, out path)) return path; 321 | else return ChildPaths [child] = AnimationUtility.CalculateTransformPath (child, Root); 322 | } 323 | 324 | private enum ChangedValues { None, Sprite, PositionX, PositionY, PositionZ, RotationZ, RotationW, ScaleX, ScaleY, ScaleZ, Alpha } 325 | private IDictionary GetCurves (TimeLine timeLine, SpatialInfo defaultInfo, List parentTimeline) { 326 | var rv = new Dictionary (); //This method checks every animatable property for changes 327 | foreach (var key in timeLine.keys) { //And creates a curve for that property if changes are detected 328 | var info = key.info; 329 | if (!info.processed) { 330 | SpatialInfo parentInfo = null; 331 | if (parentTimeline != null) { 332 | var pKey = parentTimeline.Find (x => x.time == key.time); 333 | if (pKey == null) { 334 | var pKeys = parentTimeline.FindAll (x => x.time < key.time); 335 | pKeys.Sort ((x, y) => x.time.CompareTo (y.time) * -1); 336 | if (pKeys.Count > 0) pKey = pKeys [0]; 337 | else { 338 | pKeys = parentTimeline.FindAll (x => x.time > key.time); 339 | pKeys.Sort ((x, y) => x.time.CompareTo (y.time)); 340 | if (pKeys.Count > 0) pKey = pKeys [0]; 341 | } 342 | } 343 | if (pKey != null) parentInfo = pKey.info; 344 | } 345 | info.Process (parentInfo); 346 | } 347 | if (!rv.ContainsKey (ChangedValues.PositionX) && (defaultInfo.x != info.x || defaultInfo.y != info.y)) { 348 | rv [ChangedValues.PositionX] = new AnimationCurve (); //There will be irregular behaviour if curves aren't added for all members 349 | rv [ChangedValues.PositionY] = new AnimationCurve (); //in a group, so when one is set, the others have to be set as well 350 | rv [ChangedValues.PositionZ] = new AnimationCurve (); 351 | } 352 | if (!rv.ContainsKey (ChangedValues.RotationZ) && (defaultInfo.rotation.z != info.rotation.z || defaultInfo.rotation.w != info.rotation.w)) { 353 | rv [ChangedValues.RotationZ] = new AnimationCurve ();//x and y not necessary since the default of 0 is fine 354 | rv [ChangedValues.RotationW] = new AnimationCurve (); 355 | } 356 | if (!rv.ContainsKey (ChangedValues.ScaleX) && (defaultInfo.scale_x != info.scale_x || defaultInfo.scale_y != info.scale_y)) { 357 | rv [ChangedValues.ScaleX] = new AnimationCurve (); 358 | rv [ChangedValues.ScaleY] = new AnimationCurve (); 359 | rv [ChangedValues.ScaleZ] = new AnimationCurve (); 360 | } 361 | if (!rv.ContainsKey (ChangedValues.Alpha) && defaultInfo.a != info.a) 362 | rv [ChangedValues.Alpha] = new AnimationCurve (); 363 | var scontrol = defaultInfo as SpriteInfo; 364 | if (scontrol != null && !rv.ContainsKey (ChangedValues.Sprite)) { 365 | var sinfo = (SpriteInfo)info; 366 | if (scontrol.file != sinfo.file || scontrol.folder != sinfo.folder) 367 | rv [ChangedValues.Sprite] = new AnimationCurve (); 368 | } 369 | } 370 | return rv; 371 | } 372 | } 373 | } 374 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Editor/AnimationBuilder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 18d03050f3ba748db97fac7f4d868dbb 3 | timeCreated: 1429822737 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Editor/CustomEditors.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using UnityEditorInternal; 4 | using System.Reflection; 5 | using System.Collections; 6 | 7 | namespace Spriter2UnityDX.Editors { 8 | [CustomEditor (typeof(EntityRenderer)), CanEditMultipleObjects] 9 | public class ERenderEdit : Editor { 10 | private EntityRenderer renderer; 11 | private string[] layerNames; 12 | 13 | private void OnEnable () { 14 | renderer = (EntityRenderer)target; 15 | layerNames = GetSortingLayerNames (); 16 | } 17 | 18 | // Get the sorting layer names 19 | private string[] GetSortingLayerNames() { 20 | var sortingLayers = typeof(InternalEditorUtility).GetProperty("sortingLayerNames", BindingFlags.Static | BindingFlags.NonPublic); 21 | return (string[])sortingLayers.GetValue(null, new object[0]); 22 | } 23 | 24 | public override void OnInspectorGUI () 25 | { 26 | EditorGUI.BeginChangeCheck(); 27 | var color = EditorGUILayout.ColorField ("Color", renderer.Color); 28 | if (color != renderer.Color) {renderer.Color = color;} 29 | var material = (Material)EditorGUILayout.ObjectField ("Material", renderer.Material, typeof(Material), false); 30 | if (material != renderer.Material) {renderer.Material = material;} 31 | var sortIndex = EditorGUILayout.Popup ("Sorting Layer", GetIndex (renderer.SortingLayerName), layerNames, GUILayout.ExpandWidth (true)); 32 | if (layerNames [sortIndex] != renderer.SortingLayerName) {renderer.SortingLayerName = layerNames[sortIndex];} 33 | var sortingOrder = EditorGUILayout.IntField ("Order In Layer", renderer.SortingOrder); 34 | if (sortingOrder != renderer.SortingOrder) {renderer.SortingOrder = sortingOrder;} 35 | var applyZ = EditorGUILayout.Toggle ("Apply Spriter Z Order", renderer.ApplySpriterZOrder); 36 | if (applyZ != renderer.ApplySpriterZOrder) {renderer.ApplySpriterZOrder = applyZ;} 37 | if (EditorGUI.EndChangeCheck()) 38 | { 39 | EditorUtility.SetDirty(renderer); 40 | } 41 | } 42 | 43 | private int GetIndex (string layerName) { 44 | var index = ArrayUtility.IndexOf (layerNames, layerName); 45 | if (index < 0) index = 0; 46 | return index; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Editor/CustomEditors.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d93c3b8cda584f8584c1a6379b57f26 3 | timeCreated: 1430385999 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Editor/PrefabBuilder.cs: -------------------------------------------------------------------------------- 1 | //This project is open source. Anyone can use any part of this code however they wish 2 | //Feel free to use this code in your own projects, or expand on this code 3 | //If you have any improvements to the code itself, please visit 4 | //https://github.com/Dharengo/Spriter2UnityDX and share your suggestions by creating a fork 5 | //-Dengar/Dharengo 6 | 7 | using UnityEngine; 8 | using UnityEditor; 9 | using UnityEditor.Animations; 10 | using System; 11 | using System.IO; 12 | using System.Collections.Generic; 13 | 14 | namespace Spriter2UnityDX.Prefabs { 15 | using Importing; using Animations; 16 | //Exactly what's written on the tin 17 | public class PrefabBuilder : UnityEngine.Object { 18 | private ScmlProcessingInfo ProcessingInfo; 19 | public PrefabBuilder (ScmlProcessingInfo info) { 20 | ProcessingInfo = info; 21 | } 22 | 23 | public bool Build (ScmlObject obj, string scmlPath) { 24 | //The process begins by loading up all the textures 25 | var success = true; 26 | var directory = Path.GetDirectoryName (scmlPath); 27 | var folders = new Dictionary> (); //I find these slightly more useful than Lists because 28 | foreach (var folder in obj.folders ) { //you can be 100% sure that the ids match 29 | var files = folders [folder.id] = new Dictionary (); //And items can be added in any order 30 | foreach (var file in folder.files) { 31 | var path = string.Format ("{0}/{1}", directory, file.name); 32 | files [file.id] = GetSpriteAtPath (path, file, ref success); 33 | } 34 | } //The process ends here if any of the textures need to have their settings altered 35 | if (!success) return false; //The process will be reattempted after the next import cycle 36 | foreach (var entity in obj.entities) { //Now begins the real prefab build process 37 | var prefabPath = string.Format ("{0}/{1}.prefab", directory, entity.name); 38 | var prefab = (GameObject)AssetDatabase.LoadAssetAtPath (prefabPath, typeof(GameObject)); 39 | GameObject instance; 40 | if (prefab == null) { //Creates an empty prefab if one doesn't already exists 41 | instance = new GameObject (entity.name); 42 | prefab = PrefabUtility.SaveAsPrefabAssetAndConnect (instance, prefabPath, InteractionMode.AutomatedAction); 43 | ProcessingInfo.NewPrefabs.Add (prefab); 44 | } 45 | else { 46 | instance = (GameObject)PrefabUtility.InstantiatePrefab (prefab); //instantiates the prefab if it does exist 47 | ProcessingInfo.ModifiedPrefabs.Add (prefab); 48 | } 49 | try { 50 | TryBuild (entity, prefab, instance, directory, prefabPath, folders); 51 | } 52 | catch (Exception e) { 53 | DestroyImmediate (instance); 54 | Debug.LogErrorFormat("Unable to build a prefab for '{0}'. Reason: {1}", entity.name, e); 55 | } 56 | } 57 | return success; 58 | } 59 | 60 | private void TryBuild (Entity entity, GameObject prefab, GameObject instance, string directory, string prefabPath, IDictionary> folders) { 61 | var controllerPath = string.Format ("{0}/{1}.controller", directory, entity.name); 62 | var animator = instance.GetComponent (); //Fetches the prefab's Animator 63 | if (animator == null) animator = instance.AddComponent (); //Or creates one if it doesn't exist 64 | AnimatorController controller = null; 65 | if (animator.runtimeAnimatorController != null) { //The controller we use is hopefully the controller attached to the animator 66 | controller = animator.runtimeAnimatorController as AnimatorController ?? //Or the one that's referenced by an OverrideController 67 | (AnimatorController)((AnimatorOverrideController)animator.runtimeAnimatorController).runtimeAnimatorController; 68 | } 69 | if (controller == null) { //Otherwise we have to check the AssetDatabase for our controller 70 | controller = (AnimatorController)AssetDatabase.LoadAssetAtPath (controllerPath, typeof(AnimatorController)); 71 | if (controller == null) { 72 | controller = AnimatorController.CreateAnimatorControllerAtPath (controllerPath); //Or create a new one if it doesn't exist. 73 | ProcessingInfo.NewControllers.Add (controller); 74 | } 75 | animator.runtimeAnimatorController = controller; 76 | } 77 | var transforms = new Dictionary (); //All of the bones and sprites, identified by TimeLine.name, because those are truly unique 78 | transforms ["rootTransform"] = instance.transform; //The root GameObject needs to be part of this hierarchy as well 79 | var defaultBones = new Dictionary (); //These are basically the object states on the first frame of the first animation 80 | var defaultSprites = new Dictionary (); //They are used as control values in determining whether something has changed 81 | var animBuilder = new AnimationBuilder (ProcessingInfo, folders, transforms, defaultBones, defaultSprites, prefabPath, controller); 82 | var firstAnim = true; //The prefab's graphic will be determined by the first frame of the first animation 83 | foreach (var animation in entity.animations) { 84 | var timeLines = new Dictionary (); 85 | foreach (var timeLine in animation.timelines) //TimeLines hold all the critical data such as positioning and graphics used 86 | timeLines [timeLine.id] = timeLine; 87 | foreach (var key in animation.mainlineKeys) { 88 | var parents = new Dictionary (); //Parents are referenced by different IDs V_V 89 | parents [-1] = "rootTransform"; //This is where "-1 == no parent" comes in handy 90 | var boneRefs = new Queue (key.boneRefs ?? new Ref[0]); 91 | while (boneRefs.Count > 0) { 92 | var bone = boneRefs.Dequeue (); 93 | var timeLine = timeLines [bone.timeline]; 94 | parents [bone.id] = timeLine.name; 95 | if (!transforms.ContainsKey (timeLine.name)) { //We only need to go through this once, so ignore it if it's already in the dict 96 | if (parents.ContainsKey (bone.parent)) { //If the parent cannot be found, it will probably be found later, so save it 97 | var parentID = parents [bone.parent]; 98 | var parent = transforms [parentID]; 99 | var child = parent.Find (timeLine.name); //Try to find the child transform if it exists 100 | if (child == null) { //Or create a new one 101 | child = new GameObject (timeLine.name).transform; 102 | child.SetParent (parent); 103 | } 104 | transforms [timeLine.name] = child; 105 | var spatialInfo = defaultBones [timeLine.name] = ArrayUtility.Find (timeLine.keys, x => x.id == bone.key).info; 106 | if (!spatialInfo.processed) { 107 | SpatialInfo parentInfo; 108 | defaultBones.TryGetValue (parentID, out parentInfo); 109 | spatialInfo.Process (parentInfo); 110 | } 111 | child.localPosition = new Vector3 (spatialInfo.x, spatialInfo.y, 0f); 112 | child.localRotation = spatialInfo.rotation; 113 | child.localScale = new Vector3 (spatialInfo.scale_x, spatialInfo.scale_y, 1f); 114 | } 115 | else boneRefs.Enqueue (bone); 116 | } 117 | } 118 | foreach (var oref in key.objectRefs) { 119 | var timeLine = timeLines [oref.timeline]; 120 | if (!transforms.ContainsKey (timeLine.name)) { //Same as above 121 | var parentID = parents [oref.parent]; 122 | var parent = transforms [parentID]; 123 | var child = parent.Find (timeLine.name); 124 | if (child == null) { 125 | child = new GameObject (timeLine.name).transform; 126 | child.SetParent (parent); 127 | } 128 | transforms [timeLine.name] = child; 129 | var swapper = child.GetComponent (); //Destroy the Sprite Swapper, we'll make a new one later 130 | if (swapper != null) DestroyImmediate (swapper); 131 | var renderer = child.GetComponent (); //Get or create a Sprite Renderer 132 | if (renderer == null) renderer = child.gameObject.AddComponent (); 133 | var spriteInfo = defaultSprites [timeLine.name] = (SpriteInfo)ArrayUtility.Find (timeLine.keys, x => x.id == 0).info; 134 | renderer.sprite = folders [spriteInfo.folder] [spriteInfo.file]; 135 | if (!spriteInfo.processed) { 136 | SpatialInfo parentInfo; 137 | defaultBones.TryGetValue (parentID, out parentInfo); 138 | spriteInfo.Process (parentInfo); 139 | } 140 | child.localPosition = new Vector3 (spriteInfo.x, spriteInfo.y, oref.z_index); //Z-index helps determine draw order 141 | child.localEulerAngles = new Vector3 (0f, 0f, spriteInfo.angle); //The reason I don't use layers or layer orders is because 142 | child.localScale = new Vector3 (spriteInfo.scale_x, spriteInfo.scale_y, 1f); //There tend to be a LOT of body parts, it's better to treat 143 | var color = renderer.color; //The entity as a single sprite for layer sorting purposes. 144 | color.a = spriteInfo.a; 145 | renderer.color = color; 146 | if (!firstAnim) child.gameObject.SetActive (false); //Disable the GameObject if this isn't the first frame of the first animation 147 | } 148 | } 149 | if (firstAnim) firstAnim = false; 150 | } 151 | try { 152 | animBuilder.Build (animation, timeLines); //Builds the currently processed AnimationClip, see AnimationBuilder for more info 153 | } 154 | catch (Exception e) { 155 | Debug.LogErrorFormat ("Unable to build animation '{0}' for '{1}', reason: {2}", animation.name, entity.name, e); 156 | } 157 | } 158 | if (instance.GetComponent () == null) instance.AddComponent (); //Adds an EntityRenderer if one is not already present 159 | PrefabUtility.SaveAsPrefabAssetAndConnect (instance, prefabPath, InteractionMode.AutomatedAction); 160 | DestroyImmediate (instance); //Apply the instance's changes to the prefab, then destroy the instance. 161 | } 162 | 163 | private IList InvalidImporters = new List (); //Importers in this list have already been processed and don't need to be processed again 164 | private Sprite GetSpriteAtPath (string path, File file, ref bool success) { 165 | var importer = TextureImporter.GetAtPath (path) as TextureImporter; 166 | if (importer != null) { //If no TextureImporter exists, there's no texture to be found 167 | if ((importer.textureType != TextureImporterType.Sprite || importer.spritePivot.x != file.pivot_x 168 | || importer.spritePivot.y != file.pivot_y || (ScmlImportOptions.options != null && importer.spritePixelsPerUnit != ScmlImportOptions.options.pixelsPerUnit)) && !InvalidImporters.Contains (importer)) { 169 | if (success) success = false; //If the texture type isn't Sprite, or the pivot isn't set properly, 170 | var settings = new TextureImporterSettings (); //set the texture type and pivot 171 | importer.ReadTextureSettings (settings); //and make success false so the process can abort 172 | settings.ApplyTextureType (TextureImporterType.Sprite); //after all the textures have been processed 173 | settings.spriteAlignment = (int)SpriteAlignment.Custom; 174 | settings.spritePivot = new Vector2 (file.pivot_x, file.pivot_y); 175 | if(ScmlImportOptions.options != null) 176 | { 177 | settings.spritePixelsPerUnit = ScmlImportOptions.options.pixelsPerUnit; 178 | } 179 | importer.SetTextureSettings (settings); 180 | importer.SaveAndReimport (); 181 | InvalidImporters.Add (importer); 182 | } 183 | } 184 | else Debug.LogErrorFormat ("Error: No Sprite was found at {0}", path); 185 | return (Sprite)AssetDatabase.LoadAssetAtPath (path, typeof(Sprite)); 186 | } 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Editor/PrefabBuilder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7183491dbcd0d4389b776cba3ac0c062 3 | timeCreated: 1429520612 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Editor/S2USettings.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System.Collections; 4 | 5 | //Customizable settings for the importer 6 | namespace Spriter2UnityDX { 7 | internal static class S2USettingsIMGUIRegister 8 | { 9 | [SettingsProvider] 10 | public static SettingsProvider CreateS2USettingsProvider() 11 | { 12 | var provider = new SettingsProvider("Project/Spriter2UnityDX", SettingsScope.Project) 13 | { 14 | guiHandler = (searchContext) => 15 | { 16 | var settings = S2USettings.GetSerializedSettings(); 17 | var label = new GUIContent("Animation Import Style", 18 | "By default, animations are nested into the generated prefab. Change this option to instead place animations into a separate folder."); 19 | EditorGUILayout.PropertyField(settings.FindProperty("importOption"), label); 20 | settings.ApplyModifiedProperties(); 21 | }, 22 | }; 23 | 24 | return provider; 25 | } 26 | } 27 | 28 | public class S2USettings : ScriptableObject 29 | { 30 | private const string settingsPath = "Assets/Spriter2UnityDX/Editor/Settings.asset"; 31 | 32 | [SerializeField] 33 | private AnimationImportOption importOption; 34 | 35 | internal AnimationImportOption ImportOption { get { return importOption; } } 36 | 37 | internal static S2USettings GetOrCreateSettings() 38 | { 39 | var settings = AssetDatabase.LoadAssetAtPath(settingsPath); 40 | if (settings == null) 41 | { 42 | settings = ScriptableObject.CreateInstance(); 43 | settings.importOption = AnimationImportOption.NestedInPrefab; 44 | AssetDatabase.CreateAsset(settings, settingsPath); 45 | AssetDatabase.SaveAssets(); 46 | } 47 | return settings; 48 | } 49 | 50 | internal static SerializedObject GetSerializedSettings() 51 | { 52 | return new SerializedObject(GetOrCreateSettings()); 53 | } 54 | } 55 | 56 | public enum AnimationImportOption : byte { NestedInPrefab, SeparateFolder } 57 | } 58 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Editor/S2USettings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f361e2f9624e406e9f836e8793ee5b8 3 | timeCreated: 1443291700 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Editor/ScmlImportOptions.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | using System.Collections; 4 | 5 | namespace Spriter2UnityDX.Importing 6 | { 7 | public class ScmlImportOptionsWindow : EditorWindow 8 | { 9 | public System.Action OnClose; 10 | 11 | void OnEnable() 12 | { 13 | titleContent = new GUIContent("Import Options"); 14 | } 15 | 16 | void OnGUI() 17 | { 18 | ScmlImportOptions.options.pixelsPerUnit = EditorGUILayout.FloatField("Pixels per unit", ScmlImportOptions.options.pixelsPerUnit); 19 | ScmlImportOptions.options.useUnitySpriteSwapping = EditorGUILayout.Toggle("Unity's native sprite swapping", ScmlImportOptions.options.useUnitySpriteSwapping); 20 | if(GUILayout.Button("Done")) 21 | { 22 | Close(); 23 | } 24 | } 25 | 26 | void OnDestroy() 27 | { 28 | OnClose(); 29 | } 30 | } 31 | 32 | public class ScmlImportOptions 33 | { 34 | public static ScmlImportOptions options = null; 35 | 36 | public float pixelsPerUnit = 100f; 37 | 38 | public bool useUnitySpriteSwapping; 39 | } 40 | } -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Editor/ScmlPostProcessor.cs: -------------------------------------------------------------------------------- 1 | //This project is open source. Anyone can use any part of this code however they wish 2 | //Feel free to use this code in your own projects, or expand on this code 3 | //If you have any improvements to the code itself, please visit 4 | //https://github.com/Dharengo/Spriter2UnityDX and share your suggestions by creating a fork 5 | //-Dengar/Dharengo 6 | 7 | using UnityEngine; 8 | using UnityEditor; 9 | using UnityEditor.Animations; 10 | using System.IO; 11 | using System.Xml.Serialization; 12 | using System.Collections.Generic; 13 | 14 | namespace Spriter2UnityDX.PostProcessing { 15 | using Importing; using Prefabs; 16 | //Detects when a .scml file has been imported, then begins the process to create the prefab 17 | public class ScmlPostProcessor : AssetPostprocessor { 18 | private static IList cachedPaths = new List (); 19 | 20 | //Called after an import, detects if imported files end in .scml 21 | private static void OnPostprocessAllAssets (string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { 22 | var filesToProcess = new List (); 23 | bool optionsNeedUpdated = false; 24 | foreach (var path in importedAssets) 25 | { 26 | if (path.EndsWith(".scml") && !path.Contains("autosave")) 27 | { 28 | filesToProcess.Add(path); 29 | if(!cachedPaths.Contains(path)) 30 | { 31 | optionsNeedUpdated = true; 32 | } 33 | } 34 | } 35 | foreach (var path in cachedPaths) { //Are there any incomplete processes from the last import cycle? 36 | if (!filesToProcess.Contains (path)) 37 | filesToProcess.Add (path); 38 | } 39 | cachedPaths.Clear (); 40 | if (filesToProcess.Count > 0) 41 | { 42 | if(optionsNeedUpdated || ScmlImportOptions.options == null) 43 | { 44 | ScmlImportOptionsWindow optionsWindow = EditorWindow.GetWindow(); 45 | ScmlImportOptions.options = new ScmlImportOptions(); 46 | optionsWindow.OnClose += () => ProcessFiles(filesToProcess); 47 | } 48 | else 49 | { 50 | ProcessFiles(filesToProcess); 51 | } 52 | } 53 | 54 | } 55 | 56 | private static void ProcessFiles (IList paths) { 57 | var info = new ScmlProcessingInfo (); 58 | var builder = new PrefabBuilder (info); 59 | foreach (var path in paths) 60 | if (!builder.Build (Deserialize (path), path)) //Process will fail if texture import settings need to be updated 61 | cachedPaths.Add (path); //Failed processes will be saved and re-attempted during the next import cycle 62 | AssetDatabase.Refresh (); 63 | AssetDatabase.SaveAssets (); 64 | PostProcess (info); 65 | } 66 | 67 | private static ScmlObject Deserialize (string path) { 68 | var serializer = new XmlSerializer (typeof(ScmlObject)); 69 | using (var reader = new StreamReader (path)) 70 | return (ScmlObject)serializer.Deserialize (reader); 71 | } 72 | 73 | private static void PostProcess (ScmlProcessingInfo info) { 74 | //You can put your own code or references to your own code here 75 | //If you want to do any work on these assets 76 | } 77 | } 78 | } 79 | 80 | namespace Spriter2UnityDX { 81 | public class ScmlProcessingInfo { 82 | public List NewPrefabs { get; set; } 83 | public List ModifiedPrefabs { get; set; } 84 | public List NewAnims { get; set; } 85 | public List ModifiedAnims { get; set; } 86 | public List NewControllers { get; set; } 87 | public List ModifiedControllers { get; set; } 88 | public ScmlProcessingInfo () { 89 | NewPrefabs = new List (); ModifiedPrefabs = new List (); 90 | NewAnims = new List (); ModifiedAnims = new List (); 91 | NewControllers = new List (); ModifiedControllers = new List (); 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Editor/ScmlPostProcessor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ab666dda915a4e739f1ea9e63db8018 3 | timeCreated: 1429464261 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Editor/ScmlSupport.cs: -------------------------------------------------------------------------------- 1 | //This project is open source. Anyone can use any part of this code however they wish 2 | //Feel free to use this code in your own projects, or expand on this code 3 | //If you have any improvements to the code itself, please visit 4 | //https://github.com/Dharengo/Spriter2UnityDX and share your suggestions by creating a fork 5 | //-Dengar/Dharengo 6 | 7 | using UnityEngine; 8 | using System; 9 | using System.Xml.Serialization; 10 | 11 | //All of these classes are containers for the data that is read from the .scml file 12 | //It is directly deserialized into these classes, although some individual values are 13 | //modified into a format that can be used by Unity 14 | namespace Spriter2UnityDX.Importing { 15 | [XmlRoot ("spriter_data")] 16 | public class ScmlObject { //Master class that holds all the other data 17 | [XmlElement ("folder")] public Folder[] folders { get; set; } // tags 18 | [XmlElement ("entity")] public Entity[] entities { get; set; } // tags 19 | } 20 | 21 | public class Folder : ScmlElement { 22 | [XmlAttribute] public string name { get; set; } 23 | [XmlElement ("file")] public File[] files { get; set; } // tags 24 | } 25 | 26 | public class File : ScmlElement { 27 | public File () {pivot_x=0f; pivot_y=1f;} 28 | [XmlAttribute] public string name { get; set; } 29 | [XmlAttribute] public float pivot_x { get; set; } 30 | [XmlAttribute] public float pivot_y { get; set; } 31 | //(engine specific type) fileReference; 32 | // a reference to the image store in this file 33 | //Dengar.NOTE: the above comments are an artifact from the pseudocode that these classes are based on 34 | //I don't use the 'fileReference' variable because I access everything a bit differently 35 | } 36 | 37 | public class Entity : ScmlElement { 38 | [XmlAttribute] public string name { get; set; } 39 | [XmlElement ("character_map")] public CharacterMap[] characterMaps { get; set; } // tags 40 | [XmlElement ("animation")] public Animation[] animations { get; set; } // tags 41 | } 42 | 43 | public class CharacterMap : ScmlElement { 44 | [XmlAttribute] public string name { get; set; } 45 | [XmlElement ("map")] public MapInstruction[] maps { get; set; } // tags 46 | } 47 | 48 | public class MapInstruction { 49 | public MapInstruction () {target_folder=-1; target_file=-1;} 50 | [XmlAttribute] public int folder { get; set; } 51 | [XmlAttribute] public int file { get; set; } 52 | [XmlAttribute] public int target_folder { get; set; } 53 | [XmlAttribute] public int target_file { get; set; } 54 | } 55 | 56 | public class Animation : ScmlElement { 57 | public Animation () {looping=true;} 58 | [XmlAttribute] public string name { get; set; } 59 | private float _length; 60 | [XmlAttribute] public float length { 61 | get { return _length; } 62 | set { _length = value * 0.001f; } 63 | } 64 | [XmlAttribute] public bool looping { get; set; } // enum : NO_LOOPING,LOOPING //Dengar.NOTE: the actual values are true and false, so it's a bool 65 | [XmlArray ("mainline"), XmlArrayItem ("key")] 66 | public MainLineKey[] mainlineKeys { get; set; } // tags within a single tag 67 | [XmlElement ("timeline")] public TimeLine[] timelines { get; set; } // tags 68 | } 69 | 70 | public class MainLineKey : ScmlElement { 71 | public MainLineKey () {time=0;} 72 | private float _time; 73 | [XmlAttribute] public float time { //Dengar.NOTE: In Spriter, Time is measured in milliseconds 74 | get { return _time; } 75 | set { _time = value * 0.001f; } //Dengar.NOTE: In Unity, it is measured in seconds instead, so we need to translate that 76 | } 77 | [XmlElement ("bone_ref")] public Ref[] boneRefs { get; set; } // tags 78 | [XmlElement ("object_ref")] public Ref[] objectRefs { get; set; } // tags 79 | } 80 | 81 | public class Ref : ScmlElement { 82 | public Ref () {parent=-1;} 83 | [XmlAttribute] public int parent { get; set; } // -1==no parent - uses ScmlObject spatialInfo as parentInfo 84 | [XmlAttribute] public int timeline { get; set; } //Dengar.NOTE: Again, the above comment is an artifact from the pseudocode 85 | [XmlAttribute] public int key { get; set; } //However, the fact that -1 equals "no parent" does come in useful later 86 | private float z; 87 | [XmlAttribute] public float z_index { //Translate Sprite's Z-index in something we can use in Unity 88 | get { return z; } //I choose to use position_z instead of order in layer because there are just potentially way too many 89 | set { z = value * -0.001f; } //body parts to work with. This way the order in layer is reserved for entire Spriter entities 90 | } 91 | } 92 | 93 | public enum ObjectType {sprite, bone, box, point, sound, entity, variable} 94 | public class TimeLine : ScmlElement { 95 | [XmlAttribute] public string name { get; set; } 96 | [XmlAttribute] public ObjectType objectType { get; set; } // enum : SPRITE,BONE,BOX,POINT,SOUND,ENTITY,VARIABLE //Dengar.NOTE (except not in all caps) 97 | [XmlElement ("key")] public TimeLineKey[] keys { get; set; } // tags within tags 98 | } 99 | 100 | public enum CurveType {instant, linear, quadratic, cubic} 101 | public class TimeLineKey : ScmlElement { 102 | public TimeLineKey () {time=0; spin=1;} 103 | private float _time; 104 | [XmlAttribute] public float time { 105 | get { return _time; } 106 | set { _time = value * 0.001f; } //See MainLineKey 107 | } 108 | [XmlAttribute] public CurveType curve_type { get; set; } // enum : INSTANT,LINEAR,QUADRATIC,CUBIC //Dengar.NOTE (again, no caps) 109 | [XmlAttribute] public float c1 { get; set; } 110 | [XmlAttribute] public float c2 { get; set; } //I think these should be implemented some time in the future 111 | [XmlAttribute] public int spin { get; set; } 112 | [XmlElement ("bone", typeof(SpatialInfo)), XmlElement ("object", typeof(SpriteInfo))] 113 | public SpatialInfo info { get; set; } 114 | } 115 | 116 | public class SpatialInfo { 117 | public SpatialInfo () {x=0; y=0; angle=0; scale_x=1; scale_y=1; trueScaleX=float.NaN; trueScaleY=float.NaN; a=1;} 118 | private float _x; 119 | [XmlAttribute] public float x { 120 | get { return _x; } 121 | set 122 | { 123 | if (ScmlImportOptions.options != null) 124 | { 125 | _x = value * (1f / ScmlImportOptions.options.pixelsPerUnit); // Convert Spriter space into Unity space using pixelsPerUnit 126 | } 127 | else 128 | { 129 | _x = value * 0.01f; 130 | } 131 | } 132 | } 133 | private float _y; 134 | [XmlAttribute] public float y { 135 | get { return _y; } 136 | set 137 | { 138 | if (ScmlImportOptions.options != null) 139 | { 140 | _y = value * (1f / ScmlImportOptions.options.pixelsPerUnit); // Convert Spriter space into Unity space using pixelsPerUnit 141 | } 142 | else 143 | { 144 | _y = value * 0.01f; 145 | } 146 | } 147 | } 148 | public Quaternion rotation { get; set; } //"angle" refers to a euler angle's Z value 149 | [XmlAttribute] public float angle { //Unity doesn't actually use euler angles below the hood though 150 | get { return rotation.eulerAngles.z; } //So we're translating the angle to a quaternion 151 | set { rotation = Quaternion.Euler (0, 0, value); } 152 | } 153 | private float sx; 154 | [XmlAttribute] public float scale_x { 155 | get { return sx; } 156 | set { 157 | sx = value; 158 | if (float.IsNaN(trueScaleX)) trueScaleX = value; 159 | } 160 | } 161 | private float trueScaleX; 162 | private float sy; 163 | [XmlAttribute] public float scale_y { 164 | get { return sy; } 165 | set { 166 | sy = value; 167 | if (float.IsNaN(trueScaleY)) trueScaleY = value; 168 | } 169 | } 170 | private float trueScaleY; 171 | [XmlAttribute] public float a { get; set; } //Alpha 172 | public bool processed = false; 173 | //Some very funky maths to make sure all the scale values are off the bones and on the sprite instead 174 | public bool Process (SpatialInfo parent) { 175 | if (GetType () == typeof(SpatialInfo)) { 176 | scale_x = (scale_x > 0) ? 1 : -1; 177 | scale_y = (scale_y > 0) ? 1 : -1; 178 | trueScaleX = Mathf.Abs (trueScaleX); 179 | trueScaleY = Mathf.Abs (trueScaleY); 180 | if (parent != null) { 181 | if (!float.IsNaN (parent.trueScaleX)) { 182 | _x *= parent.trueScaleX; 183 | trueScaleX *= parent.trueScaleX; 184 | } 185 | if (!float.IsNaN (parent.trueScaleY)) { 186 | _y *= parent.trueScaleY; 187 | trueScaleY *= parent.trueScaleY; 188 | } 189 | } 190 | return processed = true; 191 | } 192 | if (parent != null) { 193 | if (!float.IsNaN (parent.trueScaleX)) { 194 | _x *= parent.trueScaleX; 195 | scale_x *= parent.trueScaleX; 196 | } 197 | if (!float.IsNaN (parent.trueScaleY)) { 198 | _y *= parent.trueScaleY; 199 | scale_y *= parent.trueScaleY; 200 | } 201 | } 202 | return processed = true; 203 | } 204 | } 205 | 206 | public class SpriteInfo : SpatialInfo { 207 | public SpriteInfo () : base () {pivot_x=0; pivot_y=1;} 208 | [XmlAttribute] public int folder { get; set; } 209 | [XmlAttribute] public int file { get; set; } 210 | [XmlAttribute] public float pivot_x { get; set; } 211 | [XmlAttribute] public float pivot_y { get; set; } 212 | } 213 | 214 | public abstract class ScmlElement { 215 | [XmlAttribute] public int id { get; set; } 216 | } 217 | } 218 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Editor/ScmlSupport.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df259f6e7d7914a1c8b5aeca51ebff7b 3 | timeCreated: 1429467226 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Editor/Settings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 9f361e2f9624e406e9f836e8793ee5b8, type: 3} 13 | m_Name: Settings 14 | m_EditorClassIdentifier: 15 | importOption: 0 16 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Editor/Settings.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf890ff70619741bf9b6f668ec8c3b18 3 | timeCreated: 1443293962 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d10aa6967e2a34fee829c5246b4d5889 3 | folderAsset: yes 4 | timeCreated: 1430056322 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Runtime/EntityRenderer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace Spriter2UnityDX { 6 | [DisallowMultipleComponent, ExecuteInEditMode, AddComponentMenu("")] 7 | public class EntityRenderer : MonoBehaviour { 8 | private SpriteRenderer[] renderers = new SpriteRenderer [0]; 9 | private SortingOrderUpdater[] updaters = new SortingOrderUpdater [0]; 10 | private SpriteRenderer _first; 11 | private SpriteRenderer first { 12 | get { 13 | if (_first == null && renderers.Length > 0) 14 | _first = renderers [0]; 15 | return _first; 16 | } 17 | } 18 | public Color Color { 19 | get { return (first != null) ? first.color : default(Color); } 20 | set { DoForAll (x => x.color = value); } 21 | } 22 | 23 | public Material Material { 24 | get { return (first != null) ? first.sharedMaterial : null; } 25 | set { DoForAll (x => x.sharedMaterial = value); } 26 | } 27 | 28 | public int SortingLayerID { 29 | get { return (first != null) ? first.sortingLayerID : 0; } 30 | set { DoForAll (x => x.sortingLayerID = value); } 31 | } 32 | 33 | public string SortingLayerName { 34 | get { return (first != null) ? first.sortingLayerName : null; } 35 | set { DoForAll (x => x.sortingLayerName = value); } 36 | } 37 | 38 | [SerializeField, HideInInspector] private int sortingOrder = 0; 39 | public int SortingOrder { 40 | get { return sortingOrder; } 41 | set { 42 | sortingOrder = value; 43 | if (applySpriterZOrder) 44 | for (var i = 0; i < updaters.Length; i++) 45 | updaters [i].SortingOrder = value; 46 | else DoForAll (x => x.sortingOrder = value); 47 | } 48 | } 49 | 50 | [SerializeField, HideInInspector] private bool applySpriterZOrder = false; 51 | public bool ApplySpriterZOrder { 52 | get { return applySpriterZOrder; } 53 | set { 54 | applySpriterZOrder = value; 55 | if (applySpriterZOrder) { 56 | var list = new List (); 57 | var spriteCount = renderers.Length; 58 | foreach (var renderer in renderers) { 59 | var updater = renderer.GetComponent (); 60 | if (updater == null) updater = renderer.gameObject.AddComponent (); 61 | updater.SortingOrder = sortingOrder; 62 | updater.SpriteCount = spriteCount; 63 | list.Add (updater); 64 | } 65 | updaters = list.ToArray (); 66 | } 67 | else { 68 | for (var i = 0; i < updaters.Length; i++) { 69 | if (Application.isPlaying) Destroy (updaters [i]); 70 | else DestroyImmediate (updaters [i]); 71 | } 72 | updaters = new SortingOrderUpdater [0]; 73 | DoForAll (x => x.sortingOrder = sortingOrder); 74 | } 75 | } 76 | } 77 | 78 | private void Awake () { 79 | RefreshRenders (); 80 | } 81 | 82 | private void OnEnable () { 83 | DoForAll (x => x.enabled = true); 84 | } 85 | 86 | private void OnDisable () { 87 | DoForAll (x => x.enabled = false); 88 | } 89 | 90 | private void DoForAll (Action action) { 91 | for (var i = 0; i < renderers.Length; i++) action (renderers [i]); 92 | } 93 | 94 | public void RefreshRenders () { 95 | renderers = GetComponentsInChildren (true); 96 | updaters = GetComponentsInChildren (true); 97 | var length = updaters.Length; 98 | for (var i = 0; i < length; i++) updaters [i].SpriteCount = length; 99 | _first = null; 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Runtime/EntityRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8e9dda14b6f34517a0d598d3320a902 3 | timeCreated: 1430382382 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Runtime/SortingOrderUpdater.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | using System.Collections; 4 | 5 | namespace Spriter2UnityDX { 6 | [RequireComponent (typeof(SpriteRenderer)), ExecuteInEditMode, DisallowMultipleComponent, AddComponentMenu("")] 7 | public class SortingOrderUpdater : MonoBehaviour { 8 | private Transform trans; 9 | private SpriteRenderer srenderer; 10 | 11 | public int SpriteCount { get; set; } 12 | private int sor; 13 | public int SortingOrder { 14 | get { return sor; } 15 | set { 16 | sor = value; 17 | UpdateSortingOrder (); 18 | } 19 | } 20 | private float z_index = float.NaN; 21 | 22 | private void UpdateSortingOrder () { 23 | if (srenderer) srenderer.sortingOrder = (int)(z_index * -1000) + sor - SpriteCount; 24 | } 25 | 26 | private void Awake () { 27 | trans = transform; 28 | srenderer = GetComponent (); 29 | } 30 | 31 | private void Update () { 32 | var newZ = trans.localPosition.z; 33 | if (newZ != z_index) { 34 | z_index = newZ; 35 | UpdateSortingOrder (); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Runtime/SortingOrderUpdater.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c4a179c16de604057bc1902978187da5 3 | timeCreated: 1430814616 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Runtime/TextureController.cs: -------------------------------------------------------------------------------- 1 | //This project is open source. Anyone can use any part of this code however they wish 2 | //Feel free to use this code in your own projects, or expand on this code 3 | //If you have any improvements to the code itself, please visit 4 | //https://github.com/Dharengo/Spriter2UnityDX and share your suggestions by creating a fork 5 | //-Dengar/Dharengo 6 | 7 | using UnityEngine; 8 | using System.Collections; 9 | 10 | namespace Spriter2UnityDX { 11 | //This component is automatically added to sprite parts that have multiple possible 12 | //textures, such as facial expressions. This component will override any changes 13 | //you make to the SpriteRenderer's textures, so if you want to change textures 14 | //at runtime, please make these changes to this component, rather than SpriteRenderer 15 | [RequireComponent (typeof(SpriteRenderer)), DisallowMultipleComponent, ExecuteInEditMode, AddComponentMenu("")] 16 | public class TextureController : MonoBehaviour { 17 | public float DisplayedSprite = 0f; //Input from the AnimationClip 18 | public Sprite[] Sprites; //If you want to swap textures at runtime, change the sprites in this array 19 | 20 | private SpriteRenderer srenderer; 21 | private Animator animator; 22 | private int lastDisplayed; 23 | 24 | private void Awake () { 25 | srenderer = GetComponent (); 26 | lastDisplayed = (int)DisplayedSprite; 27 | animator = GetComponentInParent (); 28 | } 29 | 30 | private void Start () { 31 | srenderer.sprite = Sprites [lastDisplayed]; 32 | } 33 | 34 | private void Update () { 35 | //Only change the sprite when the DisplayedSprite property has actually been changed 36 | //It will ignore changes that happen during transitions because it might get messy otherwise 37 | if ((int)DisplayedSprite != lastDisplayed && !IsTransitioning () ) { 38 | lastDisplayed = (int)DisplayedSprite; 39 | srenderer.sprite = Sprites [lastDisplayed]; 40 | } 41 | } 42 | 43 | private bool IsTransitioning () { 44 | for (var i = 0; i < animator.layerCount; i++) 45 | if (animator.IsInTransition(i)) return true; 46 | return false; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Assets/Spriter2UnityDX/Runtime/TextureController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87d8dc87df01e4958ab48153b19f0ccd 3 | timeCreated: 1430060152 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Packages/Spriter2UnityDX.unitypackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dharengo/Spriter2UnityDX/c78dc39b24c5bdd21d573b3d0f5d8bd1c624970d/Packages/Spriter2UnityDX.unitypackage -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 0 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_DisableAudio: 0 15 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | m_Gravity: {x: 0, y: -9.81000042, z: 0} 7 | m_DefaultMaterial: {fileID: 0} 8 | m_BounceThreshold: 2 9 | m_SleepThreshold: .00499999989 10 | m_DefaultContactOffset: .00999999978 11 | m_SolverIterationCount: 6 12 | m_RaycastsHitTriggers: 1 13 | m_EnableAdaptiveForce: 0 14 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 15 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_WebSecurityEmulationEnabled: 0 10 | m_WebSecurityEmulationHostUrl: http://www.mydomain.com/mygame.unity3d 11 | m_DefaultBehaviorMode: 1 12 | m_SpritePackerMode: 2 13 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_LegacyDeferred: 11 | m_Mode: 1 12 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 13 | m_AlwaysIncludedShaders: 14 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 15 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 16 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 17 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 18 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 19 | - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0} 20 | m_PreloadedShaders: [] 21 | m_LightmapStripping: 0 22 | m_LightmapKeepPlain: 1 23 | m_LightmapKeepDirCombined: 1 24 | m_LightmapKeepDirSeparate: 1 25 | m_LightmapKeepDynamic: 1 26 | m_FogStripping: 0 27 | m_FogKeepLinear: 1 28 | m_FogKeepExp: 1 29 | m_FogKeepExp2: 1 30 | -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: .00100000005 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: .00100000005 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: .00100000005 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: .00100000005 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left cmd 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: .00100000005 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: .00100000005 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: .100000001 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: .100000001 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: .100000001 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: .189999998 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: .189999998 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: .00100000005 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: .00100000005 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: .00100000005 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: .00100000005 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: .00100000005 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: .00100000005 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: .00100000005 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshAreas: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | m_Gravity: {x: 0, y: -9.81000042} 7 | m_DefaultMaterial: {fileID: 0} 8 | m_VelocityIterations: 8 9 | m_PositionIterations: 3 10 | m_VelocityThreshold: 1 11 | m_MaxLinearCorrection: .200000003 12 | m_MaxAngularCorrection: 8 13 | m_MaxTranslationSpeed: 100 14 | m_MaxRotationSpeed: 360 15 | m_MinPenetrationForPenalty: .00999999978 16 | m_BaumgarteScale: .200000003 17 | m_BaumgarteTimeOfImpactScale: .75 18 | m_TimeToSleep: .5 19 | m_LinearSleepTolerance: .00999999978 20 | m_AngularSleepTolerance: 2 21 | m_RaycastsHitTriggers: 1 22 | m_RaycastsStartInColliders: 1 23 | m_ChangeStopsCallbacks: 0 24 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 25 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!129 &1 4 | PlayerSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 6 7 | AndroidProfiler: 0 8 | defaultScreenOrientation: 4 9 | targetDevice: 2 10 | targetGlesGraphics: -1 11 | targetIOSGraphics: -1 12 | targetResolution: 0 13 | accelerometerFrequency: 60 14 | companyName: DefaultCompany 15 | productName: Spriter2UnityDX 16 | cloudProjectId: 17 | defaultCursor: {fileID: 0} 18 | cursorHotspot: {x: 0, y: 0} 19 | m_ShowUnitySplashScreen: 1 20 | defaultScreenWidth: 1024 21 | defaultScreenHeight: 768 22 | defaultScreenWidthWeb: 960 23 | defaultScreenHeightWeb: 600 24 | m_RenderingPath: 1 25 | m_MobileRenderingPath: 1 26 | m_ActiveColorSpace: 0 27 | m_MTRendering: 1 28 | m_MobileMTRendering: 0 29 | m_UseDX11: 1 30 | m_Stereoscopic3D: 0 31 | iosShowActivityIndicatorOnLoading: -1 32 | androidShowActivityIndicatorOnLoading: -1 33 | iosAppInBackgroundBehavior: 0 34 | displayResolutionDialog: 1 35 | allowedAutorotateToPortrait: 1 36 | allowedAutorotateToPortraitUpsideDown: 1 37 | allowedAutorotateToLandscapeRight: 1 38 | allowedAutorotateToLandscapeLeft: 1 39 | useOSAutorotation: 1 40 | use32BitDisplayBuffer: 1 41 | disableDepthAndStencilBuffers: 0 42 | defaultIsFullScreen: 1 43 | defaultIsNativeResolution: 1 44 | runInBackground: 0 45 | captureSingleScreen: 0 46 | Override IPod Music: 0 47 | Prepare IOS For Recording: 0 48 | submitAnalytics: 1 49 | usePlayerLog: 1 50 | bakeCollisionMeshes: 0 51 | forceSingleInstance: 0 52 | resizableWindow: 0 53 | useMacAppStoreValidation: 0 54 | gpuSkinning: 0 55 | xboxPIXTextureCapture: 0 56 | xboxEnableAvatar: 0 57 | xboxEnableKinect: 0 58 | xboxEnableKinectAutoTracking: 0 59 | xboxEnableFitness: 0 60 | visibleInBackground: 0 61 | macFullscreenMode: 2 62 | d3d9FullscreenMode: 1 63 | d3d11FullscreenMode: 1 64 | xboxSpeechDB: 0 65 | xboxEnableHeadOrientation: 0 66 | xboxEnableGuest: 0 67 | xboxOneResolution: 0 68 | ps3SplashScreen: {fileID: 0} 69 | videoMemoryForVertexBuffers: 0 70 | psp2PowerMode: 0 71 | psp2AcquireBGM: 1 72 | m_SupportedAspectRatios: 73 | 4:3: 1 74 | 5:4: 1 75 | 16:10: 1 76 | 16:9: 1 77 | Others: 1 78 | bundleIdentifier: com.Company.ProductName 79 | bundleVersion: 1.0 80 | preloadedAssets: [] 81 | metroEnableIndependentInputSource: 0 82 | metroEnableLowLatencyPresentationAPI: 0 83 | xboxOneDisableKinectGpuReservation: 0 84 | productGUID: 1b3017df50bcb48399b9954b16aff20b 85 | AndroidBundleVersionCode: 1 86 | AndroidMinSdkVersion: 9 87 | AndroidPreferredInstallLocation: 1 88 | aotOptions: 89 | apiCompatibilityLevel: 2 90 | iPhoneStrippingLevel: 0 91 | iPhoneScriptCallOptimization: 0 92 | ForceInternetPermission: 0 93 | ForceSDCardPermission: 0 94 | CreateWallpaper: 0 95 | APKExpansionFiles: 0 96 | preloadShaders: 0 97 | StripUnusedMeshComponents: 0 98 | iPhoneSdkVersion: 988 99 | iPhoneTargetOSVersion: 22 100 | uIPrerenderedIcon: 0 101 | uIRequiresPersistentWiFi: 0 102 | uIStatusBarHidden: 1 103 | uIExitOnSuspend: 0 104 | uIStatusBarStyle: 0 105 | iPhoneSplashScreen: {fileID: 0} 106 | iPhoneHighResSplashScreen: {fileID: 0} 107 | iPhoneTallHighResSplashScreen: {fileID: 0} 108 | iPhone47inSplashScreen: {fileID: 0} 109 | iPhone55inPortraitSplashScreen: {fileID: 0} 110 | iPhone55inLandscapeSplashScreen: {fileID: 0} 111 | iPadPortraitSplashScreen: {fileID: 0} 112 | iPadHighResPortraitSplashScreen: {fileID: 0} 113 | iPadLandscapeSplashScreen: {fileID: 0} 114 | iPadHighResLandscapeSplashScreen: {fileID: 0} 115 | iOSLaunchScreenType: 0 116 | iOSLaunchScreenPortrait: {fileID: 0} 117 | iOSLaunchScreenLandscape: {fileID: 0} 118 | iOSLaunchScreenBackgroundColor: 119 | serializedVersion: 2 120 | rgba: 0 121 | iOSLaunchScreenFillPct: 100 122 | iOSLaunchScreenSize: 100 123 | iOSLaunchScreenCustomXibPath: 124 | AndroidTargetDevice: 0 125 | AndroidSplashScreenScale: 0 126 | AndroidKeystoreName: 127 | AndroidKeyaliasName: 128 | AndroidTVCompatibility: 1 129 | AndroidIsGame: 1 130 | androidEnableBanner: 1 131 | m_AndroidBanners: 132 | - width: 320 133 | height: 180 134 | banner: {fileID: 0} 135 | androidGamepadSupportLevel: 0 136 | resolutionDialogBanner: {fileID: 0} 137 | m_BuildTargetIcons: [] 138 | m_BuildTargetBatching: [] 139 | webPlayerTemplate: APPLICATION:Default 140 | m_TemplateCustomTags: {} 141 | actionOnDotNetUnhandledException: 1 142 | enableInternalProfiler: 0 143 | logObjCUncaughtExceptions: 1 144 | enableCrashReportAPI: 0 145 | locationUsageDescription: 146 | XboxTitleId: 147 | XboxImageXexPath: 148 | XboxSpaPath: 149 | XboxGenerateSpa: 0 150 | XboxDeployKinectResources: 0 151 | XboxSplashScreen: {fileID: 0} 152 | xboxEnableSpeech: 0 153 | xboxAdditionalTitleMemorySize: 0 154 | xboxDeployKinectHeadOrientation: 0 155 | xboxDeployKinectHeadPosition: 0 156 | ps3TitleConfigPath: 157 | ps3DLCConfigPath: 158 | ps3ThumbnailPath: 159 | ps3BackgroundPath: 160 | ps3SoundPath: 161 | ps3NPAgeRating: 12 162 | ps3TrophyCommId: 163 | ps3NpCommunicationPassphrase: 164 | ps3TrophyPackagePath: 165 | ps3BootCheckMaxSaveGameSizeKB: 128 166 | ps3TrophyCommSig: 167 | ps3SaveGameSlots: 1 168 | ps3TrialMode: 0 169 | ps3VideoMemoryForAudio: 0 170 | ps3EnableVerboseMemoryStats: 0 171 | ps3UseSPUForUmbra: 0 172 | ps3EnableMoveSupport: 1 173 | ps3DisableDolbyEncoding: 0 174 | ps4NPAgeRating: 12 175 | ps4NPTitleSecret: 176 | ps4NPTrophyPackPath: 177 | ps4ParentalLevel: 1 178 | ps4ContentID: ED1633-NPXX51362_00-0000000000000000 179 | ps4Category: 0 180 | ps4MasterVersion: 01.00 181 | ps4AppVersion: 01.00 182 | ps4AppType: 0 183 | ps4ParamSfxPath: 184 | ps4VideoOutPixelFormat: 0 185 | ps4VideoOutResolution: 4 186 | ps4PronunciationXMLPath: 187 | ps4PronunciationSIGPath: 188 | ps4BackgroundImagePath: 189 | ps4StartupImagePath: 190 | ps4SaveDataImagePath: 191 | ps4BGMPath: 192 | ps4ShareFilePath: 193 | ps4NPtitleDatPath: 194 | ps4RemotePlayKeyAssignment: -1 195 | ps4EnterButtonAssignment: 1 196 | ps4ApplicationParam1: 0 197 | ps4ApplicationParam2: 0 198 | ps4ApplicationParam3: 0 199 | ps4ApplicationParam4: 0 200 | ps4Passcode: 5PN2qmWqBlQ9wQj99nsQzldVI5ZuGXbE 201 | ps4pnSessions: 1 202 | ps4pnPresence: 1 203 | ps4pnFriends: 1 204 | ps4pnGameCustomData: 1 205 | playerPrefsSupport: 0 206 | monoEnv: 207 | psp2Splashimage: {fileID: 0} 208 | psp2NPTrophyPackPath: 209 | psp2NPSupportGBMorGJP: 0 210 | psp2NPAgeRating: 12 211 | psp2NPCommsID: 212 | psp2NPCommunicationsID: 213 | psp2NPCommsPassphrase: 214 | psp2NPCommsSig: 215 | psp2ParamSfxPath: 216 | psp2ManualPath: 217 | psp2LiveAreaGatePath: 218 | psp2LiveAreaBackroundPath: 219 | psp2LiveAreaPath: 220 | psp2LiveAreaTrialPath: 221 | psp2PatchChangeInfoPath: 222 | psp2PatchOriginalPackage: 223 | psp2PackagePassword: WRK5RhRXdCdG5nG5azdNMK66MuCV6GXi 224 | psp2KeystoneFile: 225 | psp2DRMType: 0 226 | psp2StorageType: 0 227 | psp2MediaCapacity: 0 228 | psp2DLCConfigPath: 229 | psp2ThumbnailPath: 230 | psp2BackgroundPath: 231 | psp2SoundPath: 232 | psp2TrophyCommId: 233 | psp2TrophyPackagePath: 234 | psp2PackagedResourcesPath: 235 | psp2SaveDataQuota: 10240 236 | psp2ParentalLevel: 1 237 | psp2ShortTitle: Not Set 238 | psp2ContentID: IV0000-ABCD12345_00-0123456789ABCDEF 239 | psp2Category: 0 240 | psp2MasterVersion: 01.00 241 | psp2AppVersion: 01.00 242 | psp2TVBootMode: 0 243 | psp2EnterButtonAssignment: 2 244 | psp2TVDisableEmu: 0 245 | psp2AllowTwitterDialog: 1 246 | psp2Upgradable: 0 247 | psp2HealthWarning: 0 248 | psp2UseLibLocation: 0 249 | psp2InfoBarOnStartup: 0 250 | psp2InfoBarColor: 0 251 | psmSplashimage: {fileID: 0} 252 | spritePackerPolicy: 253 | scriptingDefineSymbols: {} 254 | metroPackageName: Spriter2UnityDX 255 | metroPackageLogo: 256 | metroPackageLogo140: 257 | metroPackageLogo180: 258 | metroPackageLogo240: 259 | metroPackageVersion: 260 | metroCertificatePath: 261 | metroCertificatePassword: 262 | metroCertificateSubject: 263 | metroCertificateIssuer: 264 | metroCertificateNotAfter: 0000000000000000 265 | metroApplicationDescription: Spriter2UnityDX 266 | metroStoreTileLogo80: 267 | metroStoreTileLogo: 268 | metroStoreTileLogo140: 269 | metroStoreTileLogo180: 270 | metroStoreTileWideLogo80: 271 | metroStoreTileWideLogo: 272 | metroStoreTileWideLogo140: 273 | metroStoreTileWideLogo180: 274 | metroStoreTileSmallLogo80: 275 | metroStoreTileSmallLogo: 276 | metroStoreTileSmallLogo140: 277 | metroStoreTileSmallLogo180: 278 | metroStoreSmallTile80: 279 | metroStoreSmallTile: 280 | metroStoreSmallTile140: 281 | metroStoreSmallTile180: 282 | metroStoreLargeTile80: 283 | metroStoreLargeTile: 284 | metroStoreLargeTile140: 285 | metroStoreLargeTile180: 286 | metroStoreSplashScreenImage: 287 | metroStoreSplashScreenImage140: 288 | metroStoreSplashScreenImage180: 289 | metroPhoneAppIcon: 290 | metroPhoneAppIcon140: 291 | metroPhoneAppIcon240: 292 | metroPhoneSmallTile: 293 | metroPhoneSmallTile140: 294 | metroPhoneSmallTile240: 295 | metroPhoneMediumTile: 296 | metroPhoneMediumTile140: 297 | metroPhoneMediumTile240: 298 | metroPhoneWideTile: 299 | metroPhoneWideTile140: 300 | metroPhoneWideTile240: 301 | metroPhoneSplashScreenImage: 302 | metroPhoneSplashScreenImage140: 303 | metroPhoneSplashScreenImage240: 304 | metroTileShortName: 305 | metroCommandLineArgsFile: 306 | metroTileShowName: 0 307 | metroMediumTileShowName: 0 308 | metroLargeTileShowName: 0 309 | metroWideTileShowName: 0 310 | metroDefaultTileSize: 1 311 | metroTileForegroundText: 1 312 | metroTileBackgroundColor: {r: 0, g: 0, b: 0, a: 1} 313 | metroSplashScreenBackgroundColor: {r: 0, g: 0, b: 0, a: 1} 314 | metroSplashScreenUseBackgroundColor: 0 315 | platformCapabilities: {} 316 | metroFTAName: 317 | metroFTAFileTypes: [] 318 | metroProtocolName: 319 | metroCompilationOverrides: 1 320 | blackberryDeviceAddress: 321 | blackberryDevicePassword: 322 | blackberryTokenPath: 323 | blackberryTokenExires: 324 | blackberryTokenAuthor: 325 | blackberryTokenAuthorId: 326 | blackberryCskPassword: 327 | blackberrySaveLogPath: 328 | blackberrySharedPermissions: 0 329 | blackberryCameraPermissions: 0 330 | blackberryGPSPermissions: 0 331 | blackberryDeviceIDPermissions: 0 332 | blackberryMicrophonePermissions: 0 333 | blackberryGamepadSupport: 0 334 | blackberryBuildId: 0 335 | blackberryLandscapeSplashScreen: {fileID: 0} 336 | blackberryPortraitSplashScreen: {fileID: 0} 337 | blackberrySquareSplashScreen: {fileID: 0} 338 | tizenProductDescription: 339 | tizenProductURL: 340 | tizenCertificatePath: 341 | tizenCertificatePassword: 342 | tizenGPSPermissions: 0 343 | tizenMicrophonePermissions: 0 344 | stvDeviceAddress: 345 | stvProductDescription: 346 | stvProductAuthor: 347 | stvProductAuthorEmail: 348 | stvProductLink: 349 | stvProductCategory: 0 350 | XboxOneProductId: 351 | XboxOneUpdateKey: 352 | XboxOneSandboxId: 353 | XboxOneContentId: 354 | XboxOneTitleId: 355 | XboxOneSCId: 356 | XboxOneGameOsOverridePath: 357 | XboxOnePackagingOverridePath: 358 | XboxOneAppManifestOverridePath: 359 | XboxOnePackageEncryption: 0 360 | XboxOneDescription: 361 | XboxOneIsContentPackage: 0 362 | XboxOneEnableGPUVariability: 0 363 | XboxOneSockets: {} 364 | XboxOneSplashScreen: {fileID: 0} 365 | XboxOneAllowedProductIds: [] 366 | XboxOnePersistentLocalStorageSize: 0 367 | intPropertyNames: 368 | - WebGL::ScriptingBackend 369 | - WebGL::audioCompressionFormat 370 | - WebGL::exceptionSupport 371 | - WebGL::memorySize 372 | - iOS::Architecture 373 | - iOS::ScriptingBackend 374 | WebGL::ScriptingBackend: 1 375 | WebGL::audioCompressionFormat: 4 376 | WebGL::exceptionSupport: 0 377 | WebGL::memorySize: 256 378 | iOS::Architecture: 2 379 | iOS::ScriptingBackend: 0 380 | boolPropertyNames: 381 | - WebGL::dataCaching 382 | - XboxOne::enus 383 | WebGL::dataCaching: 0 384 | XboxOne::enus: 1 385 | stringPropertyNames: 386 | - WebGL::emscriptenArgs 387 | - WebGL::template 388 | WebGL::emscriptenArgs: 389 | WebGL::template: APPLICATION:Default 390 | firstStreamedLevelWithResources: 0 391 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.0.1f1 2 | m_StandardAssetsVersion: 0 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 5 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Fastest 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowCascade2Split: .333333343 18 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 19 | blendWeights: 1 20 | textureQuality: 1 21 | anisotropicTextures: 0 22 | antiAliasing: 0 23 | softParticles: 0 24 | softVegetation: 0 25 | realtimeReflectionProbes: 0 26 | billboardsFaceCameraPosition: 0 27 | vSyncCount: 0 28 | lodBias: .300000012 29 | maximumLODLevel: 0 30 | particleRaycastBudget: 4 31 | excludedTargetPlatforms: [] 32 | - serializedVersion: 2 33 | name: Fast 34 | pixelLightCount: 0 35 | shadows: 0 36 | shadowResolution: 0 37 | shadowProjection: 1 38 | shadowCascades: 1 39 | shadowDistance: 20 40 | shadowCascade2Split: .333333343 41 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 42 | blendWeights: 2 43 | textureQuality: 0 44 | anisotropicTextures: 0 45 | antiAliasing: 0 46 | softParticles: 0 47 | softVegetation: 0 48 | realtimeReflectionProbes: 0 49 | billboardsFaceCameraPosition: 0 50 | vSyncCount: 0 51 | lodBias: .400000006 52 | maximumLODLevel: 0 53 | particleRaycastBudget: 16 54 | excludedTargetPlatforms: [] 55 | - serializedVersion: 2 56 | name: Simple 57 | pixelLightCount: 1 58 | shadows: 1 59 | shadowResolution: 0 60 | shadowProjection: 1 61 | shadowCascades: 1 62 | shadowDistance: 20 63 | shadowCascade2Split: .333333343 64 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 65 | blendWeights: 2 66 | textureQuality: 0 67 | anisotropicTextures: 1 68 | antiAliasing: 0 69 | softParticles: 0 70 | softVegetation: 0 71 | realtimeReflectionProbes: 0 72 | billboardsFaceCameraPosition: 0 73 | vSyncCount: 0 74 | lodBias: .699999988 75 | maximumLODLevel: 0 76 | particleRaycastBudget: 64 77 | excludedTargetPlatforms: [] 78 | - serializedVersion: 2 79 | name: Good 80 | pixelLightCount: 2 81 | shadows: 2 82 | shadowResolution: 1 83 | shadowProjection: 1 84 | shadowCascades: 2 85 | shadowDistance: 40 86 | shadowCascade2Split: .333333343 87 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 88 | blendWeights: 2 89 | textureQuality: 0 90 | anisotropicTextures: 1 91 | antiAliasing: 0 92 | softParticles: 0 93 | softVegetation: 1 94 | realtimeReflectionProbes: 1 95 | billboardsFaceCameraPosition: 1 96 | vSyncCount: 1 97 | lodBias: 1 98 | maximumLODLevel: 0 99 | particleRaycastBudget: 256 100 | excludedTargetPlatforms: [] 101 | - serializedVersion: 2 102 | name: Beautiful 103 | pixelLightCount: 3 104 | shadows: 2 105 | shadowResolution: 2 106 | shadowProjection: 1 107 | shadowCascades: 2 108 | shadowDistance: 70 109 | shadowCascade2Split: .333333343 110 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 111 | blendWeights: 4 112 | textureQuality: 0 113 | anisotropicTextures: 2 114 | antiAliasing: 2 115 | softParticles: 1 116 | softVegetation: 1 117 | realtimeReflectionProbes: 1 118 | billboardsFaceCameraPosition: 1 119 | vSyncCount: 1 120 | lodBias: 1.5 121 | maximumLODLevel: 0 122 | particleRaycastBudget: 1024 123 | excludedTargetPlatforms: [] 124 | - serializedVersion: 2 125 | name: Fantastic 126 | pixelLightCount: 4 127 | shadows: 2 128 | shadowResolution: 2 129 | shadowProjection: 1 130 | shadowCascades: 4 131 | shadowDistance: 150 132 | shadowCascade2Split: .333333343 133 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 134 | blendWeights: 4 135 | textureQuality: 0 136 | anisotropicTextures: 2 137 | antiAliasing: 2 138 | softParticles: 1 139 | softVegetation: 1 140 | realtimeReflectionProbes: 1 141 | billboardsFaceCameraPosition: 1 142 | vSyncCount: 1 143 | lodBias: 2 144 | maximumLODLevel: 0 145 | particleRaycastBudget: 4096 146 | excludedTargetPlatforms: [] 147 | m_PerPlatformDefaultQuality: 148 | Android: 2 149 | BlackBerry: 2 150 | GLES Emulation: 5 151 | PS3: 5 152 | PS4: 5 153 | PSM: 5 154 | PSP2: 5 155 | Samsung TV: 2 156 | Standalone: 5 157 | Tizen: 2 158 | WP8: 5 159 | Web: 5 160 | WebGL: 3 161 | Windows Store Apps: 5 162 | XBOX360: 5 163 | XboxOne: 5 164 | iPhone: 2 165 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: .0199999996 7 | Maximum Allowed Timestep: .333333343 8 | m_TimeScale: 1 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Spriter2UnityDX 2 | Converts Spriter .scml files to Unity prefabs 3 | 4 | Version 1.0.4 5 | 6 | Download the Unity Package here: https://github.com/Dharengo/Spriter2UnityDX/raw/master/Packages/Spriter2UnityDX.unitypackage 7 | 8 | !!!Requires Unity 5.x!!! 9 | 10 | Use Instructions: 11 | 12 | 1) Import the package into your Unity project (just drag and drop it into your Project view).
13 | 2) Import your entire Spriter project folder (including all the textures) into your Unity project
14 | 3) The converter should automatically create a prefab (with nested animations) and an AnimatorController
15 | 4) When you make any changes to the .scml file, the converter will attempt to update existing assets if they exist
16 | 5) If the update causes irregular behaviour, try deleting the original assets and then reimporting the .scml file 17 | 18 | Changelog: 19 | 20 | v1.0.4:
21 | Fixes:
22 | -AnimationEvents are now preserved between reimports
23 | -SpriteSwapper renamed to TextureController to avoid confusion
24 | -Fixed a z-position issue with the SortingOrderUpdater
25 | v1.0.3:
26 | Fixes:
27 | -Fixed an issue where flipped (negative-scaled) bones caused child sprites to appear out of place and in odd angles
28 | Features:
29 | -Added a toggle to the Entity Renderer that allows you to apply the .scml file's Z-index to the order-in-layer property of the Sprite Renderers
30 | -Removed Spriter2UnityDX components from the Add Component menu, since they are automatically added or removed through script
31 | v1.0.2:
32 | Fixes:
33 | -Fixed an issue where sprites appeared distorted when resizing bones.
34 | -Exceptions are wrapped up nicely and no longer abort the whole process
35 | Features:
36 | -Now adds AnimationClips to existing AnimatorStates if they exist
37 | -Autosaves no longer trigger the importer
38 | v1.0.1:
39 | Fixes: -Fixed an issue where the sprite's Z orders would get messed up if the sprite is moved during animation
40 | Features: -Z order can now be mutated during animation
41 | v1.0: Initial version 42 | --------------------------------------------------------------------------------