Ejemplo n.º 1
0
        private SgtRingModel GetOrAddModel(int index)
        {
            var model = default(SgtRingModel);

            if (models == null)
            {
                models = new List <SgtRingModel>();
            }

            if (index < models.Count)
            {
                model = models[index];

                if (model == null)
                {
                    model = SgtRingModel.Create(this);

                    models[index] = model;
                }
            }
            else
            {
                model = SgtRingModel.Create(this);

                models.Add(model);
            }

            return(model);
        }
Ejemplo n.º 2
0
        public void UpdateModels()
        {
            var angleStep = SgtHelper.Divide(360.0f, Segments);

            for (var i = 0; i < Segments; i++)
            {
                var model    = GetOrAddModel(i);
                var angle    = angleStep * i;
                var rotation = Quaternion.Euler(0.0f, angle, 0.0f);

                model.SetMesh(Mesh);
                model.SetMaterial(material);
                model.SetRotation(rotation);
            }

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

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

                    models.RemoveAt(i);
                }
            }
        }
Ejemplo n.º 3
0
        public static void Pool(SgtRingModel segment)
        {
            if (segment != null)
            {
                segment.Ring = null;

                SgtComponentPool <SgtRingModel> .Add(segment);
            }
        }
Ejemplo n.º 4
0
        public static void MarkForDestruction(SgtRingModel segment)
        {
            if (segment != null)
            {
                segment.Ring = null;

                segment.gameObject.SetActive(true);
            }
        }
Ejemplo n.º 5
0
        protected virtual void OnDestroy()
        {
            if (models != null)
            {
                for (var i = models.Count - 1; i >= 0; i--)
                {
                    SgtRingModel.MarkForDestruction(models[i]);
                }
            }

            SgtHelper.Destroy(material);
        }