public void SetItem(Sprite icon, RuntimeAnimatorController animator, SkeletonDataAsset skeletonData, int id)
    {
        iconIndex = id;
        sprIcon = icon;

        if (skeleton != null && skeletonData != null)
        {
            skeleton.skeletonDataAsset = skeletonData;
            skeleton.Clear();
            skeleton.Initialize(true);

            skeleton.AnimationState.SetAnimation(0, skeletonAnimName, skeletonLoop);
        }

        if (anim != null && animator != null)
        {
            anim.runtimeAnimatorController = animator;
            anim.enabled = true;
            anim.SetTrigger(animStateIdle);
        }
        else if (animator == null)
        {
            if (anim != null)
            {
                anim.enabled = false;
                anim.runtimeAnimatorController = null;
            }
        }

        imgIcon.sprite = icon;
    }
Esempio n. 2
0
    public void land_over_on(GameObject senderObj)
    {
        if (senderObj.GetComponent <build_info>().thema == "")
        {
            return;
        }

        bu_se_mode.GetComponent <Animation>().Play("bu_over_land");

        index              = senderObj.GetComponent <build_info>().index;
        width              = senderObj.GetComponent <build_info>().width;
        target_name        = senderObj.GetComponent <build_info>().name;
        thema              = senderObj.GetComponent <build_info>().thema;
        target_check_value = senderObj.GetComponent <build_info>().target;

        bu_over_thema.text = thema;
        bu_over_width.text = width.ToString();
        bu_over_name.text  = GameObject.Find("inventory_mgr").GetComponent <ItemDB>().items[index - 1].name;;
        bu_over_level.text = "";

        bu_se_mode.SetActive(true);
        skg = bu_spine_img.GetComponent <SkeletonGraphic>();
        skg.skeletonDataAsset = Resources.Load("building/" + thema + "/" + target_name) as SkeletonDataAsset;
        skg.startingAnimation = aniName;
        skg.startingLoop      = true;
        skg.timeScale         = 1.0f;
        skg.Initialize(true);

        targetObj = senderObj;
        bu_spine_img.GetComponent <RectTransform>().anchoredPosition = new Vector2(-32 * width * skg.skeletonDataAsset.scale * 100, -214);
        //
    }
        public static void PlayFromStart(this SkeletonGraphic skeleton, string animationToSet, bool isLoop,
                                         Spine.AnimationState.TrackEntryDelegate OnComplete   = null,
                                         Spine.AnimationState.TrackEntryEventDelegate OnEvent = null)
        {
            TrackEntry trackEntry;

            if (skeleton.AnimationState != null)
            {
                if (skeleton.Skeleton == null)
                {
                    skeleton.Initialize(true);
                }

                skeleton.startingAnimation = animationToSet;
                skeleton.AnimationState.ClearTrack(0);
                trackEntry = skeleton.AnimationState.SetAnimation(0, animationToSet, isLoop);

                if (OnEvent != null)
                {
                    trackEntry.Event += OnEvent;
                }
                if (OnComplete != null)
                {
                    trackEntry.Complete += OnComplete;
                }
            }
        }
Esempio n. 4
0
 public void UpdateSkeleton(string skeletonName)
 {
     if (!string.IsNullOrEmpty(skeletonName))
     {
         SGK.ResourcesManager.LoadAsync(this, string.Format("roles_small/{0}/{0}_SkeletonData.asset", skeletonName), (o) => {
             if (o != null)
             {
                 spine.gameObject.SetActive(true);
                 if (o != spine.skeletonDataAsset)
                 {
                     spine.skeletonDataAsset = o as SkeletonDataAsset;
                     spine.Initialize(true);
                     spine.AnimationState.SetAnimation(0, animationName, true);
                 }
             }
             else
             {
                 spine.gameObject.SetActive(false);
             }
         });
     }
     else
     {
         spine.gameObject.SetActive(false);
     }
 }
