コード例 #1
0
ファイル: AgentModule.cs プロジェクト: jglazman/TankBattle
 protected override void DestroyInternal()
 {
     if (_gameObject != null)
     {
         GameObject.Destroy(_gameObject);
         _gameObject     = null;
         _transform      = null;
         _agentBehaviour = null;
         _isActive       = false;
     }
 }
コード例 #2
0
ファイル: AgentModule.cs プロジェクト: jglazman/TankBattle
        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;
        }