public void Initialize(bool overwrite = true) { if (overwrite || (this.attachment == null)) { ISkeletonComponent component = base.GetComponent <ISkeletonComponent>(); SkeletonRenderer renderer = component as SkeletonRenderer; if (renderer != null) { this.applyPMA = renderer.pmaVertexColors; } else { SkeletonGraphic graphic = component as SkeletonGraphic; if (graphic != null) { this.applyPMA = graphic.MeshGenerator.settings.pmaVertexColors; } } if (this.overrideAnimation) { ISkeletonAnimation animation = component as ISkeletonAnimation; if (animation != null) { animation.UpdateComplete -= new UpdateBonesDelegate(this.AnimationOverrideSpriteAttach); animation.UpdateComplete += new UpdateBonesDelegate(this.AnimationOverrideSpriteAttach); } } if (this.spineSlot == null) { } this.spineSlot = component.Skeleton.FindSlot(this.slot); Shader shader = !this.applyPMA ? Shader.Find("Sprites/Default") : Shader.Find("Spine/Skeleton"); this.attachment = !this.applyPMA ? this.sprite.ToRegionAttachment(GetPageFor(this.sprite.texture, shader), 0f) : this.sprite.ToRegionAttachmentPMAClone(shader, TextureFormat.RGBA32, false, null, 0f); } }
void InitializeReference() { if (skeletonGraphic == null) { skeletonGraphic = GetComponent <SkeletonGraphic>(); } }
// Use this for initialization void Start() { skeletonGraphic = GetComponent <SkeletonGraphic>(); skeletonGraphic.AnimationState.SetAnimation(0, "Grow_animation", false); skeletonGraphic.AnimationState.AddAnimation(0, "Idle_animation", true, 0f); skeletonGraphic.AnimationState.AddAnimation(1, "IdleLeaves_animation", true, 0f); }
public void ShowLose() { JToken hintString = SelectedMissions[minigameIndex]["hintlose"]; Text hintField = loseHintField.GetComponent <Text>(); //hintField.text = hintString.ToString(); hintField.text = LocalizationManager.GetTranslation(hintString.ToString()); ///REMOVE ACTIVE MINIGAME FROM SCREEN JToken sceneName = SelectedMissions[minigameIndex]["sceneid"]; SceneManager.UnloadSceneAsync(sceneName.ToString()); loseGame.SetActive(true); SkeletonGraphic graphic = loseGameSadChar.GetComponent <SkeletonGraphic> (); graphic.AnimationState.SetAnimation(0, "sad", false); Text continueText = continueLoseText.GetComponent <Text>(); if (minigameIndex + 1 >= SelectedMissions.Count) { continueText.text = LocalizationManager.GetTranslation("MinigameBackToMap"); } else { continueText.text = LocalizationManager.GetTranslation("MinigameContinueLocaleKey"); } continueLoseButton.GetComponent <Button> ().onClick.AddListener(PlayNextMiniGame); }
public static List <GameObject> AddAllBoundingBoxFollowerGraphicChildren( SkeletonGraphic skeletonGraphic, BoundingBoxFollowerGraphic original = null) { List <GameObject> createdGameObjects = new List <GameObject>(); foreach (var skin in skeletonGraphic.Skeleton.Data.Skins) { var attachments = skin.Attachments; foreach (var entry in attachments) { var boundingBoxAttachment = entry.Attachment as BoundingBoxAttachment; if (boundingBoxAttachment == null) { continue; } int slotIndex = entry.SlotIndex; var slot = skeletonGraphic.Skeleton.Slots.Items[slotIndex]; string slotName = slot.Data.Name; GameObject go = AddBoundingBoxFollowerGraphicChild(skeletonGraphic, original, boundingBoxAttachment.Name, slotName); var boneFollower = go.AddComponent <BoneFollowerGraphic>(); boneFollower.skeletonGraphic = skeletonGraphic; boneFollower.SetBone(slot.Data.BoneData.Name); createdGameObjects.Add(go); } } return(createdGameObjects); }
public static GameObject AddBoundingBoxFollowerGraphicChild(SkeletonGraphic skeletonGraphic, BoundingBoxFollowerGraphic original = null, string name = "BoundingBoxFollowerGraphic", string slotName = null) { var go = EditorInstantiation.NewGameObject(name, true); go.transform.SetParent(skeletonGraphic.transform, false); go.AddComponent <RectTransform>(); var newFollower = go.AddComponent <BoundingBoxFollowerGraphic>(); if (original != null) { newFollower.slotName = original.slotName; newFollower.isTrigger = original.isTrigger; newFollower.usedByEffector = original.usedByEffector; newFollower.usedByComposite = original.usedByComposite; newFollower.clearStateOnDisable = original.clearStateOnDisable; } if (slotName != null) { newFollower.slotName = slotName; } newFollower.skeletonGraphic = skeletonGraphic; newFollower.Initialize(); Selection.activeGameObject = go; EditorGUIUtility.PingObject(go); return(go); }
public void setGoodState() { if (!originalStateBad) { GameSound.gameSound.PlaySFX("error"); mdb.loseTime(1.0f); if (changeableColor) { changeableColor.changeColor(false); } } if (isGood) { return; } if (GoodSound != "") { GameSound.gameSound.PlaySFX(GoodSound); } GameSound.gameSound.PlaySFX("tap"); isGood = true; if (changeableColor) { changeableColor.changeColor(true); } if (!itemSkeleton) { itemSkeleton = this.gameObject.GetComponent <SkeletonGraphic>(); } itemSkeleton.AnimationState.SetAnimation(0, goodAnimation, false); }
public void Attach() { ISkeletonComponent component = base.GetComponent <ISkeletonComponent>(); SkeletonRenderer skeletonRenderer = component as SkeletonRenderer; if (skeletonRenderer != null) { this.applyPMA = skeletonRenderer.pmaVertexColors; } else { SkeletonGraphic skeletonGraphic = component as SkeletonGraphic; if (skeletonGraphic != null) { this.applyPMA = skeletonGraphic.SpineMeshGenerator.PremultiplyVertexColors; } } Shader shader = (!this.applyPMA) ? Shader.Find("Sprites/Default") : Shader.Find("Spine/Skeleton"); this.loader = (this.loader ?? new SpriteAttachmentLoader(this.sprite, shader, this.applyPMA)); if (this.attachment == null) { this.attachment = this.loader.NewRegionAttachment(null, this.sprite.name, string.Empty); } component.Skeleton.FindSlot(this.slot).Attachment = this.attachment; if (!this.keepLoaderInMemory) { this.loader = null; } }
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 IEnumerator IEPlay(this SkeletonGraphic skeleton, string animationToSet, bool isLoop, Spine.AnimationState.TrackEntryDelegate OnComplete = null, Spine.AnimationState.TrackEntryEventDelegate OnEvent = null) { TrackEntry trackEntry; 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, 0); } if (OnEvent != null) { trackEntry.Event += OnEvent; } if (OnComplete != null) { trackEntry.Complete += OnComplete; } yield return(new WaitForSeconds(trackEntry.AnimationTime)); }
void Awake() { graphic = GetComponent <SkeletonGraphic>(); graphic.raycastTarget = false; switch (transform.name) { case "JoinRoom": matName = "ZhuangSp_Material"; break; case "ZhuangSp": matName = "ZhuangSp_Material"; break; case "HuDie": matName = "HuDie_0_Material"; break; case "Fmsp": matName = "Fmsp_Material"; break; case "LogoSp": matName = "LogoSp_Material"; break; default: matName = "SkeletonGraphicUI"; break; } spineMat = Resources.Load <Material>("Spine/" + matName); }
static void MatchRectTransformWithBounds(SkeletonGraphic skeletonGraphic) { if (!skeletonGraphic.MatchRectTransformWithBounds()) { Debug.Log("Mesh was not previously generated."); } }
void OnEnable() { if (skeletonGraphic == null) { skeletonGraphic = GetComponent <SkeletonGraphic>(); } }
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 }
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; } } }
// Use this for initialization void Start() { mdb = this.gameObject.GetComponent <MiniGameDefaultBehavior> (); panGraph = panObject.GetComponent <SkeletonGraphic> (); fillObject = oilObjects [fillOBjectIndex]; bottleObject = bottleObjects[fillOBjectIndex]; }
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 InstantiateNewUnitAnimation() { if (_animationInstance != null) { Destroy(_animationInstance); } var animationPrefab = UnitsAnimationReferences.animationReferences.First((reference) => reference.UnitType == _model.Type); _animationInstance = Instantiate(animationPrefab.AnimationUI, transform); var rectTransform = _animationInstance.GetComponent <RectTransform>(); rectTransform.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Bottom, 0f, 0f); rectTransform.anchoredPosition = Vector2.zero; rectTransform.localScale = new Vector3(3, 3, 3); _skeletonGraphic = _animationInstance.GetComponent <SkeletonGraphic>(); _skeletonGraphic.AnimationState.Complete += SetLoopingAnimationWithUnitState; // scale unit by screen dimensions float localScale = (Screen.width / 4f) / _skeletonGraphic.SkeletonData.Width; rectTransform.localScale = new Vector3(localScale, localScale); SetSkeletonMissingBodyPartColor(0); SetLoopingAnimationWithUnitState(); }
public static void PlayAnimation(SkeletonGraphic sg, int trackIndex, string animName, bool isLoop, float speed = 1f) { ExposedList <Spine.Animation> anims = sg.Skeleton.Data.Animations; string strCurrAnimation = string.Empty; if (trackIndex == 0) { strCurrAnimation = sg.AnimationState.GetCurrent(0).Animation.Name; } for (int i = 0; i < anims.Count; i++) { if (anims.Items[i].Name.Equals(animName)) { TrackEntry entry = sg.AnimationState.SetAnimation(trackIndex, animName, isLoop); entry.TimeScale = speed; if (!isLoop && trackIndex == 0 && !strCurrAnimation.Equals(string.Empty)) { sg.AnimationState.AddAnimation(0, strCurrAnimation, true, 0); } break; } } }
private bool MatchRectTransformWithBounds_lowVersionCompatablity(SkeletonGraphic skeletonGraphic) { skeletonGraphic.UpdateMesh(); Mesh mesh = skeletonGraphic.GetLastMesh(); if (mesh == null) { return(false); } if (mesh.vertexCount == 0) { skeletonGraphic.rectTransform.sizeDelta = new Vector2(50f, 50f); skeletonGraphic.rectTransform.pivot = new Vector2(0.5f, 0.5f); return(false); } mesh.RecalculateBounds(); var bounds = mesh.bounds; var size = bounds.size; var center = bounds.center; var p = new Vector2( 0.5f - (center.x / size.x), 0.5f - (center.y / size.y) ); skeletonGraphic.rectTransform.sizeDelta = size; skeletonGraphic.rectTransform.pivot = p; return(true); }
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; }
public void SetSkinUI(SkeletonGraphic skeletonAnimation, string skin) { // 设置皮肤 skeletonAnimation.Skeleton.SetSkin(skin); // 设置姿势 skeletonAnimation.Skeleton.SetSlotsToSetupPose(); }
private void CreateSpine(EntityVo entity, int spineIndex, int childIndex) { GameObject go = null; if (_spineCache.Count < spineIndex) { go = InstantiatePrefab("Spine/SpineSkeletonGraphic"); SkeletonGraphic skeletonGraphic = go.GetComponent <SkeletonGraphic>(); _spineCache.Add(skeletonGraphic); } else { go = _spineCache[spineIndex - 1].gameObject; } SpineHeadAnimation sha = go.GetComponent <SpineHeadAnimation>(); sha.LoadAnimation(entity.id, entity.playableList); go.transform.SetParent(transform, false); RectTransform rt = go.GetComponent <RectTransform>(); rt.pivot = new Vector2(0.5f, 0); rt.sizeDelta = new Vector2(entity.width, entity.height); rt.anchoredPosition = new Vector2(entity.x, entity.y - _offsetY); rt.SetSiblingIndex(childIndex); }
void OnEnable() { #if NEW_PREFAB_SYSTEM isInspectingPrefab = false; #else isInspectingPrefab = (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab); #endif var so = this.serializedObject; thisSkeletonGraphic = target as SkeletonGraphic; // MaskableGraphic material = so.FindProperty("m_Material"); color = so.FindProperty("m_Color"); raycastTarget = so.FindProperty("m_RaycastTarget"); // SkeletonRenderer skeletonDataAsset = so.FindProperty("skeletonDataAsset"); initialSkinName = so.FindProperty("initialSkinName"); initialFlipX = so.FindProperty("initialFlipX"); initialFlipY = so.FindProperty("initialFlipY"); // SkeletonAnimation startingAnimation = so.FindProperty("startingAnimation"); startingLoop = so.FindProperty("startingLoop"); timeScale = so.FindProperty("timeScale"); unscaledTime = so.FindProperty("unscaledTime"); freeze = so.FindProperty("freeze"); meshGeneratorSettings = so.FindProperty("meshGenerator").FindPropertyRelative("settings"); meshGeneratorSettings.isExpanded = SkeletonRendererInspector.advancedFoldout; }
public SpinePlay(int trackIndex, SpinePlayableVo playableVo, SkeletonGraphic skeletonGraphic, Action playNextAction) { _isStop = false; _trackIndex = trackIndex; _playNextAction = playNextAction; _skeletonGraphic = skeletonGraphic; _playableVo = playableVo; _trackEntry = _skeletonGraphic.AnimationState.SetAnimation(_trackIndex, playableVo.animationName, true); if (_trackEntry.Animation.Name.Contains("toufa_")) { _trackEntry.TrackTime = HairTrackTime; } _trackEntry.TimeScale = _playableVo.speed; _trackEntry.Delay = playableVo.delay; CurrentTime = 0; if (_playableVo.PlayableType == PlayableType.ByCount) { CurrentCount = 0; _trackEntry.Complete += OnCount; } }
// Use this for initialization void Start() { mdb = this.gameObject.GetComponent <MiniGameDefaultBehavior> (); mouthStep.SetActive(false); faucet = faucetObject.GetComponent <SkeletonGraphic> (); handler = handlerObject.GetComponent <SkeletonGraphic> (); }
public SpinePlaySequence(SkeletonGraphic skeletonGraphic, List <SpinePlayableVo> playableList) { _playableList = playableList; _skeletonGraphic = skeletonGraphic; _skeletonGraphic.UpdateComplete += OnUpdate; }
void OnEnable() { var so = this.serializedObject; thisSkeletonGraphic = target as SkeletonGraphic; // MaskableGraphic material = so.FindProperty("m_Material"); color = so.FindProperty("m_Color"); raycastTarget = so.FindProperty("m_RaycastTarget"); // SkeletonRenderer skeletonDataAsset = so.FindProperty("skeletonDataAsset"); initialSkinName = so.FindProperty("initialSkinName"); initialFlipX = so.FindProperty("initialFlipX"); initialFlipY = so.FindProperty("initialFlipY"); // SkeletonAnimation startingAnimation = so.FindProperty("startingAnimation"); startingLoop = so.FindProperty("startingLoop"); timeScale = so.FindProperty("timeScale"); unscaledTime = so.FindProperty("unscaledTime"); freeze = so.FindProperty("freeze"); meshGeneratorSettings = so.FindProperty("meshGenerator").FindPropertyRelative("settings"); meshGeneratorSettings.isExpanded = SkeletonRendererInspector.advancedFoldout; }
// Use this for initialization void Start() { skeletonGraphic = GetComponent <SkeletonGraphic> (); skeletonGraphic.AnimationState.SetAnimation(0, "idle", false); collider = GetComponentInChildren <PolygonCollider2D> (); StartCoroutine(AnimTitle()); }
void Start() { Vector2[] coordinates = new Vector2[] { new Vector2(0.0f, 0.0f), new Vector2(100.0f, 50.0f), new Vector2(200.0f, 100.0f), new Vector2(300.0f, 200.0f), }; foreach (Vector2 coodinate in coordinates) { // ※ BoneFollowerGraphicの実装上、Instantiate時にCanvasが親であると指定する必要がある. GameObject fukidashiObj = Instantiate(_fukidashiPrefab, _canvas.transform); SkeletonGraphic skeletonGraphic = fukidashiObj.GetComponent <SkeletonGraphic>(); fukidashiObj.GetComponent <RectTransform>().anchoredPosition = coodinate; var fukidashiController = fukidashiObj.GetComponent <Fukidashi>(); if (fukidashiController != null) { fukidashiController.TouchCallback = (Fukidashi fukidashi) => { Debug.LogFormat("AnswerId:{0}", fukidashi.AnswerId); fukidashi.Success(); }; } } }
void OnEnable () { var so = this.serializedObject; thisSkeletonGraphic = target as SkeletonGraphic; // MaskableGraphic material_ = so.FindProperty("m_Material"); color_ = so.FindProperty("m_Color"); raycastTarget_ = so.FindProperty("m_RaycastTarget"); // SkeletonRenderer skeletonDataAsset_ = so.FindProperty("skeletonDataAsset"); initialSkinName_ = so.FindProperty("initialSkinName"); // SkeletonAnimation startingAnimation_ = so.FindProperty("startingAnimation"); startingLoop_ = so.FindProperty("startingLoop"); timeScale_ = so.FindProperty("timeScale"); freeze_ = so.FindProperty("freeze"); }