Esempio n. 5
0
        public override void Dispose()
        {
            Graphic_.Initialize(false);
            Graphic_.AnimationState.ClearTracks();

            base.Dispose();
        }
Esempio n. 6
0
        /// <summary>
        /// 加载骨骼数据
        /// </summary>
        /// <param name="dataAssetName"></param>
        async CTask LoadSkeletonData(string dataAssetName)
        {
            _isLoaded     = false;
            _dataAsstName = dataAssetName;
            dataAsset     = await LoadHelper.LoadSkeletonData(dataAssetName);

            if (skeletonGraphic == null)
            {
                CLog.Error("获取物体骨骼动画组件错误");
                return;
            }

            skeletonGraphic.skeletonDataAsset = dataAsset;
            skeletonGraphic.Initialize(true);
            animations  = skeletonGraphic.skeletonDataAsset.GetSkeletonData(true).Animations.Items;
            aniNameList = new List <string>();
            for (int i = 0; i < animations.Length; i++)
            {
                aniNameList.Add(animations[i].Name);
            }

            PlayStaticAnimation();
            skeletonGraphic.AnimationState.TimeScale = 1;
            if (modelSetting != null)
            {
                skeletonGraphic.gameObject.transform.localScale = Vector3.one * modelSetting.Pos[1][2];
            }
            _isLoaded = true;
        }
Esempio n. 7
0
        void OnEnable()
        {
            skeletonUtility  = (SkeletonUtility)target;
            skeletonRenderer = skeletonUtility.skeletonRenderer;
            skeletonGraphic  = skeletonUtility.skeletonGraphic;
            skeleton         = skeletonUtility.Skeleton;

            if (skeleton == null)
            {
                if (skeletonRenderer != null)
                {
                    skeletonRenderer.Initialize(false);
                    skeletonRenderer.LateUpdate();
                }
                else if (skeletonGraphic != null)
                {
                    skeletonGraphic.Initialize(false);
                    skeletonGraphic.LateUpdate();
                }
                skeleton = skeletonUtility.Skeleton;
            }

            if ((skeletonRenderer != null && !skeletonRenderer.valid) ||
                (skeletonGraphic != null && !skeletonGraphic.IsValid))
            {
                return;
            }

#if !NEW_PREFAB_SYSTEM
            isPrefab |= PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab;
#endif
        }
Esempio n. 8
0
    public void build_over_on(GameObject senderObj)
    {
        if (tp != type.basic)
        {
            return;
        }

        bu_se_mode.GetComponent <Animation>().Play("bu_over_inven");
        bu_se_mode.SetActive(true);
        //
        width       = senderObj.GetComponent <test_info>().width_;
        index       = senderObj.GetComponent <test_info>().index;
        thema       = senderObj.GetComponent <test_info>().thema;
        level       = senderObj.GetComponent <test_info>().level;
        target_name = senderObj.GetComponent <test_info>().name_;
        //GameObject.Find("inventory_mgr").GetComponent<ItemDB>().items[index-1].name;
        bu_over_thema.text = thema;
        bu_over_width.text = width.ToString();
        bu_over_name.text  = GameObject.Find("inventory_mgr").GetComponent <ItemDB>().items[index - 1].name;
        bu_over_level.text = "Lv " + level.ToString();
        //bu_over_effect;
        //
        skg = bu_spine_img.GetComponent <SkeletonGraphic>();
        skg.skeletonDataAsset = Resources.Load("building/" + thema + "/" + target_name) as SkeletonDataAsset;
        skg.startingAnimation = aniName;
        skg.startingLoop      = true;
        skg.timeScale         = 1.0f;
        skg.Initialize(true);

        bu_spine_img.GetComponent <RectTransform>().anchoredPosition = new Vector2(-32 * width * skg.skeletonDataAsset.scale * 100, -214);
        //
        targetObj = senderObj;
    }
