本文整理汇总了C#中X_UniTMX.MapObject.GetPropertyAsInt方法的典型用法代码示例。如果您正苦于以下问题:C# MapObject.GetPropertyAsInt方法的具体用法?C# MapObject.GetPropertyAsInt怎么用?C# MapObject.GetPropertyAsInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类X_UniTMX.MapObject
的用法示例。
在下文中一共展示了MapObject.GetPropertyAsInt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyCustomProperties
/// <summary>
/// Applies to gameObject any custom X-UniTMX properties present on obj
/// </summary>
/// <param name="gameObject">GameObject to apply custom properties to</param>
/// <param name="obj">MapObject to read custom properties from</param>
public void ApplyCustomProperties(GameObject gameObject, MapObject obj)
{
// nothing to do here...
if (gameObject == null || obj == null)
return;
// Set a layer number for gameObject
if (obj.HasProperty(Property_Layer))
gameObject.layer = obj.GetPropertyAsInt(Property_Layer);
if (obj.HasProperty(Property_LayerName))
gameObject.layer = LayerMask.NameToLayer(obj.GetPropertyAsString(Property_LayerName));
// Add a tag for gameObject
if (obj.HasProperty(Property_Tag))
gameObject.tag = obj.GetPropertyAsString(Property_Tag);
// Add Components for this gameObject
int c = 1;
while (obj.HasProperty(Property_AddComponent + c))
{
UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(gameObject, "Assets/X-UniTMX/Code/Map.cs (2684,5)", obj.GetPropertyAsString(Property_AddComponent + c));
c++;
}
c = 1;
while (obj.HasProperty(Property_SendMessage + c))
{
string messageToSend = obj.GetPropertyAsString(Property_SendMessage + c);
string[] menssage = messageToSend.Split('|');
if (menssage.Length == 2)
{
gameObject.BroadcastMessage(menssage[0], menssage[1]);
}
if (menssage.Length == 1)
{
gameObject.BroadcastMessage(menssage[0]);
}
c++;
}
if (gameObject.GetComponent<Renderer>() != null)
{
if (obj.HasProperty(Property_SortingLayerName))
gameObject.GetComponent<Renderer>().sortingLayerName = obj.GetPropertyAsString(Property_SortingLayerName);
if (obj.HasProperty(Property_SortingOrder))
gameObject.GetComponent<Renderer>().sortingOrder = obj.GetPropertyAsInt(Property_SortingOrder);
if (obj.HasProperty(Property_SetMaterialColor))
{
string[] splitColor = obj.GetPropertyAsString(Property_SetMaterialColor).Split(',');
if (splitColor.Length >= 1)
{
gameObject.GetComponent<Renderer>().material = new Material(BaseTileMaterial);
gameObject.GetComponent<Renderer>().material.color = new Color32(
((byte)(int.Parse(string.IsNullOrEmpty(splitColor[0]) ? "255" : splitColor[0]))),
splitColor.Length >= 2 ? ((byte)(int.Parse(splitColor[1]))) : (byte)255,
splitColor.Length >= 3 ? ((byte)(int.Parse(splitColor[2]))) : (byte)255,
splitColor.Length >= 4 ? ((byte)(int.Parse(splitColor[3]))) : (byte)255);
}
}
}
}