Loads and stores a Spine atlas and list of materials.
Inheritance: UnityEngine.ScriptableObject
Exemple #1
0
    static int CreateRuntimeInstance(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 3 && TypeChecker.CheckTypes <Spine.Unity.AtlasAsset[], bool>(L, 2))
            {
                UnityEngine.TextAsset    arg0 = (UnityEngine.TextAsset)ToLua.CheckObject <UnityEngine.TextAsset>(L, 1);
                Spine.Unity.AtlasAsset[] arg1 = ToLua.ToObjectArray <Spine.Unity.AtlasAsset>(L, 2);
                bool arg2 = LuaDLL.lua_toboolean(L, 3);
                Spine.Unity.SkeletonDataAsset o = Spine.Unity.SkeletonDataAsset.CreateRuntimeInstance(arg0, arg1, arg2);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 3 && TypeChecker.CheckTypes <Spine.Unity.AtlasAsset, bool>(L, 2))
            {
                UnityEngine.TextAsset  arg0 = (UnityEngine.TextAsset)ToLua.CheckObject <UnityEngine.TextAsset>(L, 1);
                Spine.Unity.AtlasAsset arg1 = (Spine.Unity.AtlasAsset)ToLua.ToObject(L, 2);
                bool arg2 = LuaDLL.lua_toboolean(L, 3);
                Spine.Unity.SkeletonDataAsset o = Spine.Unity.SkeletonDataAsset.CreateRuntimeInstance(arg0, arg1, arg2);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes <Spine.Unity.AtlasAsset, bool, float>(L, 2))
            {
                UnityEngine.TextAsset  arg0 = (UnityEngine.TextAsset)ToLua.CheckObject <UnityEngine.TextAsset>(L, 1);
                Spine.Unity.AtlasAsset arg1 = (Spine.Unity.AtlasAsset)ToLua.ToObject(L, 2);
                bool  arg2 = LuaDLL.lua_toboolean(L, 3);
                float arg3 = (float)LuaDLL.lua_tonumber(L, 4);
                Spine.Unity.SkeletonDataAsset o = Spine.Unity.SkeletonDataAsset.CreateRuntimeInstance(arg0, arg1, arg2, arg3);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes <Spine.Unity.AtlasAsset[], bool, float>(L, 2))
            {
                UnityEngine.TextAsset    arg0 = (UnityEngine.TextAsset)ToLua.CheckObject <UnityEngine.TextAsset>(L, 1);
                Spine.Unity.AtlasAsset[] arg1 = ToLua.ToObjectArray <Spine.Unity.AtlasAsset>(L, 2);
                bool  arg2 = LuaDLL.lua_toboolean(L, 3);
                float arg3 = (float)LuaDLL.lua_tonumber(L, 4);
                Spine.Unity.SkeletonDataAsset o = Spine.Unity.SkeletonDataAsset.CreateRuntimeInstance(arg0, arg1, arg2, arg3);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: Spine.Unity.SkeletonDataAsset.CreateRuntimeInstance"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
		/// <summary>
		/// Creates a runtime SkeletonDataAsset.</summary>
		public static SkeletonDataAsset CreateRuntimeInstance (TextAsset skeletonDataFile, AtlasAsset[] atlasAssets, bool initialize, float scale = 0.01f) {
			SkeletonDataAsset skeletonDataAsset = ScriptableObject.CreateInstance<SkeletonDataAsset>();
			skeletonDataAsset.Clear();
			skeletonDataAsset.skeletonJSON = skeletonDataFile;
			skeletonDataAsset.atlasAssets = atlasAssets;
			skeletonDataAsset.scale = scale;

			if (initialize)
				skeletonDataAsset.GetSkeletonData(true);

			return skeletonDataAsset;
		}
Exemple #3
0
        public static AtlasAsset CreateRuntimeInstance(TextAsset atlasText, Material[] materials, bool initialize)
        {
            AtlasAsset atlasAsset = ScriptableObject.CreateInstance <AtlasAsset>();

            atlasAsset.Reset();
            atlasAsset.atlasFile = atlasText;
            atlasAsset.materials = materials;
            if (initialize)
            {
                atlasAsset.GetAtlas();
            }
            return(atlasAsset);
        }
        internal Atlas[] GetAtlasArray()
        {
            List <Atlas> list = new List <Atlas>(this.atlasAssets.Length);

            for (int i = 0; i < this.atlasAssets.Length; i++)
            {
                AtlasAsset asset = this.atlasAssets[i];
                if (asset != null)
                {
                    Atlas item = asset.GetAtlas();
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            return(list.ToArray());
        }
Exemple #5
0
        internal Atlas[] GetAtlasArray()
        {
            List <Atlas> list = new List <Atlas>(atlasAssets.Length);

            for (int i = 0; i < atlasAssets.Length; i++)
            {
                AtlasAsset atlasAsset = atlasAssets[i];
                if (!(atlasAsset == null))
                {
                    Atlas atlas = atlasAsset.GetAtlas();
                    if (atlas != null)
                    {
                        list.Add(atlas);
                    }
                }
            }
            return(list.ToArray());
        }
Exemple #6
0
    public void CreateSpineObject()
    {
        Material material = new Material(Resources.Load("spine/Shaders/Spine-Skeleton") as Shader);

        material.mainTexture = texture;

        Spine.Unity.AtlasAsset atlasAsset = Spine.Unity.AtlasAsset.CreateInstance <Spine.Unity.AtlasAsset>();
        atlasAsset.atlasFile    = atlasText;
        atlasAsset.materials    = new Material[1];
        atlasAsset.materials[0] = material;

        SkeletonDataAsset dataAsset = SkeletonDataAsset.CreateInstance <SkeletonDataAsset>();

        dataAsset.atlasAssets    = new Spine.Unity.AtlasAsset[1];
        dataAsset.atlasAssets[0] = atlasAsset;
        dataAsset.skeletonJSON   = jsonText;
        dataAsset.fromAnimation  = new string[0];
        dataAsset.toAnimation    = new string[0];
        dataAsset.duration       = new float[0];
        dataAsset.defaultMix     = 0.2f;
        dataAsset.scale          = 0.01f;

        GameObject        obj  = gameObject;
        SkeletonAnimation anim = obj.GetComponent <SkeletonAnimation>();

        if (null == anim)
        {
            anim = obj.AddComponent <SkeletonAnimation>();
        }

        meshRenderer = obj.GetComponent <MeshRenderer>();

        if (null == meshRenderer)
        {
            meshRenderer = obj.AddComponent <MeshRenderer>();
        }

        // meshRenderer.sortingLayerName = "spine";
        meshRenderer.sortingOrder  = MeshSortingOrder;
        anim.skeletonDataAsset     = dataAsset;
        oldMesRendererSortingOrder = MeshSortingOrder;

        anim.initialSkinName = "default";

        //anim.Reset();
        anim.loop          = IsLoop;
        anim.AnimationName = DefaultAnimationName;

        //anim.state.Complete += OnCompleteSpineAnim;

        //obj.transform.SetParent(this.gameObject.transform);
        //obj.transform.localPosition = Vector3.zero;
        obj.transform.localScale = SpineScale;

        List <Transform> childrens = new List <Transform>();

        childrens.AddRange(obj.transform.GetComponentsInChildren <Transform>());

        //for (int i = 0; i < childrens.Count; ++i){

        //    childrens[i].gameObject.layer = LayerMask.NameToLayer("UI");
        //}

        anim.Awake();

        //gameObject.SetActive(true);

        IsLoaded = true;
        if (anim.state != null)
        {
            anim.state.Complete += OnAni_Complete;
        }
    }
Exemple #7
0
 /// <summary>
 /// Creates a runtime SkeletonDataAsset.</summary>
 public static SkeletonDataAsset CreateRuntimeInstance(TextAsset skeletonDataFile, AtlasAsset atlasAsset, bool initialize, float scale = 0.01f)
 {
     return(CreateRuntimeInstance(skeletonDataFile, new [] { atlasAsset }, initialize, scale));
 }
Exemple #8
0
 public MaterialsTextureLoader(AtlasAsset atlasAsset)
 {
     this.atlasAsset = atlasAsset;
 }
		/// <summary>
		/// Creates a runtime SkeletonDataAsset.</summary>
		public static SkeletonDataAsset CreateRuntimeInstance (TextAsset skeletonDataFile, AtlasAsset atlasAsset, bool initialize, float scale = 0.01f) {
			return CreateRuntimeInstance(skeletonDataFile, new [] {atlasAsset}, initialize, scale);
		}
		public MaterialsTextureLoader (AtlasAsset atlasAsset) {
			this.atlasAsset = atlasAsset;
		}