Esempio n. 9
0
 public void LoadAsset(InfoFigure info)
 {
     if (info.asset != null)
     {
         skeleton.skeletonDataAsset = info.asset;
         skeleton.startingLoop      = true;
         skeleton.Initialize(true);
     }
 }
Esempio n. 10
0
    private void AnimationState_Complete(Spine.TrackEntry trackEntry)
    {
        int r = Random.Range(0, 8);

        skg = this.GetComponent <SkeletonGraphic>();
        skg.startingAnimation = firwork_name[r];
        skg.Initialize(true);
        skg.AnimationState.Complete += AnimationState_Complete;
    }
Esempio n. 11
0
    void OnEnable()
    {
        int r = Random.Range(0, 8);

        skg = this.GetComponent <SkeletonGraphic>();
        skg.startingAnimation = firwork_name[r];
        skg.startingLoop      = true;
        skg.timeScale         = 1f;
        skg.Initialize(true);
    }
        void Initialize(bool overwrite)
        {
            if (m_isInitialized && !overwrite)
            {
                return;
            }

            skeletonGraphic.Initialize(false);

            m_isInitialized = true;
        }
Esempio n. 13
0
    public void OnShow(InfoFigure info)
    {
        this.Show();
        AudioManager1.Ins.PlaySound(SoundType.UnlockFigure);
        UIManager.Ins.popup.PlayComeReward();
        UIManager.Ins.UpdatePlayerMasks(info.idFigure);
        asset.skeletonDataAsset = info.asset;
        asset.startingLoop      = true;
        asset.Initialize(true);

        nameFigure.text = info.heroName;
        StartCoroutine(ShowRewardClaimed());
    }
Esempio n. 14
0
 public static void ReinitializeComponent(SkeletonGraphic component)
 {
     if (component == null)
     {
         return;
     }
     if (!SkeletonDataAssetIsValid(component.SkeletonDataAsset))
     {
         return;
     }
     component.Initialize(true);
     component.LateUpdate();
 }
Esempio n. 15
0
 static void AfterLoad(SkeletonGraphic skeletonGraphic, SkeletonDataAsset skeletonDataAsset, string[] actions = null)
 {
     skeletonGraphic.skeletonDataAsset = skeletonDataAsset;
     if (actions == null && actions.Length >= 1)
     {
         skeletonGraphic.startingAnimation = actions[0];
     }
     skeletonGraphic.Initialize(true);
     if (skeletonGraphic.AnimationState != null && actions != null)
     {
         for (int i = 0; i < actions.Length; i++)
         {
             skeletonGraphic.AnimationState.SetAnimation(i, actions[i], (i == (actions.Length - 1)));
         }
     }
 }
        //===============================================================

        #region Skeleton Graphic Animation

        public static void Play(this SkeletonGraphic skeleton, string animationToSet, bool isLoop,
                                Spine.AnimationState.TrackEntryDelegate OnComplete   = null,
                                Spine.AnimationState.TrackEntryEventDelegate OnEvent = null)
        {
            TrackEntry trackEntry;

            if (skeleton.AnimationState != null)
            {
                if (skeleton.Skeleton == null)
                {
                    skeleton.Initialize(true);
                }

                bool hasAnim = false;
                foreach (var anim in skeleton.Skeleton.Data.Animations)
                {
                    if (anim.Name == animationToSet)
                    {
                        hasAnim = true;
                    }
                }
                if (!hasAnim)
                {
                    return;
                }

                if (skeleton.startingAnimation != animationToSet)
                {
                    skeleton.startingAnimation = animationToSet;
                    skeleton.AnimationState.ClearTrack(0);
                    trackEntry = skeleton.AnimationState.SetAnimation(0, animationToSet, isLoop);
                }
                else
                {
                    trackEntry = skeleton.AnimationState.AddAnimation(0, animationToSet, isLoop, 0f);
                }

                if (OnEvent != null)
                {
                    trackEntry.Event += OnEvent;
                }
                if (OnComplete != null)
                {
                    trackEntry.Complete += OnComplete;
                }
            }
        }
