Files
UltimateFishing/Assets/Scripts/Assembly-CSharp/BitStrap/Examples/ReflectionHelperExample.cs
2026-02-21 16:45:37 +08:00

40 lines
1007 B
C#

using UnityEngine;
namespace BitStrap.Examples
{
public class ReflectionHelperExample : MonoBehaviour
{
[Header("Edit the fields and click the buttons to test them!")]
public int intValue1 = 1;
public int intValue2 = 2;
public int intValue3 = 3;
public string stringValue1 = "string1";
public string stringValue2 = "string2";
[Button]
public void ListAllIntegerFields()
{
int[] fieldValuesOfType = ReflectionHelper.GetFieldValuesOfType<int>(this);
Debug.LogFormat("All Integer values: {0}", fieldValuesOfType.ToStringFull());
}
[Button]
public void ListAllStringFields()
{
string[] fieldValuesOfType = ReflectionHelper.GetFieldValuesOfType<string>(this);
Debug.LogFormat("All String values: {0}", fieldValuesOfType.ToStringFull());
}
[Button]
public void ListAllBooleanFields()
{
bool[] fieldValuesOfType = ReflectionHelper.GetFieldValuesOfType<bool>(this);
Debug.LogFormat("All Boolean values: {0}", fieldValuesOfType.ToStringFull());
}
}
}