We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 02e63d3 commit e42016bCopy full SHA for e42016b
2 files changed
Assets/Editor/Scripts/CreatePrefab.cs
@@ -0,0 +1,24 @@
1
+using UnityEngine;
2
+using UnityEditor;
3
+
4
+public class CreatePrefab
5
+{
6
+ [MenuItem("Prefabs/Create/Create Prefab")]
7
+ static public void CreateACubePrefab()
8
+ {
9
+ var path = EditorUtility.SaveFilePanel("Create Prefab", "Assets", "Cube.prefab", "prefab");
10
11
+ if (!string.IsNullOrEmpty(path))
12
13
+ var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
14
15
+ // If you simply want to cube to be written as an asset but not turn in a prefab instance
16
+ // use this method
17
+ PrefabUtility.SaveAsPrefabAsset(cube, path);
18
19
+ // This method will create a Prefab asset and make the GameObject an instance of the
20
+ // new prefab asset
21
+ PrefabUtility.SaveAsPrefabAssetAndConnect(cube, path, InteractionMode.AutomatedAction);
22
+ }
23
24
+}
Assets/Editor/Scripts/CreatePrefab.cs.meta
0 commit comments