예제 #1
0
 // Update is called once per frame
 void Update()
 {
     if (m_nScriptInsPtr != 0)
     {
         FCLibHelper.fc_call(m_VMPtr, m_nScriptInsPtr, "Update");
     }
 }
    void  TestScriptFunc1()
    {
        try
        {
            int nV2 = FCLibHelper.fc_get_version();
            print_error("fc_get_version() is " + nV2);
            bool bDebugMode = FCLibHelper.fc_is_debug_mode();
            print_error("fc_is_debug_mode() is " + bDebugMode);
        }
        catch (Exception e)
        {
            print_error(e.ToString());
        }

        try
        {
            Vector3 v = new Vector3(1, 2, 3);
            FCDll.PushCallParam(v);
            FCLibHelper.fc_call(0, "csharp2fc_set_vector3");

            Vector4 v2 = new Vector4(22, 33, 44, 55);
            FCDll.PushCallParam(v2);
            FCLibHelper.fc_call(0, "csharp2fc_set_vector4");

            string szTest = "测试字符串传参";
            FCDll.PushCallParam(szTest);
            FCLibHelper.fc_call(0, "csharp2fc_set_string");
        }
        catch (Exception e)
        {
            print_error(e.ToString());
        }
    }
    void CreateScript()
    {
        if (0 != m_nScriptInsPtr)
        {
            return;
        }
        // 创建一个脚本
        if (string.IsNullOrEmpty(ScripClassName))
        {
            m_nScriptInsPtr = 0;
        }
        else
        {
            m_nScriptInsPtr = FCLibHelper.fc_instance(ScripClassName);
        }

        // 必要的话,调用下脚本中的Start函数
        if (m_nScriptInsPtr != 0)
        {
            // 假设存在transform变量
            SetScriptValue("transform", transform);

            FCLibHelper.fc_call(m_nScriptInsPtr, "Start");
        }

        OnCreateScript();
    }
예제 #4
0
 void OnDestroy()
 {
     if (m_nScriptInsPtr != 0)
     {
         FCLibHelper.fc_call(m_nScriptInsPtr, "OnDestroy"); // 实际上,脚本一般是不需要OnDestroy事件的,只需要释放脚本就可以了
         FCLibHelper.fc_relese_ins(m_nScriptInsPtr);        // 释放脚本对象,如果脚本对象有析构函数,就会自动调用析构函数
         m_nScriptInsPtr = 0;
     }
 }
예제 #5
0
    public void OnButtonClicked(string szName)
    {
        CreateScript(); // 延迟执行吧

        if (m_nScriptInsPtr != 0)
        {
            FCDll.PushCallParam(szName);  // 传点击的按钮的参数
            FCLibHelper.fc_call(m_nScriptInsPtr, "OnButtonClicked");
        }
    }
예제 #6
0
    protected override void OnAfterLoadScriptData()
    {
        // 在加载完脚本字码码后,才执行脚本函数吧
        Transform tfChild = transform.Find("Text");

        UnityEngine.UI.Text text = tfChild.GetComponent <UnityEngine.UI.Text>();
        FCDll.PushCallParam(text);
        //FCDll.PushCallObjectParam(text);
        FCLibHelper.fc_call(0, "HelloWord.SetText");
    }
