Exemplo n.º 1
0
        /// <summary>
        /// Creates a coroutine pointing at the specified function.
        /// </summary>
        /// <param name="function">The function.</param>
        /// <returns>
        /// The coroutine handle.
        /// </returns>
        /// <exception cref="System.ArgumentException">Thrown if function is not of DataType.Function or DataType.ClrFunction</exception>
        public DynValue CreateCoroutine(DynValue function)
        {
            this.CheckScriptOwnership(function);

            if (function.Type == DataType.Function)
            {
                return(m_MainProcessor.Coroutine_Create(function.Function));
            }
            else if (function.Type == DataType.ClrFunction)
            {
                return(DynValue.NewCoroutine(new Coroutine(function.Callback)));
            }
            else
            {
                throw new ArgumentException("function is not of DataType.Function or DataType.ClrFunction");
            }
        }