浏览代码

Update com.unity.perception/Editor/AssetPreparation/AssetPreparationTools.cs

committed suggested changes

Co-authored-by: sleal-unity <53197518+sleal-unity@users.noreply.github.com>
/main
GitHub 4 年前
当前提交
e0b6fe2c
共有 1 个文件被更改,包括 13 次插入16 次删除
  1. 29
      com.unity.perception/Editor/AssetPreparation/AssetPreparationTools.cs

29
com.unity.perception/Editor/AssetPreparation/AssetPreparationTools.cs


using System.IO;
using System.IO;
class AssetPreparationTools
static class AssetPreparationMenuItems
class AssetPreparationMenuFunctions : MonoBehaviour
/// <summary>
/// Function for creating prefabs from multiple models with one click. Created prefabs will be placed in the same folder as their corresponding model.
/// </summary>
[MenuItem("Assets/Perception/Create Prefabs from Selected Models")]
static void CreatePrefabsFromSelectedModels()
/// <summary>
/// Function for creating prefabs from multiple models with one click. Created prefabs will be placed in the same folder as their corresponding model.
/// </summary>
[MenuItem("Assets/Perception/Create Prefabs from Selected Models")]
static void CreatePrefabsFromSelectedModels()
foreach (var selection in Selection.gameObjects)
foreach (var selection in Selection.gameObjects)
{
var path = AssetDatabase.GetAssetPath(selection);
var tmpGameObject = Instantiate(selection);
var destinationPath = Path.GetDirectoryName(path) + "/" + selection.name + ".prefab";
PrefabUtility.SaveAsPrefabAsset(tmpGameObject, destinationPath);
DestroyImmediate(tmpGameObject);
}
var path = AssetDatabase.GetAssetPath(selection);
var tmpGameObject = Object.Instantiate(selection);
var destinationPath = Path.GetDirectoryName(path) + "/" + selection.name + ".prefab";
PrefabUtility.SaveAsPrefabAsset(tmpGameObject, destinationPath);
Object.DestroyImmediate(tmpGameObject);
}
}
}
正在加载...
取消
保存