Esempio n. 17
0
        private void onLoadOver()
        {
            SkeletonDataAsset asset = LoadControl.getUnityObjectByType <SkeletonDataAsset>(_loadTool.getResourceID());

            if (asset != null)
            {
                setLoading(false);

                _skeletonGraphic.skeletonDataAsset = asset;
                _skeletonGraphic.startingAnimation = "";
                _skeletonGraphic.Initialize(true);
            }

            if (_overFunc != null)
            {
                _overFunc();
            }
        }
Esempio n. 18
0
    public void Init(string spineId, SkeletonGraphic skg, string animationName)
    {
        _skg           = skg;
        _animationName = animationName;

        SkeletonDataAsset skData = SpineUtil.BuildSkeletonDataAsset(spineId, skg);

        skg.skeletonDataAsset = skData;
        skg.Initialize(true);
        skg.AnimationState.SetAnimation(0, animationName, true);

        _rect            = skg.GetComponent <RectTransform>();
        _rect.pivot      = new Vector2(0.5f, 0f);
        _rect.anchorMin  = new Vector2(0.5f, 0.5f);
        _rect.anchorMax  = new Vector2(0.5f, 0.5f);
        _rect.sizeDelta  = new Vector2(300, 500);
        _rect.localScale = new Vector3(0.5f, 0.5f, 1);
        CurDerection     = 0;
    }
Esempio n. 19
0
    public void SetUp(InfoFigure info)
    {
        nameTxt.text = info.heroName;
        if (info.asset != null)
        {
            skeleton.skeletonDataAsset = info.asset;
            skeleton.startingLoop      = true;
            skeleton.Initialize(true);
        }

        if (info.isUsing)
        {
            HideAllCostType();
            costTypePre[1].Show();
        }
        else if (info.isBuy)
        {
            HideAllCostType();
        }
        else if (info.costType == CostType.Coin)
        {
            HideAllCostType();
            costTypePre[0].Show();
            costTxt.text = info.cost.ToString();
        }
        else if (info.costType == CostType.Video)
        {
            HideAllCostType();
            costTypePre[2].Show();
        }
        else if (info.costType == CostType.Vip)
        {
            HideAllCostType();
            costTypePre[3].GetComponent <Text>().text = "Vip";
            costTypePre[3].Show();
        }
        else
        {
            HideAllCostType();
            costTypePre[3].Show();
        }
    }
Esempio n. 20
0
    void spine_building_(int parent, int target, Dnditem dnditem)
    {
        GameObject      GO;
        SkeletonGraphic skg;

        switch (parent)
        {
        case 1:
            GO  = view1.transform.GetChild(target).gameObject;
            skg = GO.GetComponent <SkeletonGraphic>();
            skg.skeletonDataAsset = Resources.Load("building/" + dnditem.thema + "/" + dnditem.spine_name + "_1") as SkeletonDataAsset;
            skg.startingAnimation = sky_check();
            skg.startingLoop      = true;
            skg.timeScale         = 1f;
            skg.Initialize(true);
            GO.SetActive(true);
            break;

        case 2:
            GO  = view2.transform.GetChild(target).gameObject;
            skg = GO.GetComponent <SkeletonGraphic>();
            skg.skeletonDataAsset = Resources.Load("building/" + dnditem.thema + "/" + dnditem.spine_name + "_2") as SkeletonDataAsset;
            skg.startingAnimation = sky_check();
            skg.startingLoop      = true;
            skg.timeScale         = 1f;
            skg.Initialize(true);
            GO.SetActive(true);
            break;

        case 3:
            GO  = view3.transform.GetChild(target).gameObject;
            skg = GO.GetComponent <SkeletonGraphic>();
            skg.skeletonDataAsset = Resources.Load("building/" + dnditem.thema + "/" + dnditem.spine_name + "_3") as SkeletonDataAsset;
            skg.startingAnimation = sky_check();
            skg.startingLoop      = true;
            skg.timeScale         = 1f;
            skg.Initialize(true);
            GO.SetActive(true);
            break;
        }
    }
