Exemple #1
0
 public static void Clear(this CombineInstance[] self)
 {
     for (var i = 0; i < self.Length; i++)
     {
         MeshPool.Return(self[i].mesh);
         self[i].mesh = null;
     }
 }
Exemple #2
0
        private static void InitializeOnLoad()
        {
            MeshHelper.Init();
            MeshPool.Init();
            CombineInstanceArrayPool.Init();

            Canvas.willRenderCanvases -= Refresh;
            Canvas.willRenderCanvases += Refresh;
        }
Exemple #3
0
        /// <summary>
        /// This function is called when the behaviour becomes disabled.
        /// </summary>
        protected override void OnDisable()
        {
            UIParticleUpdater.Unregister(this);
            if (!_shouldBeRemoved)
                particles.Exec(p => p.GetComponent<ParticleSystemRenderer>().enabled = true);
            _tracker.Clear();

            // Destroy object.
            MeshPool.Return(_bakedMesh);
            _bakedMesh = null;

            base.OnDisable();
        }
Exemple #4
0
        public void Clear()
        {
            for (var i = 0; i < combineInstances.Count; i++)
            {
                var inst = combineInstances[i];
                MeshPool.Return(inst.mesh);
                inst.mesh           = null;
                combineInstances[i] = inst;
            }

            combineInstances.Clear();

            MeshPool.Return(mesh);
            mesh = null;

            count = 0;
            hash  = -1;
            index = -1;
        }
Exemple #5
0
        /// <summary>
        /// This function is called when the object becomes enabled and active.
        /// </summary>
        protected override void OnEnable()
        {
            _cachedPosition    = transform.localPosition;
            _activeMeshIndices = 0;

            UIParticleUpdater.Register(this);
            particles.Exec(p => p.GetComponent <ParticleSystemRenderer>().enabled = false);

            if (isActiveAndEnabled && m_IgnoreCanvasScaler)
            {
                _tracker.Add(this, rectTransform, DrivenTransformProperties.Scale);
            }

            // Create objects.
            _bakedMesh = MeshPool.Rent();

            base.OnEnable();

            InitializeIfNeeded();
        }
Exemple #6
0
        /// <summary>
        /// This function is called when the object becomes enabled and active.
        /// </summary>
        protected override void OnEnable()
        {
#if !SERIALIZE_FIELD_MASKABLE
            maskable = m_Maskable;
#endif
            activeMeshIndices.Clear();

            UIParticleUpdater.Register(this);
            particles.Exec(p => p.GetComponent <ParticleSystemRenderer>().enabled = false);

            if (isActiveAndEnabled && m_IgnoreCanvasScaler)
            {
                _tracker.Add(this, rectTransform, DrivenTransformProperties.Scale);
            }

            // Create objects.
            _bakedMesh = MeshPool.Rent();

            base.OnEnable();

            InitializeIfNeeded();
        }
Exemple #7
0
        public void Combine()
        {
            switch (count)
            {
            case 0:
                return;

            case 1:
                mesh      = combineInstances[0].mesh;
                transform = combineInstances[0].transform;
                return;

            default:
            {
                var cis = CombineInstanceArrayPool.Get(combineInstances);
                mesh = MeshPool.Rent();
                mesh.CombineMeshes(cis, true, true);
                transform = Matrix4x4.identity;
                cis.Clear();
                return;
            }
            }
        }
Exemple #8
0
 public static Mesh GetTemporaryMesh()
 {
     return(MeshPool.Rent());
 }
Exemple #9
0
 public static void DiscardTemporaryMesh(Mesh mesh)
 {
     MeshPool.Return(mesh);
 }