private void SpawnEditorPreviewCreep(GameObject prefab) { var go = WaveEditorHelper.BuildBareMeshCopy(prefab); go.name = AddPreviewSuffix(go.name); go.transform.position = new Vector3(SpawnPosition.x, go.transform.position.y, SpawnPosition.z); _PreviewObjects.Add(go); SaveCurrentSpawnData(); }
private void SetupSpawnPreview() { if (!_PreviewRendered) { foreach (var datapoint in _Context._SelectedSpawn.SpawnData) { var preview = WaveEditorHelper.BuildBareMeshCopy(_CreepPrefabs.Single(x => x.name == datapoint.CreepIdentifier)); preview.name = AddPreviewSuffix(preview.name); var spawntransform = _Context._Spawnpoint.transform; var relativecreeppos = spawntransform.TransformPoint(datapoint.RelativePosition); preview.transform.position = relativecreeppos; _PreviewObjects.Add(preview); } _PreviewRendered = true; } }
public static void BeginWaveEditing(GameObject spawnpoint, WavesManager wavesmanager) { EditorSceneManager.SaveOpenScenes(); if (spawnpoint == null) { Debug.Log("Need a spawnpoint to edit"); return; } if (wavesmanager == null) { Debug.Log($"Must have one component <{nameof(WavesManager)}> attached"); return; } //Pre-setup for wave editor scene. GameObject spawnobjectcopy = WaveEditorHelper.BuildBareMeshCopy(spawnpoint); spawnobjectcopy.name = "Spawn-Preview"; spawnobjectcopy.AddComponent <ImmutableGameObject>(); spawnobjectcopy.transform.position = spawnpoint.transform.position; spawnobjectcopy.transform.rotation = spawnpoint.transform.rotation; HideAllObjectsExcept(spawnobjectcopy); Selection.activeGameObject = spawnobjectcopy; SceneView.lastActiveSceneView.FrameSelected(); var editorgui = new WaveEditorSceneContext(spawnobjectcopy, wavesmanager.WavesContainer, () => { RestoreOriginalScene(); GameObject.DestroyImmediate(spawnobjectcopy); }); }