public override void OnInspectorGUI() { SortRenderer sortRenderer = target as SortRenderer; if (MyGUI.Button("从碰撞区域生成SortRendererPos")) { Bounds bounds = sortRenderer.gameObject.GetColliderBounds(); sortRenderer.SetSortRendererPos(new Vector3(bounds.center.x, bounds.center.y, bounds.max.z)); } if (MyGUI.Button("从渲染区域生成SortRendererPos")) { Bounds bounds = sortRenderer.gameObject.GetRendererBounds(); sortRenderer.SetSortRendererPos(new Vector3(bounds.center.x, bounds.center.y, bounds.max.z)); } base.OnInspectorGUI(); }
private async void DoPlayAnim(AnimEffectData animEffectData) { switch (animEffectData.animEffectType) { case AnimEffectData.AnimEffectType.Image: Texture texture = await AssetManager.LoadAssetAsync <Texture2D>(animEffectData.imagePath); imageGameObject.GetComponent <MeshRenderer>().material.SetTexture("_MainTex", texture); imageGameObject.GetComponent <MeshRenderer>().material.SetFloat("ZWrite", animEffectData.zwriteType == FrameEventInfo.ZwriteType.Off ? 0 : 1); { switch (animEffectData.renderQueue) { case FrameEventInfo.RenderQueue.Geometry: imageGameObject.GetComponent <MeshRenderer>().material.renderQueue = 2000; break; case FrameEventInfo.RenderQueue.AlphaTest: imageGameObject.GetComponent <MeshRenderer>().material.renderQueue = 2450; break; case FrameEventInfo.RenderQueue.Transparent: imageGameObject.GetComponent <MeshRenderer>().material.renderQueue = 3000; break; default: throw new ArgumentOutOfRangeException(); } } // 初始大小 add by TangJian 2018/9/12 10:42 { rendererSize.x = texture.width / 100f; rendererSize.y = texture.height / 100f; rendererSize.z = 1; float factor = 1.0f / rendererSize.y; rendererSize.x *= factor; rendererSize.y *= factor; } // 锚点 add by TangJian 2018/9/12 10:42 { imageGameObject.transform.localPosition = -animEffectData.anchor; } moveGameObject = gameObject; // 显示图片 add by TangJian 2019/6/14 16:22 imageGameObject.SetActive(true); break; case AnimEffectData.AnimEffectType.Anim: Spine.Unity.SkeletonAnimation skeletonAnimation = animGameObject.GetComponent <Spine.Unity.SkeletonAnimation>(); skeletonAnimation.skeletonDataAsset = await AssetManager.LoadAssetAsync <Spine.Unity.SkeletonDataAsset>(animEffectData.animPath); skeletonAnimation.Initialize(true); Spine.TrackEntry TrackEntry = skeletonAnimation.state.SetAnimation(0, animEffectData.animName, animEffectData.animLoop); TrackEntry.TimeScale = 1; skeletonAnimation.state.TimeScale = animEffectData.animSpeed; animGameObject.transform.localPosition = Vector3.zero; moveGameObject = animGameObject; // 显示动画 add by TangJian 2019/6/14 16:23 animGameObject.SetActive(true); break; case AnimEffectData.AnimEffectType.Particle: // var particle = await AssetManager.Instantiate(animEffectData.prefabname); var particle = await AssetManager.SpawnAsync(animEffectData.prefabname); particle.transform.parent = particleGameObject.transform; particle.transform.localPosition = Vector3.zero; moveGameObject = particleGameObject; // 显示粒子 add by TangJian 2019/6/14 16:23 particleGameObject.SetActive(true); break; case AnimEffectData.AnimEffectType.Gameobject: // var other = await AssetManager.Instantiate(animEffectData.prefabpath); var other = await AssetManager.SpawnAsync(animEffectData.prefabpath); other.transform.parent = otherGameObject.transform; other.transform.localPosition = Vector3.zero; other.transform.eulerAngles = Vector3.zero; moveGameObject = otherGameObject; // 显示其他 add by TangJian 2019/6/14 16:23 otherGameObject.SetActive(true); break; default: Debug.LogError(""); break; } Init(); RunAction(animEffectData.actionData, () => { Tang.PoolManager.Instance.Despawn(gameObject); }); { gameObject.RecursiveComponent <Renderer>((Renderer rd, int depth) => { SortRenderer sortRenderer = rd.gameObject.AddComponentIfNone <SortRenderer>(); sortRenderer.Pos = Vector3.zero; }, 1, 99); } { moveGameObject.transform.localPosition += animEffectData.pos.RotateFrontTo(orientation).Flip(MoveFlip); if (animEffectData.animEffectType == AnimEffectData.AnimEffectType.Particle) { moveGameObject.transform.localScale = animEffectData.scale; } else { moveGameObject.transform.localScale = animEffectData.scale.Flip(RenderFlip); } if (moveGameObject.transform.localScale.x > 0) { moveGameObject.transform.localRotation = Quaternion.Euler((moveGameObject.transform.localRotation.eulerAngles + animEffectData.rotation)); } else { moveGameObject.transform.localRotation = Quaternion.Euler((moveGameObject.transform.localRotation.eulerAngles + new Vector3(animEffectData.rotation.x, animEffectData.rotation.y, animEffectData.rotation.z * -1))); } moveGameObject.RecursiveComponent <Renderer>((Renderer rd, int depth) => { if (rd.material.HasProperty("AddColor")) { if (rd.gameObject.name == "Anim") { Set_Color(rd, "AddColor", new Color(0, 0, 0, 0)); Color color = Get_Color(rd, "AddColor"); color = animEffectData.addColor; Set_Color(rd, "AddColor", color); } else { rd.material.SetColor("AddColor", animEffectData.addColor); } } }, 1, 99); moveGameObject.RecursiveComponent <Renderer>((Renderer rd, int depth) => { if (rd.material.HasProperty("MulColor")) { if (rd.gameObject.name == "Anim") { Set_Color(rd, "MulColor", new Color(1, 1, 1, 1)); Color color = Get_Color(rd, "MulColor"); color = animEffectData.mulColor; Set_Color(rd, "MulColor", color); } else { rd.material.SetColor("MulColor", animEffectData.mulColor); } } }, 1, 99); moveGameObject.RecursiveComponent <Renderer>((Renderer rd, int depth) => { if (rd.gameObject.name == "Anim" && rd.material.HasProperty("_Color")) { Set_Color(rd, "_Color", new Color(1, 1, 1, 1)); Color color = Get_Color(rd, "_Color"); color.a = animEffectData.alpha; Set_Color(rd, "_Color", color); } else { if (animEffectData.animEffectType != AnimEffectData.AnimEffectType.Particle) { if (rd.material.HasProperty("_Color")) { Color color = rd.material.color; color.a = animEffectData.alpha; rd.material.color = color; } else { Debug.Log("没有_Color属性"); } } } }, 1, 99); } }