Skip to content

Commit

Permalink
Merge branch 'release/v0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
nicloay committed Jan 30, 2014
2 parents a881c3d + b2de5c7 commit 9133da5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,17 @@ static void setCachedData (SpineData data)
foreach (SpineBone bone in data.bones){
string path = "";
SpineBone b = bone;
do{
do {
path=b.name+"/"+path;
if (!string.IsNullOrEmpty( b.parent))
b = data.boneByName[b.parent];
else
b = null;
} while (b!=null);
path = path.Replace("root/","");

if (path.Length >0)
path = path.Remove(path.Length - 1);
if (path == "root")
path = "";

data.bonePathByName.Add(bone.name, path);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void OnWizardCreate(){
SpineData spineData = SpineData .deserializeFromFile(path);

SpineUtil.updateImporters(spineMultiAtlas, directory, pixelsPerUnit, out spriteByName);
GameObject rootGO = SpineUtil.buildSceleton(spineData, pixelsPerUnit, out boneGOByName, out slotByName);
GameObject rootGO = SpineUtil.buildSceleton(name, spineData, pixelsPerUnit, out boneGOByName, out slotByName);
rootGO.name = name;
SpineUtil.addAllAttahcmentsSlots(spineData, spriteByName, slotByName, pixelsPerUnit, out skins, out attachmentGOByNameBySlot);
SkinController sk = SpineUtil.addSkinController(rootGO, spineData, skins, slotByName);
Expand Down
17 changes: 9 additions & 8 deletions Assets/UnitySpineImporter/Scripts/Editor/Util/SpineUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ static void fixTextureSize(string imagePath){
if (max > sizes[i] && max <= sizes[nextI] )
fitSize = sizes[nextI];
}

if (importer.maxTextureSize!=fitSize){
Debug.LogWarning("change default size to " + fitSize+ " for "+imagePath);
importer.maxTextureSize = fitSize;
}

foreach(string platform in platforms){
int maxTextureSize;
TextureImporterFormat textureFormat;
Expand All @@ -129,7 +131,6 @@ public static void updateImporters(SpineMultiatlas multiatlas, string directory,
Texture2D tex = AssetDatabase.LoadAssetAtPath(imagePath, typeof(Texture2D )) as Texture2D;
Vector2 atlasSize = new Vector2(tex.width, tex.height);
TextureImporter importer = TextureImporter.GetAtPath(imagePath) as TextureImporter;
importer.maxTextureSize = 2048;
importer.spritesheet = getSpriteMetadata(spineAtlas, atlasSize);
importer.textureType = TextureImporterType.Sprite;
importer.spriteImportMode = SpriteImportMode.Multiple;
Expand Down Expand Up @@ -209,23 +210,23 @@ public static void swap2Float(ref float float1, ref float float2){
float2 = tmp;
}

public static GameObject buildSceleton(SpineData data, int pixelsPerUnit, out Dictionary<string,GameObject> boneGOByName, out Dictionary<string, Slot> slotByName){
public static GameObject buildSceleton(string name, SpineData data, int pixelsPerUnit, out Dictionary<string,GameObject> boneGOByName, out Dictionary<string, Slot> slotByName){
float ratio = 1.0f / (float)pixelsPerUnit;
boneGOByName = new Dictionary<string, GameObject>();
slotByName = new Dictionary<string, Slot>();
GameObject rootGO = null;
GameObject rootGO = new GameObject(name);
foreach(SpineBone bone in data.bones){
GameObject go = new GameObject(bone.name);
boneGOByName.Add(bone.name, go);
}

foreach(SpineBone bone in data.bones){
GameObject go = boneGOByName[bone.name];
if (bone.parent == null){
rootGO = go;
continue;
}
go.transform.parent = boneGOByName[bone.parent].transform;
if (bone.parent == null)
go.transform.parent = rootGO.transform;
else
go.transform.parent = boneGOByName[bone.parent].transform;

Vector3 position = new Vector3((float)bone.x * ratio, (float)bone.y * ratio, 0.0f);
Vector3 scale = new Vector3((float)bone.scaleX, (float)bone.scaleY, 1.0f);
Quaternion rotation = Quaternion.Euler(0, 0, (float)bone.rotation);
Expand Down

0 comments on commit 9133da5

Please sign in to comment.