Beispiel #1
0
        public bool Deserialize(JsonData json)
        {
            try
            {
                m_KeyToUnit[msLP_LTBU.source]      = msLP_LTBU;
                m_KeyToUnit[msGroup.source]        = msGroup;
                m_KeyToUnit[msBone_M87_BLK.source] = msBone_M87_BLK;

                var content = json;
                for (int i = 0; i < content.Count; i++)
                {
                    var item   = content[i];
                    var unit   = new PartUnit();
                    var source = (string)item["Source"];
                    unit.source         = source;
                    unit.id             = (string)item["Id"];
                    unit.type           = ((string)item["Type"]).ToEnum(PartType.Normal);
                    m_KeyToUnit[source] = unit;
#if UNITY_EDITOR
                    unitIcons.Add(source);
#endif
                }
                return(true);
            }
            catch (Exception ex)
            {
                DebugUtility.LogException(ex);
                return(false);
            }
        }
Beispiel #2
0
        public static PartUnit ParseUnit(this string name, out string customValue)
        {
            var source = string.Empty;

            customValue = string.Empty;
            var index = name.LastIndexOf('_');

            if (index < 0)
            {
                source = name;
            }
            else
            {
                //获取"_001"这类自定义字段
                var custom = name.Substring(index + 1);
                try
                {
                    Convert.ToInt32(custom);
                    source      = name.Substring(0, index);
                    customValue = custom;
                }
                catch (Exception)
                {
                    source = name;
                }
            }

            PartUnit part = new PartUnit();

            //if (!PartLibraryManager.Instance.TryGetPartUnit(source, out part))
            //{
            //	DebugUtility.LogError(LoggerTags.Project, "命名出错!{0}", name);
            //}
            return(part);
        }
Beispiel #3
0
 public bool TryGetPartUnit(string key, out PartUnit unit)
 {
     if (m_KeyToUnit.TryGetValue(key, out unit))
     {
         return(true);
     }
     return(false);
 }