Пример #1
0
 public void SetImage(string path, Texture texture, OnCallBack callBack = null)
 {
     gameObject.name = path;
     isSetImage      = true;
     gameObject.SetActiveVirtual(false);
     SetNoHideImage(path, texture, callBack);
 }
Пример #2
0
 public void PromptPopup(OnCallBack callBack)
 {
     this.callBack = callBack;
     FindObjectOfType <InputTouch>().BLOCK_INPUT = true;
     popupCanvasGroup.gameObject.SetActive(true);
     UpdateUI();
 }
Пример #3
0
 public void OnDispose()
 {
     luaUpdate      = null;
     luaLateUpdate  = null;
     luaFixedUpdate = null;
     luaSlowUpdate  = null;
 }
Пример #4
0
    public void Initialize(OnCallBackIndex callBackIdx, OnCallBack conCallBack = null)
    {
        for (int i = 0; i < TabList.Count; i++)
        {
            //스크립트가 추가가 되어 있지 아니하다면 추가하려고 검사한다.
            UITabbase tabBase = TabList[i].GetComponent <UITabbase>();
            if (tabBase == null)
            {
                tabBase = TabList[i].AddComponent <UITabbase>();
                tabBase.Init();
            }
            //누구한테 클릭되면 신호를 보내야 할지 정해준다.
            tabBase.TabGroup = this;

            UIButton uiBtn = TabList[i].GetComponent <UIButton>();
            if (uiBtn != null)
            {
                uiBtn.duration = 0;
            }
            //uiBtn.tweenTarget = null;
        }

        ConCallback = conCallBack;
        CallBackIdx = callBackIdx;
        if (DefaultInitIndex < 0)
        {
            return;
        }

        OnClickChildBtn(TabList[DefaultInitIndex]);
    }
 /// <summary>
 /// Sets the timer.
 /// </summary>
 /// <param name='observer'>
 /// The TimerObserverOrSubject you need to listen
 /// </param>
 /// <param name='callback'>
 /// The callback when time is up.
 /// </param>
 /// <param name='arg'>
 /// Argument of the callback.
 /// </param>
 /// <param name='timepass'>
 /// Timepass before calling the callback.
 /// </param>
 public void SetTimer(TimerObserverOrSubject observer, OnCallBack callback, object arg, float timepass)
 {
     if (observer != null && callback != null)
     {
         Timer timer = new Timer(observer, callback, arg, timepass);
         m_Timers.Add(timer);
     }
 }
Пример #6
0
 public void Restart(LuaEnv luaEnv)
 {
     luaUpdate      = luaEnv.Global.Get <OnCallBackFF>("Update");
     luaSlowUpdate  = luaEnv.Global.Get <OnCallBack>("SlowUpdate");
     luaLateUpdate  = luaEnv.Global.Get <OnCallBack>("LateUpdate");
     luaFixedUpdate = luaEnv.Global.Get <OnCallBackFloat>("FixedUpdate");
     slowUpdateFPS  = luaEnv.Global.Get <int>("SlowUpdateFPS");
     slowUpdateRate = 1F / slowUpdateFPS;
 }
Пример #7
0
 public void SetImageNoHide(string path, OnCallBack callBack = null)
 {
     onCallBack  = callBack;
     currentPath = path;
     if (m_Atlas == null)
     {
         SetGroup(mGroup);
     }
     m_Atlas.GetImage(path, OnGetImageCallBack);
 }
Пример #8
0
 public void PromptPopup(TipType tipType, string description, OnCallBack callBack)
 {
     this.tipType     = tipType;
     this.description = description;
     this.callBack    = callBack;
     FindObjectOfType <InputTouch>().BLOCK_INPUT = true;
     popupCanvasGroup.gameObject.SetActive(true);
     AddButtonListeners();
     UpdateUI();
 }
Пример #9
0
 public void SetNoHideImage(string path, Texture texture, OnCallBack callBack = null)
 {
     currentPath = path;
     if (AtlasConfig.kUsingCopyTexture)
     {
         m_Atlas.SetTexture(currentPath, texture, OnGetImageCallBack);
     }
     else
     {
         m_Atlas.SetTexture(currentPath, texture, OnGetMaterialCallBack);
     }
 }
