예제 #1
0
        public void UpdateModels()
        {
            SgtHelper.BeginRandomSeed(Seed);
            {
                for (var i = 0; i < PlaneCount; i++)
                {
                    var model = SgtHelper.GetIndex(ref models, i);

                    if (model == null)
                    {
                        model = models[i] = SgtProminenceModel.Create(this);
                    }

                    model.SetRotation(Random.rotationUniform);
                    model.SetMaterial(material);
                    model.SetMesh(mesh);
                }
            }
            SgtHelper.EndRandomSeed();

            // Remove any excess
            if (models != null)
            {
                var min = Mathf.Max(0, PlaneCount);

                for (var i = models.Count - 1; i >= min; i--)
                {
                    SgtProminenceModel.Pool(models[i]);

                    models.RemoveAt(i);
                }
            }
        }
        public static void MarkForDestruction(SgtProminenceModel plane)
        {
            if (plane != null)
            {
                plane.Prominence = null;

                plane.gameObject.SetActive(true);
            }
        }
        public static void Pool(SgtProminenceModel plane)
        {
            if (plane != null)
            {
                plane.Prominence = null;

                SgtComponentPool <SgtProminenceModel> .Add(plane);
            }
        }
예제 #4
0
        protected virtual void OnDestroy()
        {
            if (models != null)
            {
                for (var i = models.Count - 1; i >= 0; i--)
                {
                    SgtProminenceModel.MarkForDestruction(models[i]);
                }
            }

            if (mesh != null)
            {
                mesh.Clear(false);

                SgtObjectPool <Mesh> .Add(mesh);
            }

            SgtHelper.Destroy(material);
        }