Esempio 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);
        }
Esempio 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);
            }
Esempio 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);
        }
Esempio 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);
        }
Esempio n. 5
0
 public static void SetLayer(this Canvas canvas, RenderLayer layer)
 => layer.Apply(canvas);
Esempio n. 6
0
 public static void SetLayer(this Renderer renderer, RenderLayer layer)
 => layer.Apply(renderer);