本文整理汇总了C#中Texture.GetInstanceID方法的典型用法代码示例。如果您正苦于以下问题:C# Texture.GetInstanceID方法的具体用法?C# Texture.GetInstanceID怎么用?C# Texture.GetInstanceID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Texture
的用法示例。
在下文中一共展示了Texture.GetInstanceID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeTextureReadable
bool MakeTextureReadable(Texture tex)
{
string path = AssetDatabase.GetAssetPath(tex.GetInstanceID());
if (string.IsNullOrEmpty(path)) return false;
TextureImporter ti = AssetImporter.GetAtPath(path) as TextureImporter;
if (ti == null) return false;
TextureImporterSettings settings = new TextureImporterSettings();
ti.ReadTextureSettings(settings);
if (!settings.readable)
{
settings.readable = true;
ti.SetTextureSettings(settings);
AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate | ImportAssetOptions.ForceSynchronousImport);
}
return true;
}
示例2: ImportTexture
/// <summary>
/// Fix the import settings for the specified texture, re-importing it if necessary.
/// </summary>
public static Texture2D ImportTexture(Texture tex, bool forInput, bool force)
{
if (tex != null)
{
string path = AssetDatabase.GetAssetPath(tex.GetInstanceID());
return ImportTexture(path, forInput, force);
}
return null;
}
示例3: TextureToString
public static void TextureToString(int tab, StringBuilder sb, Texture tx, ref bool first)
{
if (exportTxs.Contains(tx))
return;
exportTxs.Add(tx);
if (first)
first = false;
else
sb.Append (",\n");
TabAppend (tab, sb, "'" + tx.name+"' : {\n");
int instId = tx.GetInstanceID();
string assetPath = AssetDatabase.GetAssetPath(tx);
// string destFile = folderPath + "/"+ Path.GetFileNameWithoutExtension(assetPath)+".png";
string destFile = folderPath + "/" + Path.GetFileName(assetPath);
string destPath = Path.GetDirectoryName(destFile);
// if (!Directory.Exists(destPath))
// Directory.CreateDirectory (destPath);
try
{
File.Copy (assetPath, destFile);
}
catch
{
}
/*
Texture2D tx2d = (Texture2D)tx;
byte[] bytes = tx2d.EncodeToPNG();
string destFile = folderPath+tx.name+".png";
System.IO.File.WriteAllBytes(destFile, bytes);
*/
TabAppend (tab+1, sb, "'url' : '" + tx.name+".png" + "'\n");
TabAppend (tab, sb, "}");
}
示例4: TextureToString
public static void TextureToString(int tab, StringBuilder sb, Texture tx, ref bool first)
{
if (first)
first = false;
else
sb.Append (",\n");
TabAppend (tab, sb, "'" + tx.name+"' : {\n");
int instId = tx.GetInstanceID();
string assetPath = AssetDatabase.GetAssetPath(tx);
TabAppend (tab+1, sb, "'url' : '" + assetPath + "'\n");
TabAppend (tab, sb, "}");
}