Пример #1
0
        public Cloth Clone(AssetCabinet file)
        {
            file.MergeTypeDefinition(this.file, UnityClassID.Cloth);

            Cloth cloth = new Cloth(file);

            AssetCabinet.IncompleteClones.Add(new Tuple <Component, Component>(this, cloth));
            return(cloth);
        }
Пример #2
0
        public void CopyTo(Cloth dest)
        {
            dest.m_Enabled                = m_Enabled;
            dest.m_StretchingStiffness    = m_StretchingStiffness;
            dest.m_BendingStiffness       = m_BendingStiffness;
            dest.m_UseTethers             = m_UseTethers;
            dest.m_UseGravity             = m_UseGravity;
            dest.m_Damping                = m_Damping;
            dest.m_ExternalAcceleration   = m_ExternalAcceleration;
            dest.m_RandomAcceleration     = m_RandomAcceleration;
            dest.m_WorldVelocityScale     = m_WorldVelocityScale;
            dest.m_WorldAccelerationScale = m_WorldAccelerationScale;
            dest.m_Friction               = m_Friction;
            dest.m_CollisionMassScale     = m_CollisionMassScale;
            dest.m_UseContinuousCollision = m_UseContinuousCollision;
            dest.m_UseVirtualParticles    = m_UseVirtualParticles;
            dest.m_SolverFrequency        = m_SolverFrequency;
            dest.m_SleepThreshold         = m_SleepThreshold;
            dest.m_Coefficients           = m_Coefficients;

            Transform destRoot = dest.m_GameObject.instance.FindLinkedComponent(typeof(Transform));

            while (destRoot.Parent != null)
            {
                destRoot = destRoot.Parent;
            }
            dest.m_CapsuleColliders = new List <PPtr <CapsuleCollider> >(m_CapsuleColliders.Count);
            foreach (var ccPtr in m_CapsuleColliders)
            {
                CapsuleCollider cCol = ccPtr.instance;
                if (cCol != null)
                {
                    Transform destTrans = cCol.m_GameObject.instance.FindLinkedComponent(typeof(Transform));
                    if (destTrans != null)
                    {
                        CapsuleCollider destCCol = destTrans.m_GameObject.instance.FindLinkedComponent(UnityClassID.CapsuleCollider);
                        if (destCCol != null)
                        {
                            dest.m_CapsuleColliders.Add(new PPtr <CapsuleCollider>(destCCol));
                        }
                    }
                }
            }
            if (dest.m_CapsuleColliders.Count != m_CapsuleColliders.Count)
            {
                Report.ReportLog("Warning! Could not find all CapsuleColliders for Cloth " + dest.m_GameObject.instance.m_Name);
            }

            dest.m_SphereColliders = new List <Tuple <PPtr <SphereCollider>, PPtr <SphereCollider> > >(m_SphereColliders.Count);
            foreach (var pair in m_SphereColliders)
            {
                SphereCollider destSCol1 = null;
                SphereCollider sCol1     = pair.Item1.instance;
                if (sCol1 != null)
                {
                    Transform destTrans = sCol1.m_GameObject.instance.FindLinkedComponent(typeof(Transform));
                    if (destTrans != null)
                    {
                        destSCol1 = destTrans.m_GameObject.instance.FindLinkedComponent(UnityClassID.SphereCollider);
                    }
                }

                SphereCollider destSCol2 = null;
                SphereCollider sCol2     = pair.Item2.instance;
                if (sCol2 != null)
                {
                    Transform destTrans = sCol2.m_GameObject.instance.FindLinkedComponent(typeof(Transform));
                    if (destTrans != null)
                    {
                        destSCol2 = destTrans.m_GameObject.instance.FindLinkedComponent(UnityClassID.SphereCollider);
                    }
                }

                if (destSCol1 != null || destSCol2 != null)
                {
                    dest.m_SphereColliders.Add
                    (
                        new Tuple <PPtr <SphereCollider>, PPtr <SphereCollider> >
                        (
                            new PPtr <SphereCollider>(destSCol1),
                            new PPtr <SphereCollider>(destSCol2)
                        )
                    );
                }
            }
            if (dest.m_SphereColliders.Count != m_SphereColliders.Count)
            {
                Report.ReportLog("Warning! Could not find all SphereCollider pairs for Cloth " + dest.m_GameObject.instance.m_Name);
            }
        }