示例#1
0
文件: UINode.cs 项目: spadd/Json2UGUI
        public static UINode CreateNode(string path, List <string> assetPathList, List <FontItem> fonts, JsonData info, UINode parent = null)
        {
            string _type = info["type"].ValueAsString();

            if (_type.Contains("scroll"))
            {
                int index = _type.IndexOf("scroll");
                _type = _type.Substring(0, index + 1).ToUpper() + _type.Substring(index + 1, _type.Length - (index + 1));
            }
            else
            {
                _type = _type.Substring(0, 1).ToUpper() + _type.Substring(1, _type.Length - 1);
            }
            //UnityEngine.Debug.LogError(Type.GetType(string.Format("ThunderEditor.{0}Node", _type)) + "   >>> " + string.Format("Thunder.{0}Node", _type));

            UINode node = null;

            node        = System.Activator.CreateInstance(Type.GetType(string.Format("ThunderEditor.{0}Node", _type)), path, assetPathList, fonts, info) as UINode;
            node.parent = parent;

            /* try
             * {
             *   node = System.Activator.CreateInstance(Type.GetType(string.Format("ThunderEditor.{0}Node", _type)), path, assetPathList, fonts, info) as UINode;
             * }
             * catch (Exception e)
             * {
             *   UnityEngine.Debug.LogError(string.Format("Thunder.{0}Node", _type) +" Error:"+e.Message);
             * }*/
            return(node);
        }