public static void GenBullet() { if (!GenerateBullet.CheckObjectType()) { return; } GameObject selectedObj = Selection.activeObject as GameObject; if (selectedObj == null) { return; } GameObject bullet = new GameObject(selectedObj.name); bullet.transform.position = Vector3.zero; GameObject obj = GameObject.Instantiate <GameObject>(selectedObj); obj.name = "mesh"; obj.transform.SetParent(bullet.transform); obj.transform.localPosition = Vector3.zero; EffectController effectCtrl = bullet.AddMissingComponent <EffectController>(); effectCtrl.autoRemove = false; PrefabUtility.SaveAsPrefabAssetAndConnect(bullet, "Assets/RawResources/Scene/Prefab/Bullet/" + selectedObj.name + ".prefab", InteractionMode.AutomatedAction); GameObject.DestroyImmediate(bullet); }
public static bool CheckBullet() { return(GenerateBullet.CheckObjectType()); }