Esempio n. 21
0
        public void LoadAnimation(string spineId, List <SpinePlayableVo> playableList = null, bool autoInit = true)
        {
            _skg = GetComponent <SkeletonGraphic>();

//            RectTransform rect = GetComponent<RectTransform>();
//            rect.pivot = new Vector2(0.5f, 0);
//            rect.sizeDelta = new Vector2(388,388);

            SkeletonDataAsset skData = SpineUtil.BuildSkeletonDataAsset(spineId, _skg);

            _skg.skeletonDataAsset = skData;

            _playableList = playableList;

            _skg.Initialize(true);

            if (autoInit && playableList != null)
            {
                _sequence = new SpinePlaySequence(_skg, _playableList);
                _sequence.Play();
            }
        }
Esempio n. 22
0
    public void Init(string name, string text, SkeletonDataAsset skeletonDataAsset, AnimationReferenceAsset animation, Color backColor)
    {
        if (!string.IsNullOrEmpty(name) && nameTextField)
        {
            nameTextField.text = name;
        }

        textTextField.text = text;

        if (avatar)
        {
            avatar.gameObject?.SetActive(false);
        }

        back.color = backColor;

        spineParent.gameObject.SetActive(true);
        spineSkeleton.Clear();
        spineSkeleton.skeletonDataAsset = skeletonDataAsset;
        spineSkeleton.Initialize(true);
        spineSkeleton.AnimationState.SetAnimation(0, animation, true);
    }
Esempio n. 23
0
    /**public SkeletonAnimation getSpine(string spineName){
     *      if (!spinePool.ContainsKey (spineName)) {
     *              SkeletonDataAsset yourSkeletonDataAsset = Resources.Load<SkeletonDataAsset> ("spine/" + spineName + "/" + spineName + "_SkeletonData");
     *              SkeletonAnimation newSkeletonAnimation = SkeletonAnimation.NewSkeletonAnimationGameObject (yourSkeletonDataAsset);
     *              //heroscene.DontDestroyOnLoad(newSkeletonAnimation.transform.gameObject);
     *              newSkeletonAnimation.calculateNormals = true;
     *              newSkeletonAnimation.loop = true;
     *              newSkeletonAnimation.AnimationName = "stand";
     *              newSkeletonAnimation.transform.localPosition = new Vector3 (0.0f, -0.5f, 0.0f);
     *
     *              spinePool [spineName] = newSkeletonAnimation;
     *      } else if (spinePool [spineName] == null) {
     *              spinePool.Remove (spineName);
     *              getSpine (spineName);
     *      }
     *      return spinePool [spineName];
     * }
     **/
    public SkeletonGraphic getSkeletonGraphic(string spineName, SkeletonGraphic demo)
    {
        if (!spinePool.ContainsKey(spineName))
        {
            SkeletonDataAsset yourSkeletonDataAsset = Resources.Load <SkeletonDataAsset> ("spine/" + spineName + "/" + spineName + "_SkeletonData");
            SkeletonGraphic   skeletonGraphic       = (SkeletonGraphic)GameObject.Instantiate(demo, demo.transform.localPosition, demo.transform.localRotation);
            //heroscene.DontDestroyOnLoad(newSkeletonAnimation.transform.gameObject);
            skeletonGraphic.skeletonDataAsset = yourSkeletonDataAsset;
            skeletonGraphic.Initialize(true);
            skeletonGraphic.timeScale    = 1;
            skeletonGraphic.unscaledTime = true;
            skeletonGraphic.AnimationState.SetAnimation(0, "stand", true);


            spinePool [spineName] = skeletonGraphic;
        }
        else if (spinePool [spineName] == null)
        {
            spinePool.Remove(spineName);
            getSkeletonGraphic(spineName, demo);
        }
        return(spinePool [spineName]);
    }
 public void Change(SkeletonDataAsset asset)
 {
     spineGraphic.skeletonDataAsset = asset;
     spineGraphic.startingAnimation = "idle";
     spineGraphic.Initialize(true);
 }
