Exemplo n.º 1
0
        public static GameObject InstantiateTrailInstance(TrailRendererEventProperties properties, Animator animator, bool flipped, bool isCrit, bool bypassPools = false)
        {
            GameObject trail = null;

            if (Application.isPlaying)
            {
                if (!bypassPools)
                {
                    trail = LoadTrailWithPool(properties, isCrit);
                }
                else
                {
                    trail = LoadTrailWithoutPool(properties, isCrit);
                }
            }
            else
            {
                trail = LoadTrailWithoutPool(properties, isCrit);
            }

            if (trail != null)
            {
                TrailRendererInstance tri    = trail.GetComponent <TrailRendererInstance>();
                Transform             parent = null;

                if (tri != null)
                {
                    Vector3 offset1 = properties._offset1;
                    Vector3 offset2 = properties._offset2;

                    tri.OffsetPoints(offset1, offset2, properties._useLocalOffsets);

                    if (tri._TimeUnits == TrailRenderer.eTIME_UNITS.Frames)
                    {
                        tri.ConvertFramesToSeconds(properties._fps);
                    }
                }

                if (animator != null)
                {
                    parent = GetBodyPartTransform(animator, properties._attachment, properties._attachmentPath);
                    trail.transform.parent = parent;

                    trail.transform.localPosition = properties._rigOffset;

                    if (properties._worldSpace)
                    {
                        trail.transform.eulerAngles = properties._angles;

                        if (flipped)
                        {
                            // rotate this by 180
                            trail.transform.RotateAround(trail.transform.position, Vector3.up, 180.0f);
                        }
                    }
                    else
                    {
                        trail.transform.localEulerAngles = properties._angles;
                    }
                }

                trail.transform.localScale = Vector3.one;

                if (!properties._parent)
                {
                    trail.transform.parent = null;
                }
                else
                {
                    AttachTransform at = AttachTransform.LockPosition(trail, properties._lockXOffset, properties._lockYOffset, properties._lockZOffset);
                    tri.SetAttachTransform(at);
                }
            }

            return(trail);
        }
Exemplo n.º 2
0
        public static ParticleSystem InstantiateParticle(Object obj, ParticleEventProperties properties, Animator animator, bool flipped = false, bool bypassPools = false)
        {
            ParticleSystem ps = GetParticleInstance(obj, properties, flipped, bypassPools);

            if (ps != null)
            {
                Transform parent = GetBodyPartTransform(animator, properties._bodyPart, properties._attachmentPath);

                if (properties._parent)
                {
                    ps.transform.SetParent(parent);
                    if (properties._bodyPart == BodyPart.HeadNubNotRot)
                    {
                        ps.transform.position         = animator.GetComponent <FXHelper>().HeadNubTransform.position;
                        ps.transform.localEulerAngles = Vector3.zero;
                    }
                    else
                    {
                        ps.transform.localPosition = properties._offset;
                    }
                }
                else
                {
                    ps.transform.SetParent(null);
                    ps.transform.position = parent.TransformPoint(properties._offset);
                }

                if (properties._lockXOffset || properties._lockYOffset != HeightLock.Unlocked || properties._lockZOffset)
                {
                    AttachTransform.LockPosition(ps.gameObject, properties._lockXOffset, properties._lockYOffset, properties._lockZOffset);
                }

                if (properties._worldSpace)
                {
                    ps.transform.eulerAngles = properties._angles;

                    if (flipped)
                    {
                        // rotate this by 180
                        ps.transform.RotateAround(ps.transform.position, Vector3.up, 180.0f);
                    }
                }
                else
                {
                    if (properties._parent)
                    {
                        ps.transform.localEulerAngles = properties._angles; //感觉不好 没看明白 因为我们现在的粒子不挂角色身上
                    }
                    else
                    {
                        ps.transform.eulerAngles = parent.TransformDirection(properties._angles);//解决无父节点的旋转问题
                    }
                }

                // mirror the effect, for parented effects, this is done inside the attach transform
                if (flipped && !properties._parent)
                {
                    FlipWorldRotationByXYPlane(ps.transform);
                }

                ps.transform.localScale = properties._scale;
            }

            return(ps);
        }