void Start() { mace = GameObject.FindGameObjectWithTag("enemyTag").GetComponent <MaceControl>(); physics = GetComponent <Rigidbody2D>(); physics.AddForce(mace.GetDirection() * 1000); Destroy(gameObject, 3); }
public override void OnInspectorGUI() { MaceControl script = (MaceControl)target; if (GUILayout.Button("produce")) { GameObject newObject = new GameObject(); newObject.transform.parent = script.transform; newObject.transform.position = script.transform.position; newObject.name = script.transform.childCount.ToString(); } EditorGUILayout.PropertyField(serializedObject.FindProperty("layerMask")); EditorGUILayout.PropertyField(serializedObject.FindProperty("frontSide")); EditorGUILayout.PropertyField(serializedObject.FindProperty("backSide")); EditorGUILayout.PropertyField(serializedObject.FindProperty("bullet")); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); }