1 using System.Collections.Generic;
6 namespace droid.Runtime.Prototyping.Configurables {
10 [AddComponentMenu(ConfigurableComponentMenuPath._ComponentMenuPath
12 + ConfigurableComponentMenuPath._Postfix)]
14 [SerializeField]
int _amount = 0;
16 [SerializeField]
Axis _axis =
Axis.X_;
18 [SerializeField] GameObject _object_to_spawn = null;
20 List<GameObject> _spawned_objects = null;
25 public override string PrototypingTypeName {
get {
return "ObjectSpawnerConfigurable"; } }
28 this.DestroyObjects();
29 this._spawned_objects =
new List<GameObject>();
33 void DestroyObjects() {
34 if (this._spawned_objects != null) {
35 foreach (var o
in this._spawned_objects) {
40 foreach (Transform c
in this.transform) {
41 Destroy(c.gameObject);
46 if (this._object_to_spawn) {
48 if (this._axis ==
Axis.X_) {
50 }
else if (this._axis ==
Axis.Z_) {
51 dir = Vector3.forward;
54 var transform1 = this.transform;
55 for (var i = 0; i < this._amount; i++) {
56 this._spawned_objects.Add(Instantiate(this._object_to_spawn,
57 transform1.position + dir * i,
64 void OnApplicationQuit() { this.DestroyObjects(); }
66 public override ISpace ConfigurableValueSpace {
get; }
70 var go = Instantiate(this._object_to_spawn, this.transform);
71 this._spawned_objects.Add(go);
73 if (this._spawned_objects.Count > 0) {
74 this._spawned_objects.RemoveAt(this._spawned_objects.Count - 1);
override void ApplyConfiguration(IConfigurableConfiguration obj)