[unity] Minor SkeletonGraphic fixes.

This commit is contained in:
pharan 2016-07-15 14:44:23 +08:00
parent 0e883f3e3c
commit 5611de296d
2 changed files with 17 additions and 14 deletions

View File

@ -108,6 +108,7 @@ namespace Spine.Unity.Editor {
var skeletonGraphic = (SkeletonGraphic)command.context; var skeletonGraphic = (SkeletonGraphic)command.context;
var mesh = skeletonGraphic.SpineMeshGenerator.LastGeneratedMesh; var mesh = skeletonGraphic.SpineMeshGenerator.LastGeneratedMesh;
mesh.RecalculateBounds();
var bounds = mesh.bounds; var bounds = mesh.bounds;
var size = bounds.size; var size = bounds.size;
var center = bounds.center; var center = bounds.center;
@ -120,19 +121,6 @@ namespace Spine.Unity.Editor {
skeletonGraphic.rectTransform.pivot = p; skeletonGraphic.rectTransform.pivot = p;
} }
public static Material DefaultSkeletonGraphicMaterial {
get {
var guids = AssetDatabase.FindAssets("SkeletonGraphicDefault t:material");
if (guids.Length <= 0)
return null;
var firstAssetPath = AssetDatabase.GUIDToAssetPath(guids[0]);
if (string.IsNullOrEmpty(firstAssetPath))
return null;
var firstMaterial = AssetDatabase.LoadAssetAtPath<Material>(firstAssetPath);
return firstMaterial;
}
}
[MenuItem("GameObject/Spine/SkeletonGraphic (UnityUI)", false, 15)] [MenuItem("GameObject/Spine/SkeletonGraphic (UnityUI)", false, 15)]
static public void SkeletonGraphicCreateMenuItem () { static public void SkeletonGraphicCreateMenuItem () {
var parentGameObject = Selection.activeObject as GameObject; var parentGameObject = Selection.activeObject as GameObject;
@ -219,6 +207,19 @@ namespace Spine.Unity.Editor {
return go; return go;
} }
public static Material DefaultSkeletonGraphicMaterial {
get {
var guids = AssetDatabase.FindAssets("SkeletonGraphicDefault t:material");
if (guids.Length <= 0) return null;
var firstAssetPath = AssetDatabase.GUIDToAssetPath(guids[0]);
if (string.IsNullOrEmpty(firstAssetPath)) return null;
var firstMaterial = AssetDatabase.LoadAssetAtPath<Material>(firstAssetPath);
return firstMaterial;
}
}
#endregion #endregion
#endif #endif

View File

@ -1,3 +1,5 @@
// This is a premultiply-alpha adaptation of the built-in Unity shader "UI/Default" to allow Unity UI stencil masking.
Shader "Spine/SkeletonGraphic (Premultiply Alpha)" Shader "Spine/SkeletonGraphic (Premultiply Alpha)"
{ {
Properties Properties
@ -84,7 +86,7 @@ Shader "Spine/SkeletonGraphic (Premultiply Alpha)"
fixed4 frag(v2f IN) : SV_Target fixed4 frag(v2f IN) : SV_Target
{ {
half4 color = tex2D(_MainTex, IN.texcoord) * IN.color; half4 color = tex2D(_MainTex, IN.texcoord) * IN.color;
clip (color.a - 0.01); //clip(color.a - 0.01);
return color; return color;
} }
ENDCG ENDCG