Exemplo n.º 1
0
        public Line CreateLine(
            Transform parent, string name,
            RenderLayer layer, Color color, float width,
            bool loop, bool useWorldspace)
        {
            var line = CreateObjectWithRenderer <LineRenderer>(parent, Vec2.zero, name, layer);

            line.material          = lineMaterials.Get(color);
            line.loop              = loop;
            line.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
            line.receiveShadows    = false;
            line.useWorldSpace     = useWorldspace;
            line.widthMultiplier   = width;
            var ret = new Line(line);

            return(ret);
        }
Exemplo n.º 2
0
            public Tilemap(Map map, Transform layout, Material mat, RenderLayer layer, BoundsInt bounds, TM.TileBase[] buffer)
            {
                var node = new GameObject(typeof(T).Name.Remove(0, 11));

                node.transform.SetParent(layout, false);
                tilemap            = node.AddComponent <TM.Tilemap>();
                tilemap.origin     = Vec3I.zero;
                tilemap.size       = new Vec3I(bounds.size.x, bounds.size.y, bounds.size.z);
                tilemap.tileAnchor = Vec2.zero;

                var render = node.AddComponent <TM.TilemapRenderer>();

                render.sortOrder = TM.TilemapRenderer.SortOrder.TopRight;
                render.mode      = TM.TilemapRenderer.Mode.Chunk;
                render.detectChunkCullingBounds = TM.TilemapRenderer.DetectChunkCullingBounds.Auto;
                render.maskInteraction          = SpriteMaskInteraction.None;
                render.material = mat;
                render.SetLayer(layer);

                vtileA = VirtualTileBase.Create <T>(map, tilemap);
                vtileB = VirtualTileBase.Create <T>(map, tilemap);

                InitTilemap(bounds, buffer);
            }
Exemplo n.º 3
0
        public T CreateObjectWithRenderer <T>(Transform parent, Vec2 pos, string name, RenderLayer layer)
            where T : Renderer
        {
            var node = new GameObject(name);

            node.transform.SetParent(parent, false);
            node.transform.localPosition = pos;

            var renderer = node.AddComponent <T>();

            renderer.SetLayer(layer);
            return(renderer);
        }
Exemplo n.º 4
0
        public SpriteRenderer CreateSpriteObject(Transform parent, Vec2 pos, string name, SpriteDef sprite, Color color, RenderLayer layer)
        {
            var renderer = CreateObjectWithRenderer <SpriteRenderer>(parent, pos, name, layer);

            renderer.material = spriteMaterial;
            renderer.sprite   = sprites.Get(sprite);
            renderer.color    = color;
            return(renderer);
        }
Exemplo n.º 5
0
 public static void SetLayer(this Canvas canvas, RenderLayer layer)
 => layer.Apply(canvas);
Exemplo n.º 6
0
 public static void SetLayer(this Renderer renderer, RenderLayer layer)
 => layer.Apply(renderer);