(UI용 아님)
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
[RequireComponent(typeof(MeshRenderer))]
[RequireComponent(typeof(MeshFilter))]
public class CircularSectorMeshRenderer : MonoBehaviour
{
public float degree = 180;
public float intervalDegree = 5;
public float beginOffsetDegree = 0;
public float radius = 10;
Mesh mesh;
MeshFilter meshFilter;
Vector3[] vertices;
int[] triangles;
Vector2[] uvs;
int i;
float beginDegree;
float endDegree;
float beginRadian;
float endRadian;
float uvRadius = 0.5f;
Vector2 uvCenter = new Vector2(0.5f, 0.5f);
float currentIntervalDegree = 0;
float limitDegree;
int count;
int lastCount;
float beginCos;
float beginSin;
float endCos;
float endSin;
int beginNumber;
int endNumber;
int triangleNumber;
// Use this for initialization
void Start ()
{
mesh = new Mesh();
meshFilter = (MeshFilter)GetComponent("MeshFilter");
}
// Update is called once per frame
void Update ()
{
currentIntervalDegree = Mathf.Abs(intervalDegree);
count = (int)( Mathf.Abs(degree) / currentIntervalDegree );
if ( degree % intervalDegree != 0 )
{ ++count; }
if ( degree < 0 )
{ currentIntervalDegree = -currentIntervalDegree; }
if ( lastCount != count )
{
mesh.Clear(); vertices = new Vector3[ count*2 + 1 ];
triangles = new int [ count*3 ];
uvs = new Vector2[ count*2 + 1 ];
vertices[0] = Vector3.zero;
uvs[0] = uvCenter;
lastCount = count;
}
i =0;
beginDegree = beginOffsetDegree;
limitDegree = degree + beginOffsetDegree;
while ( i < count )
{
endDegree = beginDegree + currentIntervalDegree;
if ( degree > 0 )
{
if ( endDegree > limitDegree )
{
endDegree = limitDegree;
}
} else
{
if ( endDegree < limitDegree )
{
endDegree = limitDegree;
}
}
beginRadian = Mathf.Deg2Rad * beginDegree; endRadian = Mathf.Deg2Rad * endDegree ;
beginCos = Mathf.Cos( beginRadian );
beginSin = Mathf.Sin( beginRadian );
endCos = Mathf.Cos( endRadian );
endSin = Mathf.Sin( endRadian );
beginNumber = i*2 + 1;
endNumber = i*2 + 2;
triangleNumber = i*3;
vertices[ beginNumber ].x = beginCos * radius;
vertices[ beginNumber ].y = 0;
vertices[ beginNumber ].z = beginSin * radius;
vertices[ endNumber ].x = endCos * radius;
vertices[ endNumber ].y = 0;
vertices[ endNumber ].z = endSin * radius;
triangles[ triangleNumber ] = 0;
if ( degree > 0 )
{
triangles[ triangleNumber + 1 ] = endNumber;
triangles[ triangleNumber + 2 ] = beginNumber;
} else
{
triangles[ triangleNumber + 1 ] = beginNumber;
triangles[ triangleNumber + 2 ] = endNumber;
}
if ( radius > 0 )
{
uvs[ beginNumber ].x = beginCos * uvRadius + uvCenter.x;
uvs[ beginNumber ].y = beginSin * uvRadius + uvCenter.y;
uvs[ endNumber ].x = endCos * uvRadius + uvCenter.x;
uvs[ endNumber ].y = endSin * uvRadius + uvCenter.y;
} else
{
uvs[ beginNumber ].x = -beginCos * uvRadius + uvCenter.x;
uvs[ beginNumber ].y = -beginSin * uvRadius + uvCenter.y;
uvs[ endNumber ].x = -endCos * uvRadius + uvCenter.x;
uvs[ endNumber ].y = -endSin * uvRadius + uvCenter.y;
}
beginDegree += currentIntervalDegree; ++i;
}
mesh.vertices = vertices;
mesh.triangles = triangles;
mesh.uv = uvs;
mesh.RecalculateNormals();
mesh.RecalculateBounds();
meshFilter.sharedMesh = mesh;
meshFilter.sharedMesh.name = "CircularSectorMesh";
}
}
2019년 3월 26일 화요일
피드 구독하기:
댓글 (Atom)
git rejected error(feat. cherry-pick)
문제 아무 생각 없이 pull을 받지않고 로컬에서 작업! 커밋, 푸시 진행을 해버렷다. push에선 remote와 다르니 당연히 pull을 진행해라고 하지만 로컬에서 작업한 내용을 백업하지 않고 진행하기에는 부담스럽다(로컬작업 유실 가능성) 해결하려...
-
/// < summary > /// 검색 조건과 내용으로 테이블에 있는 데이터를 검색하는 메서드 /// </ summary > /// < param name = "valu...
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 ...
-
해결책 서비스 > application layer Gateway Service 를 한번 실행해주면 엉킨포트가 풀리는지 어떤지 모르겠지만 된다 포트가 풀린것 확인하려면 명령프롬프트창에 netstat -n 명령을 넣어서 확인할 수 있다...
댓글 없음:
댓글 쓰기