Ejemplo n.º 1
0
    public void UpdateModels()
    {
        updateModelsCalled = true;

        var meshCount = Meshes != null ? Meshes.Count : 0;

        for (var i = 0; i < meshCount; i++)
        {
            var mesh  = Meshes[i];
            var model = GetOrAddModel(i);

            model.SetMesh(mesh);
            model.SetMaterial(Material);
        }

        // Remove any excess
        if (Models != null)
        {
            for (var i = Models.Count - 1; i >= meshCount; i--)
            {
                SgtSingularityModel.Pool(Models[i]);

                Models.RemoveAt(i);
            }
        }
    }
Ejemplo n.º 2
0
    private SgtSingularityModel GetOrAddModel(int index)
    {
        var model = default(SgtSingularityModel);

        if (Models == null)
        {
            Models = new List <SgtSingularityModel>();
        }

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

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

                Models[index] = model;
            }
        }
        else
        {
            model = SgtSingularityModel.Create(this);

            Models.Add(model);
        }

        return(model);
    }
    public static void MarkForDestruction(SgtSingularityModel model)
    {
        if (model != null)
        {
            model.Singularity = null;

            model.gameObject.SetActive(true);
        }
    }
    public static void Pool(SgtSingularityModel model)
    {
        if (model != null)
        {
            model.Singularity = null;

            SgtComponentPool <SgtSingularityModel> .Add(model);
        }
    }
    public static void Pool(SgtSingularityModel model)
    {
        if (model != null)
        {
            model.Singularity = null;

            SgtComponentPool<SgtSingularityModel>.Add(model);
        }
    }
    public static void MarkForDestruction(SgtSingularityModel model)
    {
        if (model != null)
        {
            model.Singularity = null;

            model.gameObject.SetActive(true);
        }
    }
    protected virtual void OnDestroy()
    {
        SgtHelper.Destroy(material);

        for (var i = models.Count - 1; i >= 0; i--)
        {
            SgtSingularityModel.MarkForDestruction(models[i]);
        }

        models.Clear();
    }
Ejemplo n.º 8
0
    protected virtual void OnDestroy()
    {
        if (Models != null)
        {
            for (var i = Models.Count - 1; i >= 0; i--)
            {
                SgtSingularityModel.MarkForDestruction(Models[i]);
            }
        }

        SgtHelper.Destroy(Material);
    }
    private void UpdateModels()
    {
        models.RemoveAll(m => m == null);

        if (Meshes.Count != models.Count)
        {
            SgtHelper.ResizeArrayTo(ref models, Meshes.Count, i => SgtSingularityModel.Create(this), m => SgtSingularityModel.Pool(m));
        }

        for (var i = Meshes.Count - 1; i >= 0; i--)
        {
            models[i].ManualUpdate(Meshes[i], material);
        }
    }