Пример #1
0
    void TestActioCallback()
    {
        APIExportTest obj = new APIExportTest();

        //Delegate Test
        APIExportTest.OnStaticDelegateFinish = () =>
        {
            Debug.LogError("PerTest OnStaticUpdate");
        };
        APIExportTest.OnStaticDelegateFinish();

        obj.OnDelegateFinish += OnPerTestDelegateFinish;
        obj.OnDelegateFinish();
        obj.OnDelegateFinish -= OnPerTestDelegateFinish;
        if (obj.OnDelegateFinish == null)
        {
            Debug.LogError("====Remove OnPerTestDelegateFinish====");
        }

        System.Action delegateAction = () =>
        {
            Debug.LogError("PerTest AddDelegate");
        };
        obj.AddDelegate(delegateAction);
        obj.OnDelegateFinish();
        obj.RemoveDelegate(delegateAction);
        if (obj.OnDelegateFinish == null)
        {
            Debug.LogError("====Remove AddDelegate====");
        }

        //Static Event Test
        APIExportTest.OnStaticEventFinish += OnPerTestStaticEventFinish;
        APIExportTest.SendStaticEvent();
        Debug.LogError("====Remove OnPerTestStaticEventFinish====");
        APIExportTest.OnStaticEventFinish -= OnPerTestStaticEventFinish;
        APIExportTest.SendStaticEvent();

        //Instance Event Test
        Debug.LogError("====Test AddEvent====");
        System.Action <MonoBehaviour> eventAction = (mono) =>
        {
            Debug.LogError("PerTest AddEvent");
        };
        obj.AddEvent(eventAction);
        obj.SendEvent();
        Debug.LogError("====Remove AddEvent====");
        obj.RemoveEvent(eventAction);
        obj.SendEvent();

        Debug.LogError("====Test OnPerTestEventFinish====");
        obj.OnEventFinish += OnPerTestEventFinish;
        obj.SendEvent();
        Debug.LogError("====Remove OnPerTestEventFinish====");
        obj.OnEventFinish -= OnPerTestEventFinish;
        obj.SendEvent();
    }
    static bool APIExportTest_testReturnList(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 0)
        {
            JSMgr.datax.setObject((int)JSApi.SetType.Rval, APIExportTest.testReturnList());
        }

        return(true);
    }
    static bool APIExportTest_SendStaticEvent(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 0)
        {
            APIExportTest.SendStaticEvent();
        }

        return(true);
    }
// fields
    static void APIExportTest_IDs(JSVCall vc)
    {
        if (vc.bGet)
        {
            APIExportTest _this  = (APIExportTest)vc.csObj;
            var           result = _this.IDs;
            JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
        }
        else
        {
            List <System.Int32> arg0  = (List <System.Int32>)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            APIExportTest       _this = (APIExportTest)vc.csObj;
            _this.IDs = arg0;
        }
    }
 static void APIExportTest_ID(JSVCall vc)
 {
     if (vc.bGet)
     {
         APIExportTest _this  = (APIExportTest)vc.csObj;
         var           result = _this.ID;
         JSApi.setInt32((int)JSApi.SetType.Rval, (System.Int32)(result));
     }
     else
     {
         System.Int32  arg0  = (System.Int32)JSApi.getInt32((int)JSApi.GetType.Arg);
         APIExportTest _this = (APIExportTest)vc.csObj;
         _this.ID = arg0;
     }
 }
 static void APIExportTest_toggle(JSVCall vc)
 {
     if (vc.bGet)
     {
         APIExportTest _this  = (APIExportTest)vc.csObj;
         var           result = _this.toggle;
         JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
     }
     else
     {
         System.Boolean arg0  = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
         APIExportTest  _this = (APIExportTest)vc.csObj;
         _this.toggle = arg0;
     }
 }
Пример #7
0
    // Use this for initialization
    void Start()
    {
//        PerTest.test123(1.5, 1.3);
        //PerTest.testString(null, "abc");
        var logo = Resources.Load("Textures/logo");

        Debug.LogError("Resources.Load: " + logo);

        logo = Resources.Load <Texture2D>("Textures/logo");
        Debug.LogError("Resources.Load<T>: " + logo);

        List <string> contents = new List <string>();

        contents.Add("hello");
        contents.Add("fxck");
        contents.Add("foo");
        Debug.LogError(contents.Random());

        Debug.LogError("ForEach contents");
        foreach (string content in contents)
        {
            Debug.LogError(content);
        }
        Debug.LogError("For contents");
        for (int i = 0; i < contents.Count; i++)
        {
            Debug.LogError(contents[i]);
        }

        var obj = new APIExportTest();

        obj.IDs.Add(123);
        obj.IDs.Add(456);
        Debug.LogError("For IDs");
        for (int i = 0; i < obj.IDs.Count; i++)
        {
            Debug.LogError(obj.IDs[i]);
        }
        Debug.LogError("ForEach IDs");
        foreach (int i in obj.IDs)
        {
            Debug.LogError(i);
        }
        //PrintStrings("a", "b", "c");
        //print(null);
    }
    static bool APIExportTest_testReturnArray(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 0)
        {
            var arrRet = APIExportTest.testReturnArray();
            for (int i = 0; arrRet != null && i < arrRet.Length; i++)
            {
                JSMgr.datax.setObject((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]);
                JSApi.moveSaveID2Arr(i);
            }
            JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true);
        }

        return(true);
    }
    static bool APIExportTest_testRefParams__String__String(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 2)
        {
            int           r_arg0 = JSApi.getArgIndex();
            System.String arg0   = (System.String)JSApi.getStringS((int)JSApi.GetType.ArgRef);
            int           r_arg1 = JSApi.incArgIndex();
            System.String arg1;
            APIExportTest.testRefParams(ref arg0, out arg1);
            JSApi.setArgIndex(r_arg0);
            JSApi.setStringS((int)JSApi.SetType.ArgRef, arg0);
            JSApi.setArgIndex(r_arg1);
            JSApi.setStringS((int)JSApi.SetType.ArgRef, arg1);
        }

        return(true);
    }
Пример #10
0
    static bool APIExportTest_testString__String_Array(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 1)
        {
            System.String[] arg0 = JSDataExchangeMgr.GetJSArg <System.String[]>(() =>
            {
                int jsObjID = JSApi.getObject((int)JSApi.GetType.Arg);
                int length  = JSApi.getArrayLength(jsObjID);
                var ret     = new System.String[length];
                for (var i = 0; i < length; i++)
                {
                    JSApi.getElement(jsObjID, i);
                    ret[i] = (System.String)JSApi.getStringS((int)JSApi.GetType.SaveAndRemove);
                }
                return(ret);
            });
            APIExportTest.testString(arg0);
        }

        return(true);
    }
Пример #11
0
 static void APIExportTest_OnDelegateFinish(JSVCall vc)
 {
     if (vc.bGet)
     {
         APIExportTest _this  = (APIExportTest)vc.csObj;
         var           result = _this.OnDelegateFinish;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         APIExportTest _this = (APIExportTest)vc.csObj;
         _this.OnDelegateFinish = JSDataExchangeMgr.GetJSArg <System.Action>(() =>
         {
             if (JSApi.isFunctionS((int)JSApi.GetType.Arg))
             {
                 return(APIExportTest_OnDelegateFinish_GetDelegate_member1_arg0(JSApi.getFunctionS((int)JSApi.GetType.Arg)));
             }
             else
             {
                 return((System.Action)JSMgr.datax.getObject((int)JSApi.GetType.Arg));
             }
         });
     }
 }