Exemplo n.º 1
0
    /// <summary>
    /// Gets the variable at index.
    /// </summary>
    /// <returns>The <see cref="``0 (owner=[Method SparkStream.GetVariableAt``1(index:System.Int32):``0])"/>.</returns>
    /// <param name="index">Index.</param>
    /// <typeparam name="T">The 1st type parameter.</typeparam>
    public T GetVariableAt <T>(int index)
    {
        if (receiveCount <= Count)
        {
            object returnValue = networkVariables.ElementAt(index).Value;

            if (typeof(SparkColor).IsAssignableFrom(returnValue.GetType()))
            {
                SparkColor sparkColor = (SparkColor)returnValue;
                return((T)(object)new Color(sparkColor.r, sparkColor.g, sparkColor.b, sparkColor.a));
            }

            if (typeof(SparkEnum).IsAssignableFrom(returnValue.GetType()))
            {
                SparkEnum sparkEnum = (SparkEnum)returnValue;
                return((T)Enum.Parse(sparkEnum.enumType, sparkEnum.enumString));
            }

            return((T)returnValue);
        }
        else
        {
            Debug.Log("Default value returned for this 'GetVariableAt'. " + default(T).ToString());
            return(default(T));
        }
    }
Exemplo n.º 2
0
    // Enum

    /// <summary>
    /// Sends an Enum.
    /// </summary>
    /// <param name="enumeration">Enumeration.</param>
    public void SendNext(Enum enumeration)
    {
        SparkEnum sparkEnum = new SparkEnum(enumeration.GetType(), enumeration.ToString());

        networkVariables.Add(sendCount++, sparkEnum);
    }