Пример #10
0
 public void SetImage(string path, OnCallBack callBack = null)
 {
     isSetImage = true;
     gameObject.SetActiveVirtual(false);
     onCallBack  = callBack;
     currentPath = path;
     if (m_Atlas == null)
     {
         SetGroup(mGroup);
     }
     m_Atlas.GetImage(path, OnGetImageCallBack);
 }
Пример #11
0
    /// <summary>
    /// 添加绑定回调
    /// </summary>
    /// <param name="t"></param>
    public void AppendCalls(OnCallBack t)
    {
        if (t == null)
        {
            return;
        }

        if (!mCalls.Contains(t))
        {
            mCalls.Add(t);
        }
    }
        public Timer(TimerObserverOrSubject observer, OnCallBack callback, object arg, float time)
        {
            m_Observer = observer;
            m_Callback = callback;
            m_Arg      = arg;

            m_Subject           = null;
            m_IsCanDoFunc       = null;
            m_ArgForIsCanDoFunc = null;

            m_PassTime = time;
        }
        public Timer(TimerObserverOrSubject observer, OnCallBack callback, object arg,
                     TimerObserverOrSubject subject, OnIsCanDo isCanDoFunc, object argForIsCanDo)
        {
            m_Observer = observer;
            m_Callback = callback;
            m_Arg      = arg;

            m_Subject           = subject;
            m_IsCanDoFunc       = isCanDoFunc;
            m_ArgForIsCanDoFunc = argForIsCanDo;

            m_PassTime = 0;
        }
