/// <summary> /// Clear references to textures and delete the target objects. /// </summary> public void Cleanup() { _texture2D = null; _sprite = null; _renderTexture = null; _target = null; _targetContainer = null; targetBounds = default(Bounds); _textureSize = default(Vector2); if (_container != null) { UIObject3DUtilities.UnRegisterTargetContainer(this); if (Application.isPlaying) { Destroy(_container.gameObject); } else { DestroyImmediate(_container.gameObject); } _container = null; } }
void OnDestroy() { UIObject3DUtilities.UnRegisterTargetContainer(this); }