Esempio 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)
 {
     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");
     }
 }
Esempio n. 2
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)
        {
            if (!m_isAlive)
            {
                throw new InvalidOperationException(string.Format("Attempting to create a coroutine on dead Script [{0}]", FriendlyName));
            }
            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");
            }
        }