上传工具
This commit is contained in:
parent
6033a0b34f
commit
d3d84d1380
50
Assets/Scripts/Editor/SetReadWrite.cs
Normal file
50
Assets/Scripts/Editor/SetReadWrite.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class SetReadWrite : Editor
|
||||
{
|
||||
[MenuItem("Assets/FBX ReadWrite Enable %&r")]
|
||||
public static void EnableFBXReadWrite()
|
||||
{
|
||||
Object[] selectedObjects = Selection.GetFiltered<Object>(SelectionMode.DeepAssets);
|
||||
foreach (Object obj in selectedObjects)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath(obj);
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
EnableFBXReadWriteInFolder(path);
|
||||
}
|
||||
else if (path.EndsWith(".fbx", System.StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
EnableFBXReadWriteForFile(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void EnableFBXReadWriteInFolder(string folderPath)
|
||||
{
|
||||
string[] files = Directory.GetFiles(folderPath, "*.fbx", SearchOption.AllDirectories);
|
||||
foreach (string file in files)
|
||||
{
|
||||
EnableFBXReadWriteForFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
public static void EnableFBXReadWriteForFile(string filePath)
|
||||
{
|
||||
string relativePath = filePath;
|
||||
ModelImporter importer = AssetImporter.GetAtPath(relativePath) as ModelImporter;
|
||||
if (importer != null)
|
||||
{
|
||||
importer.isReadable = true;
|
||||
AssetDatabase.ImportAsset(relativePath, ImportAssetOptions.ForceUpdate);
|
||||
Debug.Log("Enabled Read/Write for: " + relativePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user