DeveloperConsole.SetProperty C# (CSharp) Method

SetProperty() public method

public SetProperty ( GameObject gameObject, Component component, string propertyName, string argument ) : void
gameObject GameObject
component Component
propertyName string
argument string
return void
	void SetProperty(GameObject gameObject, Component component, string propertyName, string argument)
	{
		Type componentType = component.GetType();
		PropertyInfo pInfo = componentType.GetProperty(propertyName);
		
		if (pInfo != null)
		{
			bool paramSuccess = true;
			object pArgument = null;
			
			paramSuccess = ParseStringToObject(pInfo.PropertyType, argument, ref pArgument);
			
			if (paramSuccess)
			{
				pInfo.SetValue(component, pArgument, null);
			}
			else
			{
				PrintToConsole( "Failed to set variable of type " + pInfo.PropertyType.ToString() );
			}
		}
	}