About

Author: DeathByNukes

This is a part of my Audiosurf 2 scripting library.

Contents

TextureSettingsToString

Get texture settings of a UnityEngine.Texture2D object. Can also pass it a UnityEngine.Material to get information on the material's main texture.

function TextureSettingsToString(texture)
	if texture == nil then return 'nil' end
	assert(type(texture) == 'userdata')
	if texture:GetType().FullName == "UnityEngine.Material" then
		texture = texture:GetTexture("_MainTex")
	end
	assert(texture:GetType().FullName == 'UnityEngine.Texture2D', 'Only UnityEngine.Texture2D is supported.')
	local function v(name, hide)
		local result = tostring(texture[name])
		if hide then return result end
		return name .. ": " .. result
	end
	return table.concat({
		v('format'),
		v('mipmapCount'),
		v('hideFlags'),
		v('name'),
		v('anisoLevel'),
		v('dimension'),
		v('filterMode'),
		v('mipMapBias'),
		'width x height: ' .. v('width', true) .. " x " .. v('height', true),
		v('wrapMode') .. " (U: " .. v('wrapModeU', true) .. ", V: " .. v('wrapModeU', true) .. ", W: " .. v('wrapModeW', true) .. ")",
	}, "\n")
end