Esempio n. 1
0
        /// <summary>
        /// Used to convert object references to strings.
        /// </summary>

        static object EncodeReference(GameObject go, object val)
        {
            if (val is UnityEngine.Object)
            {
#if UNITY_EDITOR
                return(go.ReferenceToString(val as UnityEngine.Object));
#else
                return(null);
#endif
            }
            else if (val is System.Collections.IList)
            {
                System.Collections.IList list = val as System.Collections.IList;
                if (list.Count == 0)
                {
                    return(null);
                }
                System.Type t        = list.GetType();
                System.Type elemType = t.GetElementType();
                if (elemType == null)
                {
                    elemType = t.GetGenericArgument();
                }

                if (typeof(UnityEngine.Object).IsAssignableFrom(elemType))
                {
#if UNITY_EDITOR
                    string[] strList = new string[list.Count];
                    for (int d = 0, dmax = list.Count; d < dmax; ++d)
                    {
                        strList[d] = go.ReferenceToString(list[d] as UnityEngine.Object);
                    }
                    val = strList;
#else
                    return(null);
#endif
                }
            }
            return(val);
        }