Ejemplo n.º 1
0
        private void SaveTreeToTreeData()
        {
            if (m_nTreeComposeIndex < 0 || m_nTreeComposeIndex > NEConfig.arrTreeComposeData.Length)
            {
                Debug.Log("需要选择树的类型");
                return;
            }
            var    composeData = NEConfig.arrTreeComposeData[m_nTreeComposeIndex];
            NEData data        = GetCurrentTreeNEData();

            if (data == null)
            {
                Debug.Log("没有树数据");
                return;
            }
            string dir = composeData.fileDir;

            if (dir.StartsWith("Assets"))
            {
                dir = dir.Replace("Assets", "");
            }
            string path = EditorUtility.SaveFilePanel("保存数据", Application.dataPath + dir, "", composeData.fileExt);

            if (path.Length != 0)
            {
                NEUtil.SerializerObject(path, data, m_lstNodeDataType.ToArray());
            }
            AssetDatabase.Refresh();
        }
Ejemplo n.º 2
0
        private void LoadTreeByTreeData()
        {
            string path = EditorUtility.OpenFilePanel("加载数据", Application.dataPath, "bytes");

            if (path.Length != 0)
            {
                //通过前后缀确定当前数据是哪种类型,需要先切换到当前类型,在加载数据,否则数据有可能不对
                NEData neData = NEUtil.DeSerializerObject(path, typeof(NEData), m_lstNodeDataType.ToArray()) as NEData;
                CreateTreeByTreeData(neData);
            }
        }
Ejemplo n.º 3
0
        private void Load(NETreeComposeType conposeType)
        {
            NEData neData = null;

            if (m_cRoot != null)
            {
                foreach (var item in NEConfig.arrTreeComposeData)
                {
                    if (item.rootType == m_cRoot.node.GetType())
                    {
                        if (item == conposeType)
                        {
                            neData = GetCurrentTreeNEData();
                        }
                        break;
                    }
                }
                m_cRoot = null;
            }
            NEUtil.LoadTreeComposeTypes(conposeType, out m_lstNodeType, out m_lstNodeDataType);

            //移除根节点
            List <Type> lst = new List <Type>();

            for (int i = 0; i < m_lstNodeType.Count; i++)
            {
                if (!IsRootType(m_lstNodeType[i]))
                {
                    lst.Add(m_lstNodeType[i]);
                }
            }
            if (m_cCanvas != null)
            {
                m_cCanvas.Dispose();
            }
            m_cCanvas = new NECanvas(lst, CreateNENodeByNENodeType);
            CreateTreeByTreeData(neData);
        }
Ejemplo n.º 4
0
        private void LoadTreeByTreeData()
        {
            if (m_nTreeComposeIndex < 0 || m_nTreeComposeIndex > NEConfig.arrTreeComposeData.Length)
            {
                Debug.Log("需要选择树的类型");
                return;
            }
            var    composeData = NEConfig.arrTreeComposeData[m_nTreeComposeIndex];
            string dir         = composeData.fileDir;

            if (dir.StartsWith("Assets"))
            {
                dir = dir.Replace("Assets", "");
            }
            string path = EditorUtility.OpenFilePanel("加载数据", Application.dataPath + dir, composeData.fileExt);

            if (path.Length != 0)
            {
                //通过前后缀确定当前数据是哪种类型,需要先切换到当前类型,在加载数据,否则数据有可能不对
                NEData neData = NEUtil.DeSerializerObject(path, typeof(NEData), m_lstNodeDataType.ToArray()) as NEData;
                CreateTreeByTreeData(neData);
            }
        }
Ejemplo n.º 5
0
        private void ParseData(string path, byte[] bytesData)
        {
            NEData neData = NEUtil.DeSerializerObjectFromBuff(bytesData, typeof(NEData), m_arrParseTypes) as NEData;
            Type   type   = neData.data.GetType();

            FieldInfo[] fields         = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy);
            bool        hasPropertyKey = false;

            foreach (var item in fields)
            {
                if (item.GetCustomAttributes(typeof(NEPropertyKeyAttribute), true).Length > 0)
                {
                    object key = item.GetValue(neData.data);
                    m_dicData.Add(key, neData);
                    hasPropertyKey = true;
                    break;
                }
            }
            if (!hasPropertyKey)
            {
                CLog.LogError(neData.data.GetType() + " can not find NEPropertyKeyAttribute!");
            }
        }