protected override void DestroyInternal() { if (_gameObject != null) { GameObject.Destroy(_gameObject); _gameObject = null; _transform = null; _agentBehaviour = null; _isActive = false; } }
public AgentModule(string gameObjectName, string prefabName, Vector3 worldPosition) { var prefab = Resources.Load <AgentBehaviour>(prefabName); if (prefab == null) { throw new Exception($"AgentBehaviour prefab not found in Resources: {prefabName}"); } _agentBehaviour = GameObject.Instantiate <AgentBehaviour>(prefab, worldPosition, Quaternion.identity); _transform = _agentBehaviour.transform; _gameObject = _agentBehaviour.gameObject; _gameObject.name = gameObjectName; }