Marcel Zickler 3 vuotta sitten
vanhempi
commit
1782ce5fea

+ 70 - 0
Assets/CarSpawnManipulator.cs

@@ -0,0 +1,70 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using TrafficSimulation;
+using UnityEditor;
+using UnityEngine;
+
+public class CarSpawnManipulator : MonoBehaviour
+{
+    private void Start()
+    {
+        
+    }
+    private void Update()
+    {
+        
+    }
+}
+[CustomEditor(typeof(CarSpawnManipulator))]
+public class CarSpawnManipulatorEditor : Editor
+{
+    private SpawnWatcher[] spawns;
+    private int spawnRate = 2; 
+    private void OnEnable()
+    {
+        this.spawns = ((CarSpawnManipulator) target).GetComponentsInChildren<SpawnWatcher>();
+    }
+    public override void OnInspectorGUI()
+    {
+        EditorGUILayout.LabelField("Sets All Car Spawns in the Conditions!");
+        //Debug.Log("Found Spawns: " + this.spawns.Length);
+        if (GUILayout.Button("Position Y to 0", GUILayout.Width(256)))
+        {
+            SetPosY(0);
+        }
+        if (GUILayout.Button("BoxCollider Size (6,1,6)", GUILayout.Width(256)))
+        {
+            SetSize(10,10);
+        }
+        this.spawnRate = EditorGUILayout.IntSlider("Spawn Rate", this.spawnRate,0, 10);
+        if (GUILayout.Button("Set Spawn Rate", GUILayout.Width(256)))
+        {
+            SetSpawnRate(spawnRate);
+        }
+    }
+    private void SetSpawnRate(int rate)
+    {
+        CarSituationSpawner[] spawners = ((CarSpawnManipulator)target).GetComponentsInChildren<CarSituationSpawner>();
+        foreach(CarSituationSpawner spawner in spawners)
+        {
+            spawner.spawnRate = rate;
+        }
+    }
+
+    private void SetSize(float xVal, float yVal)
+    {
+        foreach (SpawnWatcher spawn in this.spawns)
+        {
+            spawn.gameObject.GetComponent<BoxCollider>().size = new Vector3(6, 1, 6);
+        }
+    }
+
+    private void SetPosY(float value)
+    {
+        foreach(SpawnWatcher spawn in this.spawns)
+        {
+            spawn.gameObject.transform.position = new Vector3(spawn.gameObject.transform.position.x, value, spawn.gameObject.transform.position.z);
+        }
+    }
+}

+ 11 - 0
Assets/CarSpawnManipulator.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 9f6a1feea0b182f4783f0c43221178f4
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
Assets/Scenes/MainScene.unity