public void ResizeIfNeeded(int size)
 {
     NativeArrayHelpers.ResizeIfNeeded(ref rootBoneTransformId, size);
     NativeArrayHelpers.ResizeIfNeeded(ref rootTransformId, size);
     NativeArrayHelpers.ResizeIfNeeded(ref spriteBound, size);
     NativeArrayHelpers.ResizeIfNeeded(ref newSpriteBound, size);
 }
Exemplo n.º 2
0
        void UpdateTransformIndex()
        {
            if (!m_Dirty)
            {
                return;
            }
            m_Dirty = false;
            Profiler.BeginSample("UpdateTransformIndex");
            NativeArrayHelpers.ResizeIfNeeded(ref m_TransformMatrix, m_Transform.Length);
            if (!m_TransformAccessArray.isCreated)
            {
                TransformAccessArray.Allocate(m_Transform.Length, -1, out m_TransformAccessArray);
            }
            else if (m_TransformAccessArray.capacity != m_Transform.Length)
            {
                m_TransformAccessArray.capacity = m_Transform.Length;
            }
            m_TransformAccessArray.SetTransforms(m_Transform);

            for (int i = 0; i < m_Transform.Length; ++i)
            {
                if (m_Transform[i] != null)
                {
                    var instanceId    = m_Transform[i].GetInstanceID();
                    var transformData = m_TransformData[instanceId];
                    transformData.transformIndex = i;
                    m_TransformData[instanceId]  = transformData;
                }
            }
            Profiler.EndSample();
        }
Exemplo n.º 3
0
        void CacheBatchBoneTransform()
        {
            if (boneTransforms != null)
            {
                int boneCount = 0;
                for (int i = 0; i < boneTransforms.Length; ++i)
                {
                    if (boneTransforms[i] != null)
                    {
                        ++boneCount;
                    }
                }


                if (m_BoneTransformId.IsCreated)
                {
                    for (int i = 0; i < m_BoneTransformId.Length; ++i)
                    {
                        SpriteSkinComposite.instance.RemoveTransformById(m_BoneTransformId[i]);
                    }
                    NativeArrayHelpers.ResizeIfNeeded(ref m_BoneTransformId, boneCount);
                }
                else
                {
                    m_BoneTransformId = new NativeArray <int>(boneCount, Allocator.Persistent);
                }

                m_BoneTransformIdNativeSlice = new NativeCustomSlice <int>(m_BoneTransformId);
                for (int i = 0, j = 0; i < m_BoneTransformId.Length; ++i)
                {
                    if (boneTransforms[i] != null)
                    {
                        m_BoneTransformId[j] = boneTransforms[i].GetInstanceID();
                        ++j;
                    }
                }
                if (this.enabled)
                {
                    SpriteSkinComposite.instance.AddSpriteSkinBoneTransform(this);
                }
            }
            else
            {
                if (m_BoneTransformId.IsCreated)
                {
                    NativeArrayHelpers.ResizeIfNeeded(ref m_BoneTransformId, 0);
                }
                else
                {
                    m_BoneTransformId = new NativeArray <int>(0, Allocator.Persistent);
                }
            }
        }
Exemplo n.º 4
0
        void CacheBoneTransformIds(bool forceUpdate = false)
        {
            if (!m_BoneCacheUpdateToDate || forceUpdate)
            {
                SpriteSkinComposite.instance.RemoveTransformById(m_RootBoneTransformId);
                if (rootBone != null)
                {
                    m_RootBoneTransformId = rootBone.GetInstanceID();
                    if (this.enabled)
                    {
                        SpriteSkinComposite.instance.AddSpriteSkinRootBoneTransform(this);
                    }
                }
                else
                {
                    m_RootBoneTransformId = 0;
                }

                if (boneTransforms != null)
                {
                    int boneCount = 0;
                    for (int i = 0; i < boneTransforms.Length; ++i)
                    {
                        if (boneTransforms[i] != null)
                        {
                            ++boneCount;
                        }
                    }

                    if (m_BoneTransformId.IsCreated)
                    {
                        for (int i = 0; i < m_BoneTransformId.Length; ++i)
                        {
                            SpriteSkinComposite.instance.RemoveTransformById(m_BoneTransformId[i]);
                        }
                        NativeArrayHelpers.ResizeIfNeeded(ref m_BoneTransformId, boneCount);
                    }
                    else
                    {
                        m_BoneTransformId = new NativeArray <int>(boneCount, Allocator.Persistent);
                    }

                    m_BoneTransformIdNativeSlice = new NativeCustomSlice <int>(m_BoneTransformId);
                    for (int i = 0, j = 0; i < boneTransforms.Length; ++i)
                    {
                        if (boneTransforms[i] != null)
                        {
                            m_BoneTransformId[j] = boneTransforms[i].GetInstanceID();
                            ++j;
                        }
                    }
                    if (this.enabled)
                    {
                        SpriteSkinComposite.instance.AddSpriteSkinBoneTransform(this);
                    }
                }
                else
                {
                    if (m_BoneTransformId.IsCreated)
                    {
                        NativeArrayHelpers.ResizeIfNeeded(ref m_BoneTransformId, 0);
                    }
                    else
                    {
                        m_BoneTransformId = new NativeArray <int>(0, Allocator.Persistent);
                    }
                }
                CacheValidFlag();
                m_BoneCacheUpdateToDate = true;
                SpriteSkinComposite.instance.CopyToSpriteSkinData(this);
            }
        }