Esempio n. 25
0
        // Token: 0x06008ACF RID: 35535 RVA: 0x00287120 File Offset: 0x00285320
        public bool Create(string assetName)
        {
            this.Destroy();
            if (string.IsNullOrEmpty(assetName))
            {
                return(false);
            }
            this.m_assetName  = assetName;
            this.m_gameObject = new GameObject(GameObjectUtility.GetDefaultName(assetName));
            GameObject asset = AssetUtility.Instance.GetAsset <GameObject>(assetName);

            if (asset == null)
            {
                global::Debug.LogWarning("UISpineGraphic.Create GetAsset " + assetName + " fail.");
                this.Destroy();
                return(false);
            }
            SkeletonAnimation component = asset.GetComponent <SkeletonAnimation>();

            if (!(component != null))
            {
                global::Debug.LogWarning(assetName + " not spine prefab.");
                this.Destroy();
                return(false);
            }
            SkeletonGraphic skeletonGraphic = this.m_gameObject.AddComponent <SkeletonGraphic>();
            Texture         texture         = null;
            Renderer        component2      = asset.GetComponent <Renderer>();
            string          text            = string.Empty;

            if (component2 != null && component2.sharedMaterial != null)
            {
                if (component2.sharedMaterial.HasProperty("_AlphaTex"))
                {
                    texture = component2.sharedMaterial.GetTexture("_AlphaTex");
                }
                text = component2.sharedMaterial.shader.name;
            }
            if (texture != null)
            {
                if (text.Contains("Skeleton2_SepAlpha"))
                {
                    this.m_material = new Material(AssetUtility.Instance.GetAsset <Material>("UI/Common_New_ABS/Material/UISpine2_SepAlpha.mat"));
                }
                else
                {
                    this.m_material = new Material(AssetUtility.Instance.GetAsset <Material>("UI/Common_New_ABS/Material/UISpine_SepAlpha.mat"));
                }
                this.m_material.SetTexture("_AlphaTex", texture);
                skeletonGraphic.material = this.m_material;
            }
            else if (text.Contains("Skeleton2"))
            {
                skeletonGraphic.material = AssetUtility.Instance.GetAsset <Material>("UI/Common_New_ABS/Material/UISpine2.mat");
            }
            else
            {
                skeletonGraphic.material = AssetUtility.Instance.GetAsset <Material>("UI/Common_New_ABS/Material/UISpine.mat");
            }
            skeletonGraphic.initialSkinName   = component.initialSkinName;
            skeletonGraphic.skeletonDataAsset = component.skeletonDataAsset;
            skeletonGraphic.raycastTarget     = false;
            skeletonGraphic.startingAnimation = component._animationName;
            skeletonGraphic.startingLoop      = component.loop;
            skeletonGraphic.Initialize(false);
            if (!skeletonGraphic.IsValid)
            {
                global::Debug.LogWarning("Spine " + assetName + " error.");
                this.Destroy();
                return(false);
            }
            this.m_spine = skeletonGraphic;
            this.m_spine.AnimationState.Event += this.HandleSpineAnimationEvent;
            this.m_spine.AnimationState.Start += this.HandleSpineAnimationStart;
            this.m_spine.AnimationState.End   += this.HandleSpineAnimationEnd;
            return(true);
        }
Esempio n. 26
0
 public SkeletonSfx(string Name, Transform Trans)
     : base(Name, Trans)
 {
     Graphic_ = GetComponent <SkeletonGraphic>();
     Graphic_.Initialize(false);
 }