Пример #14
0
        public Task <int> AsyncRun_Sql_Return_Int(IEnumerable <SqlCommand> cmdList, OnCallBack <int> onCallBack)
        {
            string     err  = null;
            Task <int> task = Task.Factory.StartNew <int>(() =>
            {
                return(Run_Sql_Return_Int(cmdList, out err));
            });

            task.ContinueWith((t) =>
            {
                if (onCallBack != null)
                {
                    onCallBack(t.Result, err);
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
            return(task);
        }
Пример #15
0
        public Task <DataSet> AsyncSelect_Sql_Return_DataSet(SqlCommand cmd, OnCallBack <DataSet> onCallBack)
        {
            string         err  = null;
            Task <DataSet> task = Task.Factory.StartNew <DataSet>(() =>
            {
                return(Select_Sql_Return_DataSet(cmd, out err));
            });

            task.ContinueWith((t) =>
            {
                if (onCallBack != null)
                {
                    onCallBack(t.Result, err);
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
            return(task);
        }
Пример #16
0
        public Task <bool> AsyncSqlBulkCopy(DataTable dt, int batchSize, OnCallBack <bool> onCallBack)
        {
            string      err  = null;
            Task <bool> task = Task.Factory.StartNew <bool>(() =>
            {
                return(SqlBulkCopy(dt, batchSize, out err));
            });

            task.ContinueWith((t) =>
            {
                if (onCallBack != null)
                {
                    onCallBack(t.Result, err);
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
            return(task);
        }
Пример #17
0
 public void SetImageNoHide(string path, OnCallBack callBack = null)
 {
     onCallBack  = callBack;
     currentPath = path;
     if (m_Atlas == null)
     {
         SetGroup(mGroup);
     }
     if (AtlasConfig.kUsingCopyTexture)
     {
         m_Atlas.GetImage(path, OnGetImageCallBack);
     }
     else
     {
         m_Atlas.GetImage(path, OnGetMaterialCallBack);
     }
 }
    /// <summary>
    /// Sets the timer.
    /// </summary>
    /// <param name='observer'>
    /// The TimerObserverOrSubject you need to listen
    /// </param>
    /// <param name='callback'>
    /// The callback when condition is true.
    /// </param>
    /// <param name='arg'>
    /// Argument of the callback.
    /// </param>
    /// <param name='observer'>
    /// The TimerObserverOrSubject you need to observe
    /// </param>
    /// <param name='isCanDoFunc'>
    /// The condition function, must return a boolean.
    /// </param>
    /// <param name='argForIsCanDo'>
    /// Argument for condition function.
    /// </param>
    public void SetTimer(TimerObserverOrSubject observer, OnCallBack callback, object arg,
                         TimerObserverOrSubject subject, OnIsCanDo isCanDoFunc, object argForIsCanDo)
    {
        if (observer == null || subject == null || callback == null || isCanDoFunc == null)
        {
            return;
        }

        if (isCanDoFunc(argForIsCanDo))
        {
            callback(arg);
            return;
        }

        Timer timer = new Timer(observer, callback, arg, subject, isCanDoFunc, argForIsCanDo);

        m_Timers.Add(timer);
    }
Пример #19
0
        void ProcessReceive(SocketAsyncEventArgs e)
        {
            ReceiveEventArgs eventArgs = (ReceiveEventArgs)e;
            UserTokenSession UserToken = (UserTokenSession)eventArgs.UserToken;

            if (eventArgs.SocketError == SocketError.Success && eventArgs.BytesTransferred > 0)
            {
                //解码回调
                eventArgs.Decode((bytes) => OnCallBack?.Invoke(UserToken, bytes));

                //继续接收消息
                if (UserToken.Channel != null &&
                    !UserToken.Channel.ReceiveAsync(e))
                {
                    //此次接收没有接收完毕 递归接收
                    ProcessReceive(e);
                }
            }
        }
Пример #20
0
    /// <summary>
    /// 去除指定的绑定回调
    /// </summary>
    /// <param name="t"></param>
    public void RemoveCalls(OnCallBack t)
    {
        if (t == null)
        {
            return;
        }

        if (mCalls.Contains(t))
        {
            if (bExecute)
            {
                removeCalls.Add(t);
            }
            else
            {
                mCalls.Remove(t);
            }
        }
    }
Пример #21
0
 public Task <List <T> > AsyncSelect_Sql_Return_List <T>(string cmdText, object param, OnCallBack <List <T> > onCallBack)
 {
     return(AsyncSelect_Sql_Return_List <T>(new SqlCommand(cmdText, param), onCallBack));
 }
        internal static object ExecuteJavaScript_SimulatorImplementation(string javascript, bool runAsynchronously, bool noImpactOnPendingJSCode = false, params object[] variables)
        {
#if !BUILDINGDOCUMENTATION
            //---------------
            // Due to the fact that it is not possible to pass JavaScript objects between the simulator JavaScript context
            // and the C# context, we store the JavaScript objects in a global dictionary inside the JavaScript context.
            // This dictionary is named "jsSimulatorObjectReferences". It associates a unique integer ID to each JavaScript
            // object. In C# we only manipulate those IDs by manipulating instances of the "JSObjectReference" class.
            // When we need to re-use those JavaScript objects, the C# code passes to the JavaScript context the ID
            // of the object, so that the JavaScript code can retrieve the JavaScript object instance by using the
            // aforementioned dictionary.
            //---------------

            // Verify the arguments:
            if (noImpactOnPendingJSCode && runAsynchronously)
            {
                throw new ArgumentException("You cannot set both 'noImpactOnPendingJSCode' and 'runAsynchronously' to True. The 'noImpactOnPendingJSCode' only has meaning when running synchronously.");
            }

            // Make sure the JS to C# interop is set up:
            if (!IsJavaScriptCSharpInteropSetUp)
            {
#if CSHTML5BLAZOR
                if (Interop.IsRunningInTheSimulator_WorkAround)
                {
#endif
                // Adding a property to the JavaScript "window" object:
                JSObject jsWindow = (JSObject)INTERNAL_HtmlDomManager.ExecuteJavaScriptWithResult("window");
                jsWindow.SetProperty("onCallBack", new OnCallBack(CallbacksDictionary));
#if CSHTML5BLAZOR
            }
            else
            {
                OnCallBack.SetCallbacksDictionary(CallbacksDictionary);
            }
#endif
                IsJavaScriptCSharpInteropSetUp = true;
            }

            string unmodifiedJavascript = javascript;

            // If the javascript code has references to previously obtained JavaScript objects, we replace those references with calls to the "document.jsSimulatorObjectReferences" dictionary.
            for (int i = variables.Length - 1; i >= 0; i--) // Note: we iterate in reverse order because, when we replace ""$" + i.ToString()", we need to replace "$10" before replacing "$1", otherwise it thinks that "$10" is "$1" followed by the number "0". To reproduce the issue, call "ExecuteJavaScript" passing 10 arguments and using "$10".
            {
                var variable = variables[i];
                if (variable is INTERNAL_JSObjectReference)
                {
                    //----------------------
                    // JS Object References
                    //----------------------

                    var    jsObjectReference = (INTERNAL_JSObjectReference)variable;
                    string jsCodeForAccessingTheObject;

                    if (jsObjectReference.IsArray)
                    {
                        jsCodeForAccessingTheObject = string.Format(@"document.jsSimulatorObjectReferences[""{0}""][{1}]", jsObjectReference.ReferenceId, jsObjectReference.ArrayIndex);
                    }
                    else
                    {
                        jsCodeForAccessingTheObject = string.Format(@"document.jsSimulatorObjectReferences[""{0}""]", jsObjectReference.ReferenceId);
                    }

                    javascript = javascript.Replace("$" + i.ToString(), jsCodeForAccessingTheObject);
                }
                else if (variable is INTERNAL_HtmlDomElementReference)
                {
                    //------------------------
                    // DOM Element References
                    //------------------------

                    string id = ((INTERNAL_HtmlDomElementReference)variable).UniqueIdentifier;
                    javascript = javascript.Replace("$" + i.ToString(), string.Format(@"document.getElementById(""{0}"")", id));
                }
                else if (variable is INTERNAL_SimulatorJSExpression)
                {
                    //------------------------
                    // JS Expression (simulator only)
                    //------------------------

                    string expression = ((INTERNAL_SimulatorJSExpression)variable).Expression;
                    javascript = javascript.Replace("$" + i.ToString(), expression);
                }
                else if (variable is Delegate)
                {
                    //-----------
                    // Delegates
                    //-----------

                    Delegate callback = (Delegate)variable;

                    // Add the callback to the document:
                    int callbackId = ReferenceIDGenerator.GenerateId();
                    CallbacksDictionary.Add(callbackId, callback);

#if CSHTML5NETSTANDARD
                    //Console.WriteLine("Added ID: " + callbackId.ToString());
#endif

                    // Change the JS code to point to that callback:
                    javascript = javascript.Replace("$" + i.ToString(), string.Format(
                                                        @"(function() {{
                        var argsArray = Array.prototype.slice.call(arguments);
                        var idWhereCallbackArgsAreStored = ""callback_args_"" + Math.floor(Math.random() * 1000000);
                        document.jsSimulatorObjectReferences[idWhereCallbackArgsAreStored] = argsArray;
                        setTimeout(
                            function() 
                            {{
                               window.onCallBack.OnCallbackFromJavaScript({0}, idWhereCallbackArgsAreStored, argsArray);
                            }}
                            , 1);
                      }})", callbackId));

                    // Note: generating the random number in JS rather than C# is important in order to be able to put this code inside a JavaScript "for" statement (cf. deserialization code of the JsonConvert extension, and also ZenDesk ticket #974) so that the "closure" system of JavaScript ensures that the number is the same before and inside the "setTimeout" call, but different for each iteration of the "for" statement in which this piece of code is put.
                    // Note: we store the arguments in the jsSimulatorObjectReferences that is inside the JS context, so that the user can access them from the callback.
                    // Note: "Array.prototype.slice.call" will convert the arguments keyword into an array (cf. http://stackoverflow.com/questions/960866/how-can-i-convert-the-arguments-object-to-an-array-in-javascript )
                    // Note: in the command above, we use "setTimeout" to avoid thread/locks problems.
                }
                else if (variable == null)
                {
                    //--------------------
                    // Null
                    //--------------------

                    javascript = javascript.Replace("$" + i.ToString(), "null");
                }
                else
                {
                    //--------------------
                    // Simple value types or other objects (note: this includes objects that override the "ToString" method, such as the class "Uri")
                    //--------------------

                    javascript = javascript.Replace("$" + i.ToString(), INTERNAL_HtmlDomManager.ConvertToStringToUseInJavaScriptCode(variable));
                }
            }

            UnmodifiedJavascriptCalls.Add(unmodifiedJavascript);
            // Add the callback to the document:
            if (!CallbacksDictionary.ContainsKey(0))
            {
                CallbacksDictionary.Add(0, (Action <string, int>)ShowErrorMessage);
            }

#if CSHTML5NETSTANDARD
            //Console.WriteLine("Added ID: " + callbackId.ToString());
#endif

            // Change the JS code to call ShowErrorMessage in case of error:
            string errorCallBack = string.Format(
                @"var idWhereErrorCallbackArgsAreStored = ""callback_args_"" + Math.floor(Math.random() * 1000000);
                document.jsSimulatorObjectReferences[idWhereErrorCallbackArgsAreStored] = {0};
                var argsArr = [];
                argsArr[0] = error.message;
                argsArr[1] = {0};
window.onCallBack.OnCallbackFromJavaScript(0, idWhereErrorCallbackArgsAreStored, argsArr);", IndexOfNextUnmodifiedJSCallInList
                );
            ++IndexOfNextUnmodifiedJSCallInList;

            // Surround the javascript code with some code that will store the result into the "document.jsSimulatorObjectReferences" for later use in subsequent calls to this method:
            int referenceId = ReferenceIDGenerator.GenerateId();
            javascript = string.Format(
                @"
try {{
var result = eval(""{0}"");
document.jsSimulatorObjectReferences[""{1}""] = result;
result;
}}
catch (error) {{
    eval(""{2}"");
}}
result;
", INTERNAL_HtmlDomManager.EscapeStringForUseInJavaScript(javascript), referenceId, INTERNAL_HtmlDomManager.EscapeStringForUseInJavaScript(errorCallBack));

            // Execute the javascript code:
            object value = null;
            if (!runAsynchronously)
            {
                value = CastFromJsValue(INTERNAL_HtmlDomManager.ExecuteJavaScriptWithResult(javascript, noImpactOnPendingJSCode: noImpactOnPendingJSCode));
            }
            else
            {
                INTERNAL_HtmlDomManager.ExecuteJavaScript(javascript);
            }

            var objectReference = new INTERNAL_JSObjectReference()
            {
                Value       = value,
                ReferenceId = referenceId.ToString()
            };

            return(objectReference);
#else
            return(null);
#endif
        }
Пример #23
0
 public static void CallBack(ROSBridgeMsg msg)
 {
     OnCallBack?.Invoke(msg);
     //Debug.Log("Render callback in /mavros/local_position/pose " + msg);
 }
Пример #24
0
 public static void CallBack(ROSBridgeMsg msg)
 {
     OnCallBack?.Invoke(msg);
 }
Пример #25
0
 public Task <int> AsyncRun_Sql_Return_Int(SqlCommand cmd, OnCallBack <int> onCallBack)
 {
     return(AsyncRun_Sql_Return_Int(new SqlCommand[] { cmd }, onCallBack));
 }
Пример #26
0
 public Task <int> AsyncRun_Sql_Return_Int(IEnumerable <string> sqlList, OnCallBack <int> onCallBack)
 {
     return(AsyncRun_Sql_Return_Int(sqlList.Select(p => new SqlCommand(p, null)), onCallBack));
 }
Пример #27
0
 /// <summary>
 /// 异步返回查询对象
 /// </summary>
 /// <param name="cmdText"></param>
 /// <param name="onCallBack"></param>
 /// <returns></returns>
 public Task <T> AsyncSelect_Sql_Return_Scalar <T>(string cmdText, OnCallBack <T> onCallBack)
 {
     return(AsyncSelect_Sql_Return_Scalar(cmdText, null, onCallBack));
 }
Пример #28
0
 /// <summary>
 /// 异步返回List
 /// </summary>
 /// <param name="cmdText"></param>
 /// <param name="onCallBack"></param>
 /// <returns></returns>
 public Task <List <T> > AsyncSelect_Sql_Return_List <T>(string cmdText, OnCallBack <List <T> > onCallBack)
 {
     return(AsyncSelect_Sql_Return_List <T>(cmdText, onCallBack));
 }
Пример #29
0
 /// <summary>
 /// 异步返回DataTable
 /// </summary>
 /// <param name="cmdText"></param>
 /// <param name="onCallBack"></param>
 /// <returns></returns>
 public Task <DataTable> AsyncSelect_Sql_Return_DataTable(string cmdText, OnCallBack <DataTable> onCallBack)
 {
     return(AsyncSelect_Sql_Return_DataTable(cmdText, null, onCallBack));
 }
Пример #30
0
 public Task <DataTable> AsyncSelect_Sql_Return_DataTable(string cmdText, object param, OnCallBack <DataTable> onCallBack)
 {
     return(AsyncSelect_Sql_Return_DataTable(new SqlCommand(cmdText, param), onCallBack));
 }