unity源码解析Texture

Texture类继承自Object是作为一个Texture2D与Texture3D的基类存在的,一般也并不直接使用它,且其本身也并没有对纹理数据的管理,只有一个,就是获取纹理的id

using System;
using System.Runtime.CompilerServices;

namespace UnityEngine
{
    public class Texture : Object
    {
        public static extern int masterTextureLimit
        {
            [WrapperlessIcall]
            [MethodImpl(MethodImplOptions.InternalCall)]
            get;
            [WrapperlessIcall]
            [MethodImpl(MethodImplOptions.InternalCall)]
            set;
        }

        public static extern AnisotropicFiltering anisotropicFiltering
        {
            [WrapperlessIcall]
            [MethodImpl(MethodImplOptions.InternalCall)]
            get;
            [WrapperlessIcall]
            [MethodImpl(MethodImplOptions.InternalCall)]
            set;
        }

        public virtual int width
        {
            get
            {
                return Texture.Internal_GetWidth(this);
            }
            set
            {
                throw new Exception("not implemented");
            }
        }

        public virtual int height
        {
            get
            {
                return Texture.Internal_GetHeight(this);
            }
            set
            {
                throw new Exception("not implemented");
            }
        }

        public extern FilterMode filterMode
        {
            [WrapperlessIcall]
            [MethodImpl(MethodImplOptions.InternalCall)]
            get;
            [WrapperlessIcall]
            [MethodImpl(MethodImplOptions.InternalCall)]
            set;
        }

        public extern int anisoLevel
        {
            [WrapperlessIcall]
            [MethodImpl(MethodImplOptions.InternalCall)]
            get;
            [WrapperlessIcall]
            [MethodImpl(MethodImplOptions.InternalCall)]
            set;
        }

        public extern TextureWrapMode wrapMode
        {
            [WrapperlessIcall]
            [MethodImpl(MethodImplOptions.InternalCall)]
            get;
            [WrapperlessIcall]
            [MethodImpl(MethodImplOptions.InternalCall)]
            set;
        }

        public extern float mipMapBias
        {
            [WrapperlessIcall]
            [MethodImpl(MethodImplOptions.InternalCall)]
            get;
            [WrapperlessIcall]
            [MethodImpl(MethodImplOptions.InternalCall)]
            set;
        }

        public Vector2 texelSize
        {
            get
            {
                Vector2 result;
                Texture.Internal_GetTexelSize(this,out result);
                return result;
            }
        }

        [WrapperlessIcall]
        [MethodImpl(MethodImplOptions.InternalCall)]
        public static extern void SetGlobalAnisotropicFilteringLimits(int forcedMin,int globalMax);

        [WrapperlessIcall]
        [MethodImpl(MethodImplOptions.InternalCall)]
        private static extern int Internal_GetWidth(Texture mono);

        [WrapperlessIcall]
        [MethodImpl(MethodImplOptions.InternalCall)]
        private static extern int Internal_GetHeight(Texture mono);

        [WrapperlessIcall]
        [MethodImpl(MethodImplOptions.InternalCall)]
        private static extern void Internal_GetTexelSize(Texture tex,out Vector2 output);

        [WrapperlessIcall]
        [MethodImpl(MethodImplOptions.InternalCall)]
        public extern IntPtr GetNativeTexturePtr(); //读取本地文件生成的Texture获取指针,可以为Texture2d的创建提供数据

        [WrapperlessIcall]
        [MethodImpl(MethodImplOptions.InternalCall)]
        public extern int GetNativeTextureID();
    }
}

你可能感兴趣的:(unity源码解析Texture)