Merge pull request #48 from Dgizusse/master

tk2d: Fixed source textures included in the build along the atlas.
This commit is contained in:
Nathan Sweet 2013-05-15 12:14:28 -07:00
commit 76194599b9
5 changed files with 39 additions and 11 deletions

View File

@ -138,10 +138,10 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor
mesh.uv = uvs; mesh.uv = uvs;
mesh.triangles = triangles; mesh.triangles = triangles;
if (skeletonDataAsset.sprites.normalGenerationMode != tk2dSpriteCollection.NormalGenerationMode.None) { if (skeletonDataAsset.normalGenerationMode != tk2dSpriteCollection.NormalGenerationMode.None) {
mesh.RecalculateNormals(); mesh.RecalculateNormals();
if (skeletonDataAsset.sprites.normalGenerationMode == tk2dSpriteCollection.NormalGenerationMode.NormalsAndTangents) { if (skeletonDataAsset.normalGenerationMode == tk2dSpriteCollection.NormalGenerationMode.NormalsAndTangents) {
Vector4[] tangents = new Vector4[mesh.normals.Length]; Vector4[] tangents = new Vector4[mesh.normals.Length];
for (int t = 0; t < tangents.Length; ++t) { for (int t = 0; t < tangents.Length; ++t) {
tangents[t] = new Vector4(1, 0, 0, 1); tangents[t] = new Vector4(1, 0, 0, 1);
@ -150,7 +150,7 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor
} }
} }
renderer.sharedMaterial = skeletonDataAsset.sprites.spriteCollection.inst.materials[0]; renderer.sharedMaterial = skeletonDataAsset.spritesData.inst.materials[0];
} }
/* /*
@ -203,7 +203,7 @@ public class tk2dSpineSkeleton : MonoBehaviour, tk2dRuntime.ISpriteCollectionFor
} }
public bool UsesSpriteCollection(tk2dSpriteCollectionData spriteCollection) { public bool UsesSpriteCollection(tk2dSpriteCollectionData spriteCollection) {
return skeletonDataAsset.sprites.spriteCollection == spriteCollection; return skeletonDataAsset.spritesData == spriteCollection;
} }
public void ForceBuild() { public void ForceBuild() {

View File

@ -9,7 +9,9 @@ public class tk2dSpineSkeletonDataAsset : ScriptableObject {
/* /*
*/ */
public tk2dSpriteCollection sprites; public tk2dSpriteCollectionData spritesData;
public tk2dSpriteCollection.NormalGenerationMode normalGenerationMode = tk2dSpriteCollection.NormalGenerationMode.None;
public TextAsset skeletonJSON; public TextAsset skeletonJSON;
public float scale = 1; public float scale = 1;
@ -42,7 +44,7 @@ public class tk2dSpineSkeletonDataAsset : ScriptableObject {
/* /*
*/ */
private void MakeSkeletonAndAnimationData() { private void MakeSkeletonAndAnimationData() {
if(sprites == null) { if(spritesData == null) {
Debug.LogWarning("Sprite collection not set for skeleton data asset: " + name,this); Debug.LogWarning("Sprite collection not set for skeleton data asset: " + name,this);
return; return;
} }
@ -52,7 +54,7 @@ public class tk2dSpineSkeletonDataAsset : ScriptableObject {
return; return;
} }
SkeletonJson json = new SkeletonJson(new tk2dSpineAttachmentLoader(sprites.spriteCollection)); SkeletonJson json = new SkeletonJson(new tk2dSpineAttachmentLoader(spritesData));
json.Scale = scale; json.Scale = scale;
try { try {

View File

@ -10,7 +10,6 @@ public class tk2dSpineSkeletonDataAssetInspector : Editor {
/* /*
*/ */
private SerializedProperty sprites;
private SerializedProperty skeletonJSON; private SerializedProperty skeletonJSON;
private SerializedProperty scale; private SerializedProperty scale;
private SerializedProperty fromAnimation; private SerializedProperty fromAnimation;
@ -18,10 +17,22 @@ public class tk2dSpineSkeletonDataAssetInspector : Editor {
private SerializedProperty duration; private SerializedProperty duration;
private bool showAnimationStateData = true; private bool showAnimationStateData = true;
private tk2dSpriteCollection sprites;
/* /*
*/ */
void OnEnable () { void OnEnable () {
sprites = serializedObject.FindProperty("sprites");
tk2dSpineSkeletonDataAsset skeletonDataAsset = target as tk2dSpineSkeletonDataAsset;
if (skeletonDataAsset != null) {
tk2dSpriteCollectionData spritesData = skeletonDataAsset.spritesData;
if (spritesData != null) {
sprites = AssetDatabase.LoadAssetAtPath( AssetDatabase.GUIDToAssetPath(spritesData.spriteCollectionGUID), typeof(tk2dSpriteCollection) ) as tk2dSpriteCollection;
}
}
skeletonJSON = serializedObject.FindProperty("skeletonJSON"); skeletonJSON = serializedObject.FindProperty("skeletonJSON");
scale = serializedObject.FindProperty("scale"); scale = serializedObject.FindProperty("scale");
fromAnimation = serializedObject.FindProperty("fromAnimation"); fromAnimation = serializedObject.FindProperty("fromAnimation");
@ -37,7 +48,22 @@ public class tk2dSpineSkeletonDataAssetInspector : Editor {
tk2dSpineSkeletonDataAsset asset = target as tk2dSpineSkeletonDataAsset; tk2dSpineSkeletonDataAsset asset = target as tk2dSpineSkeletonDataAsset;
EditorGUIUtility.LookLikeInspector(); EditorGUIUtility.LookLikeInspector();
EditorGUILayout.PropertyField(sprites); sprites = EditorGUILayout.ObjectField("Sprites", sprites, typeof(tk2dSpriteCollection), false) as tk2dSpriteCollection;
if (sprites != null) {
SerializedProperty spritesData = serializedObject.FindProperty("spritesData");
spritesData.objectReferenceValue = sprites.spriteCollection;
SerializedProperty normalGenerationMode = serializedObject.FindProperty("normalGenerationMode");
normalGenerationMode.enumValueIndex = (int)sprites.normalGenerationMode;
} else {
SerializedProperty spritesData = serializedObject.FindProperty("spritesData");
spritesData.objectReferenceValue = null;
SerializedProperty normalGenerationMode = serializedObject.FindProperty("normalGenerationMode");
normalGenerationMode.enumValueIndex = (int)tk2dSpriteCollection.NormalGenerationMode.None;
}
EditorGUILayout.PropertyField(skeletonJSON); EditorGUILayout.PropertyField(skeletonJSON);
EditorGUILayout.PropertyField(scale); EditorGUILayout.PropertyField(scale);

Binary file not shown.