Example #1
0
    private void CreateSyncLayer(AnimSyncLayer layer)
    {
        var go = GameObject.Instantiate(new GameObject(), transform);

        go.name                   = "AnimSyncLayer--" + layer.Name;
        layer.Rend                = go.AddComponent <SpriteRenderer>();
        layer.Rend.material       = MasterRenderer.material;
        layer.Rend.sortingLayerID = MasterRenderer.sortingLayerID;
        layer.Rend.sortingOrder   = layer.SortOrder;
        layer.Rend.sprite         = CreateSprite(layer.Tex);
    }
Example #2
0
    public void AddLayer(string name, Texture2D tex, int sortOrder = 0)
    {
        var layerIdx = SyncLayers.FindIndex(datum => datum.Name == name);

        if (layerIdx == -1)
        {
            var newLayer = new AnimSyncLayer()
            {
                Name = name, Tex = tex, SortOrder = sortOrder
            };
            CreateSyncLayer(newLayer);
            SyncLayers.Add(newLayer);
        }
        else
        {
            Debug.LogError("Layer " + name + " already exist.  Use SetLayerTexture if you want tot change the texture.");
        }
    }