unity5.3的tile creator在哪
答案:1 悬赏:0 手机版
解决时间 2021-01-19 23:03
- 提问者网友:謫仙
- 2021-01-19 05:31
unity5.3的tile creator在哪
最佳答案
- 五星知识达人网友:蓝房子
- 2021-01-19 06:04
using UnityEngine;
using System.Collections;
using UnityEditor;
[ExecuteInEditMode]
public class TilemapEditor : MonoBehaviour {
public Material material;
Vector2 middlePoint;
public Vector2 one;
public Vector2 two;
public Vector2[] list;
Vector2[] pointone=new Vector2[50];
Vector2[] pointtwo=new Vector2[50];
Vector2[] pointThree= new Vector2[50];
Vector2[] pointFour= new Vector2[50];
public float test;
// Use this for initialization
void Start () {
// Handles.DrawLine(new Vector3(0,0,0),new Vector3(100,300,0));
}
// Update is called once per frame
void Update () {
// Debug.DrawLine(new Vector3(0,0,0),new Vector3(100,300,0));
}
void OnPostRender()
{
if(!material)
{
return;
}
material.SetPass(0);
GL.PushMatrix();
GL.LoadOrtho();
// GL.MultMatrix(transform.localToWorldMatrix);
GL.Begin(GL.LINES);
for(int i=0; i<20;i++)
{
pointone[i]= Vector2.Lerp(two,one,test*i);
pointtwo[i]=Vector2.Lerp(list[0],new Vector2(two.x,two.y-(two.y-one.y)*2),test*i);
pointThree[i]=Vector2.Lerp(two,list[0],test*i);
pointFour[i]= Vector2.Lerp(one,new Vector2(two.x,two.y-(two.y-one.y)*2),test*i);
}
// pointone[0]= Vector2.Lerp(two,one,test);
// pointtwo[0]=Vector2.Lerp(list[0],new Vector2(two.x,two.y-(two.y-one.y)*2),test);
DrawLine(one.x,one.y,two.x,two.y);
DrawLine(list[0].x,list[0].y,two.x,two.y);
DrawLine(one.x,one.y,two.x,two.y-(two.y-one.y)*2);
DrawLine(two.x,two.y-(two.y-one.y)*2,list[0].x,list[0].y);
for(int i=0; i<20;i++)
{
DrawLine(pointone[i].x,pointone[i].y,pointtwo[i].x,pointtwo[i].y);
DrawLine(pointThree[i].x,pointThree[i].y,pointFour[i].x,pointFour[i].y);
}
GL.End();
GL.PopMatrix();
}
void DrawLine(float x1,float y1,float x2,float y2)
{
// GL.PushMatrix();
GL.Vertex(new Vector3(x1/Screen.width,y1/Screen.height,0));
GL.Vertex(new Vector3(x2/Screen.width,y2/Screen.height,0));
// GL.PushMatrix();
}
// void OnSceneGUI()
// {
// Handles.color=Color.blue;
// HandleUtility.Repaint();
// }
}
using System.Collections;
using UnityEditor;
[ExecuteInEditMode]
public class TilemapEditor : MonoBehaviour {
public Material material;
Vector2 middlePoint;
public Vector2 one;
public Vector2 two;
public Vector2[] list;
Vector2[] pointone=new Vector2[50];
Vector2[] pointtwo=new Vector2[50];
Vector2[] pointThree= new Vector2[50];
Vector2[] pointFour= new Vector2[50];
public float test;
// Use this for initialization
void Start () {
// Handles.DrawLine(new Vector3(0,0,0),new Vector3(100,300,0));
}
// Update is called once per frame
void Update () {
// Debug.DrawLine(new Vector3(0,0,0),new Vector3(100,300,0));
}
void OnPostRender()
{
if(!material)
{
return;
}
material.SetPass(0);
GL.PushMatrix();
GL.LoadOrtho();
// GL.MultMatrix(transform.localToWorldMatrix);
GL.Begin(GL.LINES);
for(int i=0; i<20;i++)
{
pointone[i]= Vector2.Lerp(two,one,test*i);
pointtwo[i]=Vector2.Lerp(list[0],new Vector2(two.x,two.y-(two.y-one.y)*2),test*i);
pointThree[i]=Vector2.Lerp(two,list[0],test*i);
pointFour[i]= Vector2.Lerp(one,new Vector2(two.x,two.y-(two.y-one.y)*2),test*i);
}
// pointone[0]= Vector2.Lerp(two,one,test);
// pointtwo[0]=Vector2.Lerp(list[0],new Vector2(two.x,two.y-(two.y-one.y)*2),test);
DrawLine(one.x,one.y,two.x,two.y);
DrawLine(list[0].x,list[0].y,two.x,two.y);
DrawLine(one.x,one.y,two.x,two.y-(two.y-one.y)*2);
DrawLine(two.x,two.y-(two.y-one.y)*2,list[0].x,list[0].y);
for(int i=0; i<20;i++)
{
DrawLine(pointone[i].x,pointone[i].y,pointtwo[i].x,pointtwo[i].y);
DrawLine(pointThree[i].x,pointThree[i].y,pointFour[i].x,pointFour[i].y);
}
GL.End();
GL.PopMatrix();
}
void DrawLine(float x1,float y1,float x2,float y2)
{
// GL.PushMatrix();
GL.Vertex(new Vector3(x1/Screen.width,y1/Screen.height,0));
GL.Vertex(new Vector3(x2/Screen.width,y2/Screen.height,0));
// GL.PushMatrix();
}
// void OnSceneGUI()
// {
// Handles.color=Color.blue;
// HandleUtility.Repaint();
// }
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