/// <summary> /// Creates an instance of a specified state type, either through .NET activation /// or through a defined state resolver. /// </summary> /// <param name="stateType"></param> /// <returns></returns> private ISolidState InstantiateState(Type stateType) { // Do we have a state resolver? if (_stateResolver != null) { var instance = _stateResolver.ResolveState(stateType); if (instance == null) { throw new SolidStateException(string.Format("State resolver returned null for type '{0}'!", stateType.Name)); } return(instance); } else { return((ISolidState)Activator.CreateInstance(stateType)); } }
/// <summary> /// Creates an instance of a specified state type, either through .NET activation /// or through a defined state resolver. /// </summary> private ISolidState InstantiateState(Type stateType) { // Do we have a state resolver? if (_stateResolver != null) { var instance = _stateResolver.ResolveState(stateType); if (instance == null) { Debug.LogError(string.Format("State resolver could not resolve a state for type '{0}'!", stateType.Name)); return(instance); } return(instance); } else { return((ISolidState)Activator.CreateInstance(stateType)); } }