/// <summary> /// The global function that every other can call to disable the object with the required variables such as : /// spawning or not another gameObject, waiting for x seconds before disabling. /// </summary> private void Disabling() { isDisabling = true; if (callFunctionOnSend) { functionOnSend.Invoke(); } if (enableOtherGoOnDisable) { try { PoolingSystem.GetFromPool(gameObjToEnable, transform.position, transform.rotation); } catch (UnassignedReferenceException) { Debug.LogWarning("You tried calling an object on disable with SendToPoolEvents but no GameObject was assigned to the script on the object " + gameObject.name); } } if (disableDelay) { StartCoroutine(DisableDelay()); } else { if (resetTransformPosition) { transform.position = startingPosition; } PoolingSystem.SendToPool(gameObject); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.A)) { PoolingSystem.Preload(gameObjectPls, 10); } if (Input.GetKeyDown(KeyCode.E)) { PoolingSystem.GetFromPool(gameObjectPls, transform.position, transform.rotation); } if (Input.GetKey(KeyCode.Z)) { transform.Translate(0.1f, 0, 0); } if (Input.GetKey(KeyCode.Q)) { transform.Translate(0, 0, 0.1f); } if (Input.GetKey(KeyCode.D)) { transform.Translate(0, 0, -0.1f); } if (Input.GetKey(KeyCode.S)) { transform.Translate(-0.1f, 0, 0); } }