Created
December 2, 2022 21:32
-
-
Save Slyrith/ac9c8434bf8469eda67416d8910fde94 to your computer and use it in GitHub Desktop.
unity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| using System.Numerics; | |
| using Unity.VisualScripting; | |
| using UnityEngine; | |
| using UnityEngine.SceneManagement; | |
| using UnityEngine.UIElements; | |
| using Vector3 = UnityEngine.Vector3; | |
| public class PropSpawn : MonoBehaviour | |
| { | |
| public static PropSpawn Api { get; set; } | |
| public Transform _transformLocations = SpawnLocations.Api.locations[0]; | |
| public Transform _propTransformLocation = SpawnItemsLocations.Api.locations[0]; | |
| public Transform TransformLocations { get { return _transformLocations; } set { _transformLocations = value; } } | |
| public Transform PropTransformLocations { get { return _propTransformLocation; } set { _propTransformLocation = value; } } | |
| public void Spawn() | |
| { | |
| _propTransformLocation.position = new Vector3(_transformLocations.position.x, _transformLocations.position.y, _transformLocations.position.z); | |
| } | |
| } | |
| public class SpawnBehaviour : MonoBehaviour | |
| { | |
| public void OnGUI() | |
| { | |
| if (GUI.Button(new Rect(20, 20, 150, 25), "Tap the spawn!")) | |
| { | |
| PropSpawn.Api.Spawn(); | |
| } | |
| } | |
| } | |
| public class SpawnLocations : MonoBehaviour | |
| { | |
| public static SpawnLocations Api { get; set; } | |
| public void Awake() | |
| { | |
| Api = this; | |
| TakeSpawnLocations(); | |
| } | |
| public Transform spawnLocations; | |
| public List<Transform> locations; | |
| public void TakeSpawnLocations() | |
| { | |
| foreach (Transform child in spawnLocations) | |
| { | |
| locations.Add(child); | |
| } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment