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


C# Texture2D.DrawFilledRectangle方法代码示例

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


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

示例1: Draw

    void Draw(Map map)
    {
        IList<Room> rooms = map.GetRooms ();
        Texture2D tex = new Texture2D (map.CellCount, map.CellCount, TextureFormat.RGB24, false, true);
        Renderer rend = GetComponent<Renderer> ();
        rend.enabled = true;
        tex.filterMode = FilterMode.Point;
        tex.wrapMode = TextureWrapMode.Clamp;
        tex.DrawFilledRectangle (new Rect (0, 0, map.CellCount, map.CellCount), Color.black);

        /*foreach (Room room in rooms) {
            int height = room.GetHeight();
            int width = room.GetWidth();
            int x = room.GetX();
            int y = room.GetY();

            tex.DrawFilledRectangle (new Rect (x, y, width, height), Color.white);
        }*/

        /*
        foreach (Room room in rooms) {
            Vertex2 c = room.GetCenterPoint();
            float x = (float)scale (c.x);
            float y = (float)scale (c.y);
            tex.DrawFilledRectangle(new Rect(x, y, 3, 3), Color.cyan);
        }

        foreach(Edge e in map.allEdges) {
            //if(!map.edges.Contains(e)) tex.DrawLine(scale((int)e.start.x), scale((int)e.start.y), scale((int)e.end.x), scale((int)e.end.y), Color.blue);
        }
        */
        foreach(Edge e in map.edges) {
            //tex.DrawLine(e.start.x, e.start.y, e.end.x, e.end.y, new Color(0.5f, 0.5f, 0.5f, 0.1f));
        }

        int[,] tiles = map.ptiles;
        int h = tiles.GetLength(0);
        int w = tiles.GetLength (0);

        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                int cell = tiles[h-i-1, w-j-1];
                if(cell == PathGenerator.OPEN_ENDPOINT) {
                    tex.SetPixel(map.CellCount - j, i, Color.green);
                } else if(cell == PathGenerator.BUFFER) {
                    tex.SetPixel(map.CellCount - j, i, Color.red);
                }

            }
        }

        tex.Apply ();
        rend.material.mainTexture = tex;
    }
开发者ID:olemstrom,项目名称:the-morko,代码行数:54,代码来源:Map2D.cs

示例2: Start

		void Start()
		{
			_staticRectTexture = new Texture2D( sizeX, sizeY);
			_staticRectTexture.DrawFilledRectangle(new Rect(0,0,_staticRectTexture.width, _staticRectTexture.height), Color.black);

			_newStaticRectTexture = new Texture2D( sizeX, sizeY);
			_staticRectStyle = new GUIStyle();

			onUpdate = new GraphDebugEventManager.GraphDebugEvent (OnUpdate);
			GraphDebugEventManager.UpdateSpectrum += onUpdate;
		}
开发者ID:fromtons,项目名称:meme-pas-peur_app,代码行数:11,代码来源:SpectrumDebug.cs

示例3: Start

    void Start()
    {
        Material material = renderer.material;
        Texture2D texture = new Texture2D(512,512, TextureFormat.RGB24, false);
        texture.wrapMode = TextureWrapMode.Clamp;
        material.SetTexture(0, texture);

        texture.DrawFilledRectangle(new Rect(0, 0, 120, 120), Color.green);

        texture.DrawRectangle(new Rect(0, 0, 120, 60), Color.red);

        texture.DrawCircle(256, 256, 100, Color.cyan);
        texture.DrawFilledCircle(256, 256, 50, Color.grey);

        texture.DrawCircle(0, 0, 512, Color.red);

        texture.DrawLine(new Vector2(120, 60), new Vector2(256, 256), Color.black);

        texture.Apply();
    }
开发者ID:AliAkbarMontazeri,项目名称:BitmapDrawingExampleProject,代码行数:20,代码来源:Example.cs


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