当前位置: 首页>>代码示例>>C#>>正文


C# Cell.GetTexture方法代码示例

本文整理汇总了C#中Cell.GetTexture方法的典型用法代码示例。如果您正苦于以下问题:C# Cell.GetTexture方法的具体用法?C# Cell.GetTexture怎么用?C# Cell.GetTexture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cell的用法示例。


在下文中一共展示了Cell.GetTexture方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetTileBrush

    public Brush GetTileBrush(Cell cell, Point localTileID)
    {
        var texture = cell.GetTexture();
        if (!texture) throw new UnityException("Texture is missing");

        var index = localTileID.Y*TilesPerCell + localTileID.X;
        var tile = cell.GetTile(index);

        var colors = texture.GetPixels(localTileID.X*TileResolution, localTileID.Y*TileResolution, TileResolution,
                                       TileResolution);

        var c = tile.Collision;
        var collision = new bool[c.Length];
        Array.Copy(c, collision, c.Length);

        return new Brush(colors, new TileProperties(tile.Properties), collision);
    }
开发者ID:fudge22,项目名称:LayeredPlatformerUnity,代码行数:17,代码来源:TilerMap.cs

示例2: ChangeTile

    public Texture2D ChangeTile(Cell cell, Point localTileID, Brush data)
    {
        var index = localTileID.Y*_tilerMap.TilesPerCell + localTileID.X;
        var t = cell.GetTile(index);

        if (t.Properties != data.Properties)
        {
            var oldBrush = _tilerMap.GetTileBrush(cell, localTileID);
            Undo.PushUndo(cell, localTileID, oldBrush);

            t.Properties = new TileProperties(data.Properties);

            var texture = cell.GetTexture();
            if (!texture)
                return null;

            texture.SetPixels(localTileID.X*_tilerMap.TileResolution, localTileID.Y*_tilerMap.TileResolution, _tilerMap.TileResolution,
                              _tilerMap.TileResolution, data.Colors);

            var c = data.Collision;
            var collision = new bool[c.Length];
            Array.Copy(c, collision, c.Length);

            t.Collision = collision;

            // Just add to apply list so we don't run multiple applies for same texture
            cell.IsDirty = true;

            return texture;
        }

        return null;
    }
开发者ID:LayeredPlatformer,项目名称:LayeredPlatformerUnity,代码行数:33,代码来源:TilerMapEdit.cs


注:本文中的Cell.GetTexture方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。