//misc properties Layer Tag ObjectName SpriteRenderer void SetOtherProperties(CSpawnableObject3D _Obj, GameObject _GO) //_Obj info and GO already spawned { if (_Obj.ObjectName != "") { _GO.name = _Obj.ObjectName; } }
//Spawn with set properties: GameObject SpawnAfterPropertiesAreSet(CSpawnableObject3D _SpawnableObject, Vector3 _Position, Quaternion _Rotation, float _Scale) { GameObject go_temp = Instantiate(_SpawnableObject.Prefab, this.transform.position + _Position, _Rotation) as GameObject; go_temp.transform.localScale = go_temp.transform.localScale * _Scale; return(go_temp); }
float SetScale(CSpawnableObject3D _Object) { if (_Object.RandomScale) { return(UnityEngine.Random.Range(_Object.ScaleMin, _Object.ScaleMax)); } else { return(1.00f); } }
//Eigentlicher Spawn void SpawnObject(CSpawnableObject3D _Object) { //SetPos Vector3 _Position = SetPosition(_Object); //SetRot Vector3 _Rotation = SetRotation(_Object); //SetScale float _Scale = SetScale(_Object); tGameObject = SpawnAfterPropertiesAreSet(_Object, _Position, Quaternion.Euler(_Rotation), _Scale); SetOtherProperties(_Object, tGameObject); //ApplyPhysicsToGO(_Object, tGameObject); }
Vector3 SetPosition(CSpawnableObject3D _Object) { if (_Object.RandomSpawn) { float RandomX = UnityEngine.Random.Range(_Object.RandomXmin, _Object.RandomXmax); float RandomY = UnityEngine.Random.Range(_Object.RandomYmin, _Object.RandomYmax); float RandomZ = UnityEngine.Random.Range(_Object.RandomZmin, _Object.RandomZmax); return(new Vector3(RandomX, RandomY, RandomZ)); } else { return(_Object.RelativeSpawnPos); } }
Vector3 SetRotation(CSpawnableObject3D _Object) { Vector3 tRotation = Vector3.zero; if (_Object.RotationRandom) { tRotation = new Vector3(UnityEngine.Random.Range(_Object.RotationMin, _Object.RotationMax), UnityEngine.Random.Range(_Object.RotationMin, _Object.RotationMax), UnityEngine.Random.Range(_Object.RotationMin, _Object.RotationMax)); } else { tRotation = _Object.RotationDegree; } //Debug.Log("Rotation 2D " + _RotationAngle); return(tRotation); }