Exemplo n.º 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;
     }
 }
Exemplo n.º 2
0
        private static void InitializeOnLoad()
        {
            MeshHelper.Init();
            MeshPool.Init();
            CombineInstanceArrayPool.Init();

            Canvas.willRenderCanvases -= Refresh;
            Canvas.willRenderCanvases += Refresh;
        }
Exemplo n.º 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();
        }
Exemplo n.º 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;
        }
Exemplo n.º 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();
        }
Exemplo n.º 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();
        }
Exemplo n.º 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;
            }
            }
        }
Exemplo n.º 8
0
 public static Mesh GetTemporaryMesh()
 {
     return(MeshPool.Rent());
 }
Exemplo n.º 9
0
 public static void DiscardTemporaryMesh(Mesh mesh)
 {
     MeshPool.Return(mesh);
 }