本文整理汇总了C#中PrimitiveType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# PrimitiveType.ToString方法的具体用法?C# PrimitiveType.ToString怎么用?C# PrimitiveType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PrimitiveType
的用法示例。
在下文中一共展示了PrimitiveType.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatePrimitive
public static GameObject CreatePrimitive(PrimitiveType type, bool bLeaveOutMesh, bool bTrigger)
{
GameObject go = null;
if (bLeaveOutMesh)
{
switch (type)
{
case PrimitiveType.Cube:
go = new GameObject(type.ToString());
go.AddComponent<BoxCollider>();
break;
case PrimitiveType.Capsule:
go = new GameObject(type.ToString());
var cap = go.AddComponent<CapsuleCollider>();
cap.radius = 0.5f;
cap.height = 2.0f;
break;
case PrimitiveType.Sphere:
go = new GameObject(type.ToString());
go.AddComponent<SphereCollider>();
break;
case PrimitiveType.Cylinder:
go = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
ObjUtil.SmartDestroy(go.GetComponent<MeshCollider>());
var coll = go.AddComponent<MeshCollider>();
coll.sharedMesh = go.GetComponent<MeshFilter>().sharedMesh;
ObjUtil.SmartDestroy(go.GetComponent<MeshFilter>());
ObjUtil.SmartDestroy(go.GetComponent<MeshRenderer>());
break;
case PrimitiveType.Plane:
go = GameObject.CreatePrimitive(PrimitiveType.Plane);
ObjUtil.SmartDestroy(go.GetComponent<MeshFilter>());
ObjUtil.SmartDestroy(go.GetComponent<MeshRenderer>());
break;
case PrimitiveType.Quad:
go = GameObject.CreatePrimitive(PrimitiveType.Quad);
ObjUtil.SmartDestroy(go.GetComponent<MeshFilter>());
ObjUtil.SmartDestroy(go.GetComponent<MeshRenderer>());
break;
}
}
else
{
go = GameObject.CreatePrimitive(type);
}
if (go != null)
{
go.GetComponent<Collider>().isTrigger = bTrigger;
}
return go;
}
示例2: numVertsPerPrimitive
private static int numVertsPerPrimitive(PrimitiveType type)
{
switch (type)
{
case PrimitiveType.LineList:
return 2;
case PrimitiveType.TriangleList:
return 3;
default:
throw new Exception("PrimitiveDrawer doesn't support " + type.ToString());
}
}
示例3: GlPrimitiveOutputType
protected BeginMode GlPrimitiveOutputType(PrimitiveType type)
{
BeginMode t;
switch (type)
{
case PrimitiveType.POINTS:
t = BeginMode.Points;
break;
case PrimitiveType.TRIANGLESTRIP:
t = BeginMode.TriangleStrip;
break;
case PrimitiveType.LINESTRIP:
t = BeginMode.LineStrip;
break;
//HACK
/*case PrimitiveType.LINES:
t = GL._LINES;
break;
case PrimitiveType.TRIANGLES:
t = GL._TRIANGLES;
break;*/
default:
throw new Exception("wrong output primitive type: " + type.ToString());
}
return t;
}