예제 #7
0
 public void  CallFunc()
 {
     try
     {
         FCLibHelper.fc_call(m_nThisPtr, m_szFuncName);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
 }
예제 #8
0
 void FCSaveJson()
 {
     string szJson = m_ItemCfg.text;
     long nBeginTime = DateTime.Now.Ticks / 10000;
     int nTotalCount = 100;
     FCLibHelper.fc_push_string_a(szJson);
     FCLibHelper.fc_call(0, "JsonLoader.TestWrite");
     long nEndTime = DateTime.Now.Ticks / 10000;
     long nCostTime = nEndTime - nBeginTime;
     string szTips = string.Format("FC Save Json 花费总时间={0}毫秒,平均时间={1}毫秒,总调用次数={2}", nCostTime, nCostTime / nTotalCount, nTotalCount);
     print_error(szTips);
 }
예제 #9
0
 public void  CallFunc()
 {
     try
     {
         long VM = m_VMPtr;
         FCLibHelper.fc_call(VM, m_nThisPtr, m_szFuncName);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
 }
    void TestObjectScript()
    {
        InitDll();
        if (m_nTestPtr == 0)
        {
            m_nTestPtr = FCLibHelper.fc_instance("CTestD");
        }
        string szLog = string.Format("脚本实例IntPtr = {0}", m_nTestPtr);

        print_error(szLog);
        FCLibHelper.fc_call(m_nTestPtr, "Start");
    }
예제 #11
0
 void OnDestroy()
 {
     if (m_nScriptInsPtr != 0)
     {
         if (FCLibHelper.fc_is_init())                          // 如果脚本系统已经释放了,就不能调用脚本的函数了
         {
             FCLibHelper.fc_call(m_nScriptInsPtr, "OnDestroy"); // 实际上,脚本一般是不需要OnDestroy事件的,只需要释放脚本就可以了
             FCLibHelper.fc_relese_ins(m_nScriptInsPtr);        // 释放脚本对象,如果脚本对象有析构函数,就会自动调用析构函数
         }
         m_nScriptInsPtr = 0;
     }
 }
예제 #12
0
 public void  CallFunc(int arg0)
 {
     try
     {
         FCDll.PushCallParam(arg0);
         FCLibHelper.fc_call(m_nThisPtr, m_szFuncName);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
 }
예제 #13
0
    void TestFunc10()
    {
        GameObject obj = GameObject.Find("Empty");

        if (obj == null)
        {
            obj = new GameObject("Empty");
        }
        long nPtr = FCGetObj.PushObj(obj.transform);

        FCLibHelper.fc_push_intptr(nPtr);
        FCLibHelper.fc_call(0, "Test10");
    }
예제 #14
0
    void TestFunc4()
    {
        GameObject obj = GameObject.Find("Empty");

        if (obj == null)
        {
            obj = new GameObject("Empty");
        }
        //FCLibHelper.fc_prepare_call(0, "Test0"); // 要传Object参数,需要初始化参数列表
        long nPtr = FCGetObj.PushObj(obj.transform);

        FCLibHelper.fc_push_intptr(nPtr);
        FCLibHelper.fc_call(0, "Test4");
    }
예제 #15
0
 public void  CallFunc(int arg0, string arg1, Vector2 arg2)
 {
     try
     {
         FCDll.PushCallParam(arg0);
         FCDll.PushCallParam(arg1);
         FCDll.PushCallParam(ref arg2);
         FCLibHelper.fc_call(m_nThisPtr, m_szFuncName);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
 }
예제 #16
0
    void TestFunc11()
    {
        // 测试空函数调用
        long nBeginTime = DateTime.Now.Ticks / 10000;

        for (int i = 0; i < 200000; ++i)
        {
            FCLibHelper.fc_call(0, "EmptyFunc");
        }
        long   nEndTime    = DateTime.Now.Ticks / 10000;
        long   nCostTime   = nEndTime - nBeginTime;
        int    nTotalCount = 200000;
        string szTips      = string.Format("Test11 花费总时间={0}秒,平均时间={1}毫秒,总调用次数={2}", nCostTime / 1000, nCostTime / nTotalCount, nTotalCount);

        print_error(szTips);
        FCLibHelper.fc_call(0, "PrintV0");
    }
예제 #17
0
    void FCSaveXml()
    {
        string szFileData = m_XmlData.text;

        int  nTotalCount = 1;
        long nBeginTime  = DateTime.Now.Ticks / 10000;

        for (int i = 0; i < nTotalCount; ++i)
        {
            FCLibHelper.fc_push_string_a(szFileData);
            FCLibHelper.fc_call(0, "XmlLoader.TestWrite");
        }
        long   nEndTime  = DateTime.Now.Ticks / 10000;
        long   nCostTime = nEndTime - nBeginTime;
        string szTips    = string.Format("FC Save Xml 花费总时间={0}毫秒,平均时间={1}毫秒,总调用次数={2}", nCostTime, nCostTime / nTotalCount, nTotalCount);

        print_error(szTips);
    }
예제 #18
0
    void FCLoadMapData()
    {
        string szJson = MakeTestMapData();

        int  nTotalCount = 10;
        long nBeginTime  = DateTime.Now.Ticks / 10000;

        for (int i = 0; i < nTotalCount; ++i)
        {
            FCLibHelper.fc_push_string_a(szJson);
            FCLibHelper.fc_call(0, "JsonLoaderMapData.TestLoad");
        }
        long   nEndTime  = DateTime.Now.Ticks / 10000;
        long   nCostTime = nEndTime - nBeginTime;
        string szTips    = string.Format("FC Load Json 花费总时间={0}毫秒,平均时间={1}毫秒,总调用次数={2}", nCostTime, nCostTime / nTotalCount, nTotalCount);

        print_error(szTips);
    }
예제 #19
0
    void CreateScript()
    {
        if (0 != m_nScriptInsPtr)
        {
            return;
        }
        // 创建一个脚本
        if (string.IsNullOrEmpty(ScripClassName))
        {
            m_nScriptInsPtr = 0;
        }
        else
        {
            m_nScriptInsPtr = FCLibHelper.fc_instance(ScripClassName);
        }

        // 必要的话,调用下脚本中的Start函数
        if (m_nScriptInsPtr != 0)
        {
            FCLibHelper.fc_call(m_nScriptInsPtr, "Start");
        }
    }
예제 #20
0
    void CreateScript()
    {
        if (0 != m_nScriptInsPtr)
        {
            return;
        }
        m_VMPtr = FCDll.GetMainVMPtr();
        // 创建一个脚本
        if (string.IsNullOrEmpty(ScripClassName))
        {
            m_nScriptInsPtr = 0;
        }
        else
        {
            m_nScriptInsPtr = FCLibHelper.fc_instance(m_VMPtr, ScripClassName);
        }

        // 必要的话,调用下脚本中的Start函数
        if (m_nScriptInsPtr != 0)
        {
            // 假设存在transform变量
            SetScriptValue("transform", transform);
        }
        try
        {
            OnCreateScript();
        }
        catch (Exception e)
        {
            Debug.LogException(e);
        }
        if (m_nScriptInsPtr != 0)
        {
            FCLibHelper.fc_call(m_VMPtr, m_nScriptInsPtr, "Start");
        }
    }
예제 #21
0
 void TestFunc9()
 {
     FCLibHelper.fc_call(0, "Test9");
 }
예제 #22
0
 void TestFunc7()
 {
     FCLibHelper.fc_call(0, "Test7");
 }
예제 #23
0
 void TestFunc8()
 {
     FCLibHelper.fc_call(0, "Test8");
 }
예제 #24
0
 void TestFunc5()
 {
     FCLibHelper.fc_call(0, "Test5");
 }
예제 #25
0
 void TestFunc6()
 {
     FCLibHelper.fc_call(0, "Test6");
 }
 void LoadScript()
 {
     InitDll();
     FCLibHelper.fc_call(0, "main");
 }
예제 #27
0
 void TestFunc3()
 {
     FCLibHelper.fc_call(0, "Test3");
 }
예제 #28
0
 void TestFunc2()
 {
     FCLibHelper.fc_call(0, "Test2");
 }
예제 #29
0
 void TestFunc14()
 {
     FCLibHelper.fc_call(0, "Test14");
 }
 void InvalidObjectScriptCall()
 {
     InitDll();
     FCLibHelper.fc_call(m_nTestPtr, "Start");
 }