コード例 #1
0
        public static bool ToValueType(this TypeHandle handle, out ValueType typeHandleToValueType)
        {
            typeHandleToValueType = ValueType.Unknown;

            if (handle == TypeHandle.Unknown)
            {
                typeHandleToValueType = ValueType.Unknown;
                return(true);
            }

            if (handle == TypeHandle.Bool)
            {
                typeHandleToValueType = ValueType.Bool;
                return(true);
            }

            if (handle == TypeHandle.Int)
            {
                typeHandleToValueType = ValueType.Int;
                return(true);
            }

            if (handle == TypeHandle.Float)
            {
                typeHandleToValueType = ValueType.Float;
                return(true);
            }

            if (handle == TypeHandle.Vector2 || handle == DotsTypeHandle.Float2)
            {
                typeHandleToValueType = ValueType.Float2;
                return(true);
            }

            if (handle == TypeHandle.Vector3 || handle == DotsTypeHandle.Float3)
            {
                typeHandleToValueType = ValueType.Float3;
                return(true);
            }

            if (handle == TypeHandle.Vector4 || handle == DotsTypeHandle.Float4)
            {
                typeHandleToValueType = ValueType.Float4;
                return(true);
            }

            if (handle == TypeHandle.Quaternion || handle == DotsTypeHandle.Quaternion)
            {
                typeHandleToValueType = ValueType.Quaternion;
                return(true);
            }

            if (handle == TypeHandle.GameObject || handle == DotsTypeHandle.Entity)
            {
                typeHandleToValueType = ValueType.Entity;
                return(true);
            }

            if (handle == TypeHandle.String || handle.IsNativeString())
            {
                typeHandleToValueType = ValueType.StringReference;
                return(true);
            }

            return(false);
        }