private void InitScoreBarActor() { m_RhythmBeatInterval = m_RhythmBeatInterval = 60000f / CorePlayData.CurrentSong.BPM; LogManager.LogWarning("m_RhythmBeatInterval calcula: ", m_RhythmBeatInterval); int nDefaultModelId = 20001; int nDefaultMotinId = 30003; //get id from selfdata int nModelId = string.IsNullOrEmpty(SelfPlayerData.ModelId) || SelfPlayerData.ModelId == "0" ? nDefaultModelId : int.Parse(SelfPlayerData.ModelId); int nMotionId = string.IsNullOrEmpty(SelfPlayerData.EmotionId) || SelfPlayerData.ModelId == "0" ? nDefaultMotinId : int.Parse(SelfPlayerData.EmotionId); string strModelName = RoleModelConfig.Instance.GetNameById(nModelId); string strMotionName = RoleEmotionConfig.Instance.GetNameById(nMotionId); SkeletonAnimation obj = Resources.Load <SkeletonAnimation> ("RoleCreate/Role/" + strModelName); m_scoreBarActor = SkeletonGraphic.NewSkeletonGraphicGameObject(obj.SkeletonDataAsset, m_mainSlider.transform); m_scoreBarActor.transform.localPosition = new Vector3(-855f, -20f, 0); m_scoreBarActor.transform.localScale = new Vector3(0.15f, 0.12f, 0.15f); m_scoreBarActor.Skeleton.SetSkin(strMotionName); PlayBarActorAnimation(); m_scoreBarActor.AnimationState.Complete += OnAniCom; }
private void LoadSpine(int unitid) { SkeletonDataAsset dataAsset = ScriptableObject.CreateInstance <SkeletonDataAsset>(); dataAsset = Resources.Load <SkeletonDataAsset>("Unit/" + unitid + "/" + unitid + "_SkeletonData"); int motiontype = MainManager.Instance.UnitRarityDic[unitid].detailData.motionType; string motiontype_str = motiontype < 10 ? "0" + motiontype : "" + motiontype; var spineAnimation = dataAsset.GetSkeletonData(false).FindAnimation(motiontype_str + "_idle"); var sa = SkeletonGraphic.NewSkeletonGraphicGameObject(dataAsset, parent.transform); if (spineAnimation != null) { sa.Initialize(false); sa.AnimationState.SetAnimation(0, spineAnimation, true); } spine = sa.gameObject; spine.transform.localPosition = spinePosition; spine.transform.localScale = spineScale; }
public void InitAssetInUI() { Debug.Log("INITCharacter_UI"); SkeletonData.GetSkeletonData(false); // Preload SkeletonDataAsset. if (ModelParent.childCount == 0) { Material m = Resources.LoadAll <Material>("Spine/spineGraphic").ToList() .Find(x => x.name.Contains("default")); var sa = SkeletonGraphic.NewSkeletonGraphicGameObject (SkeletonData, ModelParent, m); sa.name = "MODE_SINGLEROLE"; sa.rectTransform.localScale = Vector3.one * scaleRate; Vector2 p0 = new Vector2(this.GetComponent <RectTransform>().anchoredPosition.x / this.GetComponent <RectTransform>().localScale.x , this.GetComponent <RectTransform>().anchoredPosition.y / this.GetComponent <RectTransform>().localScale.y ); Vector2 p1 = new Vector2(ModelParent.GetComponent <RectTransform>().anchoredPosition.x / ModelParent.GetComponent <RectTransform>().localScale.x , ModelParent.GetComponent <RectTransform>().anchoredPosition.y / ModelParent.GetComponent <RectTransform>().localScale.y ); sa.rectTransform.anchoredPosition = isModelAlignBottom? p0 - p1:Vector2.zero; // sa.gameObject.AddComponent <Model_ColorInitialize>(); cm_g = sa.gameObject.AddComponent <CharacterModel_graphic>(); CurrentCharacterModel.CMC = this; CurrentCharacterModel.DataAsset = SkeletonData; // CurrentCharacterModel.initCharacterModel(); } else { if (ModelParent.GetComponentInChildren <CharacterModel_graphic>()) { ModelParent.GetComponentInChildren <CharacterModel_graphic>() .initCharacterModel(); } } }
IEnumerator Start() { if (skeletonDataAsset == null) { yield break; } skeletonDataAsset.GetSkeletonData(false); // Preload SkeletonDataAsset. yield return(new WaitForSeconds(1f)); // Pretend stuff is happening. var sg = SkeletonGraphic.NewSkeletonGraphicGameObject(skeletonDataAsset, this.transform, skeletonGraphicMaterial); // Spawn a new SkeletonGraphic GameObject. sg.gameObject.name = "SkeletonGraphic Instance"; // Extra Stuff sg.Initialize(false); sg.Skeleton.SetSkin(startingSkin); sg.Skeleton.SetSlotsToSetupPose(); sg.AnimationState.SetAnimation(0, startingAnimation, true); }
/// <summary> /// /// </summary> /// <param name="parent"></param> /// <param name="abName"></param> /// <param name="assetName"></param> /// <param name="actionName"></param> /// <param name="isLoop"></param> /// <returns></returns> public void NewUISpineAni(string viewId, GameObject parent, string abName, string assetName, LuaFunction callback, string actionName = "", bool isLoop = true, bool hasButton = false, string name = null) { ResourceManager.Instance.LoadPrefabAsync(viewId, abName, delegate(AssetBundle assetBundle) { if (assetBundle == null) { DebugManager.LogError("NewUISpineAni Error:下载资源失败!" + abName + "," + assetName); return; } SkeletonDataAsset skeletonDataAsset = assetBundle.LoadAsset <SkeletonDataAsset>(assetName + "_SkeletonData"); SkeletonGraphic graphic = SkeletonGraphic.NewSkeletonGraphicGameObject(skeletonDataAsset, parent.transform); graphic.material = new Material(Shader.Find("Spine/SkeletonGraphic (Premultiply Alpha)")); if (actionName != "") { graphic.AnimationState.SetAnimation(0, actionName, isLoop); } graphic.gameObject.transform.localPosition = new Vector3(0, 0, 0); if (name != null) { graphic.gameObject.name = name; } else { graphic.gameObject.name = "Spi_" + assetName; } if (hasButton == true) { graphic.gameObject.AddComponent <UnityEngine.UI.Button>(); } if (callback != null) { callback.Call(graphic); callback.Dispose(); } }); }