本文整理汇总了C#中DynValue.CheckUserDataType方法的典型用法代码示例。如果您正苦于以下问题:C# DynValue.CheckUserDataType方法的具体用法?C# DynValue.CheckUserDataType怎么用?C# DynValue.CheckUserDataType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynValue
的用法示例。
在下文中一共展示了DynValue.CheckUserDataType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StoreReturnVariable
protected virtual void StoreReturnVariable(DynValue returnValue)
{
if (returnVariable == null || returnValue == null)
{
return;
}
// Store the return value in a Fungus Variable
System.Type variableType = returnVariable.GetType();
if (variableType == typeof(BooleanVariable) && returnValue.Type == DataType.Boolean)
{
(returnVariable as BooleanVariable).value = returnValue.Boolean;
}
else if (variableType == typeof(IntegerVariable) && returnValue.Type == DataType.Number)
{
(returnVariable as IntegerVariable).value = (int)returnValue.Number;
}
else if (variableType == typeof(FloatVariable) && returnValue.Type == DataType.Number)
{
(returnVariable as FloatVariable).value = (float)returnValue.Number;
}
else if (variableType == typeof(StringVariable) && returnValue.Type == DataType.String)
{
(returnVariable as StringVariable).value = returnValue.String;
}
else if (variableType == typeof(ColorVariable) && returnValue.Type == DataType.UserData)
{
(returnVariable as ColorVariable).value = returnValue.CheckUserDataType<Color>("ExecuteLua.StoreReturnVariable");
}
else if (variableType == typeof(GameObjectVariable) && returnValue.Type == DataType.UserData)
{
(returnVariable as GameObjectVariable).value = returnValue.CheckUserDataType<GameObject>("ExecuteLua.StoreReturnVariable");
}
else if (variableType == typeof(MaterialVariable) && returnValue.Type == DataType.UserData)
{
(returnVariable as MaterialVariable).value = returnValue.CheckUserDataType<Material>("ExecuteLua.StoreReturnVariable");
}
else if (variableType == typeof(ObjectVariable) && returnValue.Type == DataType.UserData)
{
(returnVariable as ObjectVariable).value = returnValue.CheckUserDataType<Object>("ExecuteLua.StoreReturnVariable");
}
else if (variableType == typeof(SpriteVariable) && returnValue.Type == DataType.UserData)
{
(returnVariable as SpriteVariable).value = returnValue.CheckUserDataType<Sprite>("ExecuteLua.StoreReturnVariable");
}
else if (variableType == typeof(TextureVariable) && returnValue.Type == DataType.UserData)
{
(returnVariable as TextureVariable).value = returnValue.CheckUserDataType<Texture>("ExecuteLua.StoreReturnVariable");
}
else if (variableType == typeof(Vector2Variable) && returnValue.Type == DataType.UserData)
{
(returnVariable as Vector2Variable).value = returnValue.CheckUserDataType<Vector2>("ExecuteLua.StoreReturnVariable");
}
else if (variableType == typeof(Vector3Variable) && returnValue.Type == DataType.UserData)
{
(returnVariable as Vector3Variable).value = returnValue.CheckUserDataType<Vector3>("ExecuteLua.StoreReturnVariable");
}
else
{
Debug.LogError("Failed to convert " + returnValue.Type.ToLuaTypeString() + " return type to " + variableType.ToString());
}
}