private void OnValidate() { if (autoPlaced) { spawnPoints = new SpawnPointDefinition[count]; float rotDelta = Mathf.PI * 2f / count; for (int i = 0; i < count; i++) { float perimeter = startRotation * Mathf.Deg2Rad + rotDelta * i; Vector2 pos = new Vector2(Mathf.Cos(perimeter), Mathf.Sin(perimeter)) * distanceFromCenter; float rot = Vector2.SignedAngle(Vector2.right, pos.normalized); spawnPoints[i] = new SpawnPointDefinition() { position = pos, rotation = rot }; } } foreach (SequenceElement elem in sequence) { if (!elem.CheckDataValidity()) { elem.ResetData(); } } }
public AttackPoint CreateSpawnPoint(SpawnPointDefinition def, Transform parent) { GameObject go = new GameObject("AttackPoint"); go.transform.SetParent(parent); AttackPoint point = go.AddComponent <AttackPoint>(); point.position = def.position; point.rotation = def.rotation; return(point); }