コード例 #1
0
    public void GetRpcs()
    {
        MonoBehaviour[] sceneActive = GameObject.FindObjectsOfType <MonoBehaviour>();

        foreach (MonoBehaviour mono in sceneActive)
        {
            Type         monoType     = mono.GetType();
            MethodInfo[] objectFields = monoType.GetMethods();

            for (int i = 0; i < objectFields.Length; i++)
            {
                RpcAttribute attribute = Attribute.GetCustomAttribute(objectFields[i], typeof(RpcAttribute)) as RpcAttribute;
                if (attribute != null)
                {
                    if (objectFields[i].Name == "ObjectMovement")
                    {
                        string uid = mono.GetComponent(mono.GetType()).GetType().GetField("uniqueId").GetValue(mono.GetComponent(mono.GetType())).ToString();
                        movements.Add(new Movements {
                            uid = uid, classInstance = mono.GetComponent(mono.GetType()), MI = objectFields[i]
                        });
                    }
                    else
                    {
                        Rpcs rtofind = rpclist.Find(x => x.classInstance == (object)mono.GetComponent(mono.GetType()) && x.MI == objectFields[i]);
                        if (rtofind == null)
                        {
                            rpclist.Add(new Rpcs {
                                cmd = objectFields[i].Name, classInstance = mono.GetComponent(mono.GetType()), MI = objectFields[i]
                            });
                        }
                    }
                }
            }
        }
    }
コード例 #2
0
ファイル: RpcAttributeTest.cs プロジェクト: qipa/rpc-1
 public RpcAttributeTest()
 {
     sut = new RpcAttribute("Test");
 }