浏览代码

Implementation mass prefab generation from fbx models

/main
Mohsen Kamalzadeh 4 年前
当前提交
82de97f1
共有 1 个文件被更改,包括 9 次插入1 次删除
  1. 10
      com.unity.perception/Editor/AssetPreparation/AssetPreparationTools.cs

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


using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
namespace UnityEditor.Perception.AssetPreparation

[MenuItem("Assets/Perception/Create Prefabs from Selected Models")]
static void CreatePrefabsFromSelectedModels()
{
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);
}
}
}
正在加载...
取消
保存