@@ -8,10 +8,11 @@ using System.Linq;
8
8
using UnityEngine.AssetGraph;
9
9
10
10
[CustomPrefabBuilder("MyPrefabBuilder")]
11
- public class MyPrefabBuilder : IPrefabBuilder {
12
-
13
- [SerializeField] private Color color;
11
+ public class MyPrefabBuilder : IPrefabBuilder
12
+ {
14
13
14
+ [SerializeField] private Vector3 m_size;
15
+
15
16
public void OnValidate () {
16
17
}
17
18
@@ -21,28 +22,28 @@ public class MyPrefabBuilder : IPrefabBuilder {
21
22
*/
22
23
public bool CanCreatePrefab (string groupKey, List<UnityEngine.Object> objects, ref PrefabCreateDescription description) {
23
24
24
- var tex = objects.Find(o => o.GetType() == typeof(UnityEngine.Texture2D ));
25
+ var pMat = objects.Find(o => o.GetType() == typeof(PhysicMaterial ));
25
26
26
- if(tex != null) {
27
- description.prefabName = string.Format( "MyPrefab{0}", groupKey) ;
27
+ if(pMat != null) {
28
+ description.prefabName = $ "MyPrefab{groupKey}" ;
28
29
}
29
30
30
- return tex != null;
31
+ return pMat != null;
31
32
}
32
33
33
34
/**
34
35
* Create Prefab.
35
36
*/
36
- public UnityEngine. GameObject CreatePrefab (string groupKey, List<UnityEngine.Object> objects) {
37
+ public GameObject CreatePrefab (string groupKey, List<UnityEngine.Object> objects, GameObject previous ) {
37
38
38
- GameObject go = new GameObject(string.Format("MyPrefab{0}", groupKey ));
39
+ var pMat = (PhysicMaterial)objects.Find(o => o.GetType() == typeof(PhysicMaterial ));
39
40
40
- GUITexture t = go.AddComponent<GUITexture>( );
41
+ var go = new GameObject($"MyPrefab{groupKey}" );
41
42
42
- Texture2D tex = (Texture2D)objects.Find(o => o.GetType() == typeof(UnityEngine.Texture2D) );
43
+ var c = go.AddComponent<BoxCollider>( );
43
44
44
- t.texture = tex ;
45
- t.color = color ;
45
+ c.size = m_size ;
46
+ c.material = pMat ;
46
47
47
48
return go;
48
49
}
@@ -54,9 +55,9 @@ public class MyPrefabBuilder : IPrefabBuilder {
54
55
55
56
EditorGUILayout.HelpBox("This is the inspector of your custom PrefabBuilder. You can customize by implementing OnInspectorGUI().", MessageType.Info);
56
57
57
- var newValue = EditorGUILayout.ColorField("Example ", color );
58
- if(newValue != color ) {
59
- color = newValue;
58
+ var newValue = EditorGUILayout.Vector3Field("Size ", m_size );
59
+ if(newValue != m_size ) {
60
+ m_size = newValue;
60
61
onValueChanged();
61
62
}
62
63
}
0 commit comments