// Need to do this to ensure that we don't use multiple different ToMonoBehaviour
        // bindings with different game objects but same type/id
        public void MarkGameObject(SingletonId id, GameObject gameObject)
        {
            GameObjectMarkInfo markInfo;

            if (_gameObjectMarks.TryGetValue(id, out markInfo))
            {
                if (markInfo.GameObject != gameObject)
                {
                    throw new ZenjectBindException(
                        "Attempted to use multiple different Game Objects with ToSingleMonoBehaviour using the same type/identifier: '{0}' / '{1}'"
                        .Fmt(id.ConcreteType, id.ConcreteIdentifier));
                }
            }
            else
            {
                markInfo = new GameObjectMarkInfo()
                {
                    GameObject = gameObject,
                };
                _gameObjectMarks.Add(id, markInfo);
            }

            markInfo.RefCount += 1;
        }
Exemple #2
0
        // Need to do this to ensure that we don't use multiple different ToMonoBehaviour
        // bindings with different game objects but same type/id
        public void MarkGameObject(SingletonId id, GameObject gameObject)
        {
            GameObjectMarkInfo markInfo;

            if (_gameObjectMarks.TryGetValue(id, out markInfo))
            {
                if (markInfo.GameObject != gameObject)
                {
                    throw new ZenjectBindException(
                              "Attempted to use multiple different Game Objects with ToSingleMonoBehaviour using the same type/identifier: '{0}' / '{1}'"
                              .Fmt(id.ConcreteType, id.ConcreteIdentifier));
                }
            }
            else
            {
                markInfo = new GameObjectMarkInfo()
                {
                    GameObject = gameObject,
                };
                _gameObjectMarks.Add(id, markInfo);
            }

            markInfo.RefCount += 1;
        }