Guest User

Untitled

a guest
Apr 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function ExportGO(go:GameObject, froot:String):GameObject
  2.     {
  3.         var path : String = froot + "/" + go.name ;
  4.         var orig : GameObject = Instantiate (go.gameObject,
  5.         go.gameObject.transform.position, go.gameObject.transform.rotation);
  6.        
  7.         var prefab : Object = EditorUtility.CreateEmptyPrefab( path + ".prefab");
  8.         AssetDatabase.Refresh();
  9.         EditorUtility.ReplacePrefab(orig, prefab as UnityEngine.Object);
  10.         AssetDatabase.Refresh();
  11.         DestroyImmediate(orig as GameObject);
  12.         DestroyImmediate(go.gameObject as GameObject);
  13.         var clone : GameObject = EditorUtility.InstantiatePrefab(prefab as UnityEngine.Object) as GameObject;
  14.         Debug.Log(clone);
  15.         //Remove the tiles, irrelevant
  16.         //FileUtil.DeleteFileOrDirectory("Assets/BatchingToolsTemp");
  17.         AssetDatabase.Refresh();
  18.         AssetDatabase.SaveAssets();
  19.         return clone;
  20.     }
Add Comment
Please, Sign In to add comment