Skip to content

Commit

Permalink
Update com.unity.perception/Editor/AssetPreparation/AssetPreparationT…
Browse files Browse the repository at this point in the history
…ools.cs


committed suggested changes

Co-authored-by: sleal-unity <[email protected]>
  • Loading branch information
mkamalza and sleal-unity authored Dec 2, 2020
1 parent ac963af commit e209f10
Showing 1 changed file with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
using System.IO;
using System.IO;
using UnityEngine;

namespace UnityEditor.Perception.AssetPreparation
{
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);
}
}
}
Expand Down

0 comments on commit e209f10

Please sign in to comment.