/// <summary> /// Creates the object from asset. /// </summary> /// <returns>The object from asset.</returns> /// <param name="path">Path.</param> static public GameObject CreateObjectFromAsset(string searchString, string undoName) { var prefab = AssetDatabase.FindAssets(searchString); var go = Utilites.CreateObject(AssetDatabase.GUIDToAssetPath(prefab[0])); Undo.RegisterCreatedObjectUndo(go, undoName); return(go); }
/// <summary> /// Creates the object from asset. /// </summary> /// <returns>The object from asset.</returns> /// <param name="key">Search string.</param> /// <param name="undoName">Undo name.</param> static public GameObject CreateObjectFromAsset(string key, string undoName) { var prefab = AssetDatabase.FindAssets(key); if (prefab.Length == 0) { return(null); } var go = Utilites.CreateObject(AssetDatabase.GUIDToAssetPath(prefab[0])); Undo.RegisterCreatedObjectUndo(go, undoName); Selection.activeObject = go; return(go); }