0
如何在Unity中创建交互式GUI对象 - 编辑器窗口?如何让四边形可以在Unity Editor窗口中拖放?
我可以得出静态四边形如下面的代码。但我想要的效果像reference video,从0:22
到0:30
。
public class EditorCanvas {
public static void DrawQuad(int x, int y, int width, int height, Color color) {
Rect rect = new Rect(x, y, width, height);
Texture2D texture = new Texture2D(1, 1);
texture.SetPixel(0, 0, color);
texture.Apply();
GUI.skin.box.normal.background = texture;
GUI.Box(rect, GUIContent.none);
}
}
public class MyWindow : EditorWindow {
void OnGUI() {
EditorCanvas.DrawQuad(100, 75, 50, 50, Color.black);
}
}