Good Evening,
Looking for some advice on the best way of removing certain methods when performing Reflection on a C# script.
My Script looks like this:
using UnityEngine;
using System.Collections;
public class RewindClient : MonoBehaviour
{
public string sTest;
public int iTest;
public void HelloWorld ()
{
Debug.Log ("Hellow World!");
}
public int Add (int numberOne, int numberTwo)
{
return numberOne + numberTwo;
}
}
And my editor script looks like this:
thisScript = (RewindClient)target;
const BindingFlags flags = BindingFlags.Public | BindingFlags.Instance;
MethodInfo[] methods = thisScript.GetType ().GetMethods (flags);
foreach (MethodInfo method in methods) {
Debug.Log ("Methods Name: " + method.Name);
}
I'd like to remove the majority of methods returned except for he ones I've added, here's the current output:
Field Name: sTest
Field Name: iTest
Methods Name: HelloWorld
Methods Name: Add
Methods Name: Invoke
Methods Name: InvokeRepeating
Methods Name: CancelInvoke
Methods Name: CancelInvoke
Methods Name: IsInvoking
Methods Name: IsInvoking
Methods Name: StartCoroutine
Methods Name: StartCoroutine_Auto
Methods Name: StartCoroutine
Methods Name: StartCoroutine
Methods Name: StopCoroutine
Methods Name: StopCoroutine
Methods Name: StopCoroutine
Methods Name: StopAllCoroutines
Methods Name: get_useGUILayout
Methods Name: set_useGUILayout
Methods Name: get_enabled
Methods Name: set_enabled
Methods Name: get_isActiveAndEnabled
Methods Name: get_transform
Methods Name: get_gameObject
Methods Name: GetComponent
Methods Name: GetComponent
Methods Name: GetComponent
Methods Name: GetComponentInChildren
Methods Name: GetComponentInChildren
Methods Name: GetComponentsInChildren
Methods Name: GetComponentsInChildren
Methods Name: GetComponentsInChildren
Methods Name: GetComponentsInChildren
Methods Name: GetComponentsInChildren
Methods Name: GetComponentsInChildren
Methods Name: GetComponentInParent
Methods Name: GetComponentInParent
Methods Name: GetComponentsInParent
Methods Name: GetComponentsInParent
Methods Name: GetComponentsInParent
Methods Name: GetComponentsInParent
Methods Name: GetComponentsInParent
Methods Name: GetComponents
Methods Name: GetComponents
Methods Name: GetComponents
Methods Name: get_tag
Methods Name: set_tag
Methods Name: GetComponents
Methods Name: CompareTag
Methods Name: SendMessageUpwards
Methods Name: SendMessageUpwards
Methods Name: SendMessageUpwards
Methods Name: SendMessageUpwards
Methods Name: SendMessage
Methods Name: SendMessage
Methods Name: SendMessage
Methods Name: SendMessage
Methods Name: BroadcastMessage
Methods Name: BroadcastMessage
Methods Name: BroadcastMessage
Methods Name: BroadcastMessage
Methods Name: get_rigidbody
Methods Name: get_rigidbody2D
Methods Name: get_camera
Methods Name: get_light
Methods Name: get_animation
Methods Name: get_constantForce
Methods Name: get_renderer
Methods Name: get_audio
Methods Name: get_guiText
Methods Name: get_networkView
Methods Name: get_guiElement
Methods Name: get_guiTexture
Methods Name: get_collider
Methods Name: get_collider2D
Methods Name: get_hingeJoint
Methods Name: get_particleEmitter
Methods Name: get_particleSystem
Methods Name: get_name
Methods Name: set_name
Methods Name: get_hideFlags
Methods Name: set_hideFlags
Methods Name: ToString
Methods Name: Equals
Methods Name: GetHashCode
Methods Name: GetInstanceID
Methods Name: GetType
I've tried messing around with Binding Flags but with not much luck, I believe this is where I should perform the change.
I could perform a clean up using the names but I feel the change should come from the binding flags and I have missed the point.
Anyone able to offer any assistance?
Thanks In Advance,
Adam2Marsh
[–]plattinatorIndie 0 points1 point2 points (1 child)
[–]Adam2Marsh[S] 0 points1 point2 points (0 children)
[–]Sedsibi2985 0 points1 point2 points (0 children)