コード例 #1
0
ファイル: TextureMgr.cs プロジェクト: iuvei/hzmj_client
    private void ResizeUITexture(Material newMat, UITexture texture, TextureResizeType resizeType)
    {
        Vector3 dim = texture.Dimensions;

        if (newMat.mainTexture != null)
        {
            switch (resizeType)
            {
            case TextureResizeType.ResizeBasedOnOrigin:
            {
                dim.x = newMat.mainTexture.width;
                dim.y = newMat.mainTexture.height;
            }
            break;

            case TextureResizeType.ResizeBasedOnWidth:
            {
                dim.y = dim.x / newMat.mainTexture.width * newMat.mainTexture.height;
            }
            break;

            case TextureResizeType.ResizeBasedOnHeight:
            {
                dim.x = dim.y / newMat.mainTexture.height * newMat.mainTexture.width;
            }
            break;
            }
        }

        texture.Dimensions = dim;
    }
コード例 #2
0
ファイル: TextureMgr.cs プロジェクト: iuvei/hzmj_client
    public Material LoadResizeTexture(UITexture texture, string shaderName, string path, bool transparent, TextureResizeType type)
    {
        Shader   s  = ResLoader.LoadAsset(shaderName) as Shader;
        Material mt = BaseLoadTexture(s, path, transparent);

        texture.material = mt;

        ResizeUITexture(mt, texture, type);

        return(mt);
    }