Skip to content

Commit

Permalink
v1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
loodakrawa committed Nov 17, 2015
1 parent b27ce51 commit 4452ca9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
### 1.0.3
##### 1.0.4
* Fix SpriterImporter to pass prefab instead of destroyed tmp object

##### 1.0.3
* Fix bug when no keyframe in t = 0
* Fix bug when keyframe has no object_refs

### 1.0.2
##### 1.0.2
* Fix changing pivots when blending animations

### 1.0.1
##### 1.0.1
* Add XML Documentation to SpriterAnimator
* Fix blend compatibility test
* Fix read only properties in SpriterAnimator
Expand Down
21 changes: 12 additions & 9 deletions SpriterDotNet.Unity/Assets/SpriterDotNet/SpriterImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class SpriterImporter : AssetPostprocessor

public static float DeltaZ = -0.001f;
public static bool UseNativeTags = true;
public static event Action<SpriterEntity, GameObject> EntityImported = (e,g) => { };

public static event Action<SpriterEntity, GameObject> EntityImported = (e, p) => { };

private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPath)
{
Expand Down Expand Up @@ -65,18 +65,18 @@ private static void CreateSpriter(string path)
CreateSprites(entity, cd, spriter, sprites);
CreateCollisionRectangles(entity, cd, spriter, metadata);
CreatePoints(entity, cd, spriter, metadata);

behaviour.EntityIndex = entity.Id;
behaviour.enabled = true;
behaviour.SpriterData = spriterData;
behaviour.ChildData = cd;

CreatePrefab(go, rootFolder);
GameObject prefab = CreatePrefab(go, rootFolder);

EntityImported(entity, go);
EntityImported(entity, prefab);
}

if(UseNativeTags) CreateTags(spriter);
if (UseNativeTags) CreateTags(spriter);
}

private static SpriterData CreateSpriterData(Spriter spriter, string rootFolder, string name)
Expand All @@ -91,15 +91,18 @@ private static SpriterData CreateSpriterData(Spriter spriter, string rootFolder,
return data;
}

private static void CreatePrefab(GameObject go, string folder)
private static GameObject CreatePrefab(GameObject go, string folder)
{
string prefabPath = folder + "/" + go.name + ".prefab";
GameObject existing = AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath);

if (existing != null) PrefabUtility.ReplacePrefab(go, existing, ReplacePrefabOptions.Default);
else PrefabUtility.CreatePrefab(prefabPath, go, ReplacePrefabOptions.Default);
GameObject prefab;
if (existing != null) prefab = PrefabUtility.ReplacePrefab(go, existing, ReplacePrefabOptions.Default);
else prefab = PrefabUtility.CreatePrefab(prefabPath, go, ReplacePrefabOptions.Default);

GameObject.DestroyImmediate(go);

return prefab;
}

private static void CreateSprites(SpriterEntity entity, ChildData cd, Spriter spriter, GameObject parent)
Expand Down

0 comments on commit 4452ca9

Please sign in to comment.