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


C# PrimitiveType.ToString方法代码示例

本文整理汇总了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;
        }
开发者ID:Gege00,项目名称:spacepuppy-unity-framework,代码行数:52,代码来源:PrimitiveUtil.cs

示例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());
     }
 }
开发者ID:kekraft,项目名称:XNAProject,代码行数:12,代码来源:PrimitiveBatch.cs

示例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;
        }
开发者ID:cody82,项目名称:spacewar-arena,代码行数:28,代码来源:OpenGL.cs


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