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