/// <summary> /// Creates a prefab and save to assets. /// </summary> /// <param name="name">Prefab name</param> /// <param name="path">Asset folder path</param> /// <typeparam name="T">Script type</typeparam> private static void CreatePrefab <T>(string name, string path) where T : MonoBehaviour { var go = EditorUtility.CreateGameObjectWithHideFlags( name, HideFlags.DontSaveInEditor & HideFlags.HideInHierarchy, typeof(T)); var uniquePath = AssetDatabase.GenerateUniqueAssetPath(path + "/" + name + ".prefab"); PrefabUtility.SaveAsPrefabAsset(go, uniquePath); Object.DestroyImmediate(go); BulletStormLogger.Log("Created prefab '" + name + "'.\n" + path + "/" + name); }
public override void OnDropObjects(Object[] objects) { var pos = window.WindowToGridPosition(Event.current.mousePosition) - new Vector2(15, 15); var cnt = 0; var offset = new Vector2(10, 10); var add = false; Node node = null; foreach (var @object in objects) { switch (@object) { case ShapeAsset asset: { node = CreateNode(typeof(ShapeReference), pos + offset * cnt++); window.SelectNode(node, add); add = true; if (node is ShapeReference shapeReference) { shapeReference.shapeAsset = asset; } else { BulletStormLogger.LogError("An unexpected errored occured when creating node."); } break; } default: BulletStormLogger.Log($"{@object} can't drop into shape graph"); break; } Util.System.SendMessage(node, "OnValidate"); } }