예제 #1
0
    private void OnEnable()
    {
        _index = 1;

        assetObj = (RedPointAsset)target;
        //根节点的id = 1, parentId = -1;
        assetObj.cfg.id       = 1;
        assetObj.cfg.parentId = -1;
        assetObj.cfg.key      = "Root";

        _nodeDic     = new Dictionary <int, RedPointAssetCfg>();
        _nodeViewDic = new Dictionary <int, RedPointAssetCfgViewItem>();
        _nodeDic.Add(1, assetObj.cfg);//添加根节点
        _nodeViewDic.Add(1, new RedPointAssetCfgViewItem(this, assetObj.cfg));
        for (int i = 0; i < assetObj.cfgList.Count; i++)
        {
            RedPointAssetCfg cfg = assetObj.cfgList[i];
            _nodeDic.Add(cfg.id, cfg);
            _nodeViewDic.Add(cfg.id, new RedPointAssetCfgViewItem(this, cfg));
            if (cfg.id > _index) //获取最大的索引值
            {
                _index = cfg.id;
            }
        }
    }
예제 #2
0
    private int _index; //当前节点的最大索引

    public void Init()
    {
        nodeDic = new Dictionary <int, RedPointNode>();
        //初始化红点结构
        RedPointAsset pointAsset = ResMgr.Inst.LoadAsset <RedPointAsset>("RedPointCfg", 3, "RedPoint");

        //转换下数据
        AddNode(pointAsset.cfg);
        for (int i = 0; i < pointAsset.cfgList.Count; i++)
        {
            AddNode(pointAsset.cfgList[i]);
        }
        //构建下每个节点的查询表
        foreach (var pair in nodeDic)
        {
            pair.Value.BuildChildDic();
            if (pair.Key > _index)
            {
                _index = pair.Key;
            }
        }

        //释放空间
        ResMgr.Inst.OnModuleDestroy("RedPoint", true);
    }
예제 #3
0
    private void OnEnable()
    {
        _idProperty   = serializedObject.FindProperty("id");
        _typeProperty = serializedObject.FindProperty("type");
        _goProperty   = serializedObject.FindProperty("viewGo");
        _numProperty  = serializedObject.FindProperty("numTxt");

        if (!Application.isPlaying)
        {
            string path = "Assets/Data/RedPointCfg.asset";
            if (File.Exists(path))
            {
                _assetObj = AssetDatabase.LoadAssetAtPath <RedPointAsset>(path);
                _nodeDic  = new Dictionary <int, RedPointAssetCfg>();
                _nodeDic.Add(1, _assetObj.cfg);//添加根节点
                for (int i = 0; i < _assetObj.cfgList.Count; i++)
                {
                    RedPointAssetCfg cfg = _assetObj.cfgList[i];
                    _nodeDic.Add(cfg.id, cfg);
                }
                if (!_nodeDic.ContainsKey(_idProperty.intValue))
                {
                    _idProperty.intValue = 0;
                    _idProperty.serializedObject.ApplyModifiedProperties();
                    _key = "Dynamic";
                }
                else
                {
                    _key = GetKey(_idProperty.intValue);
                }
            }
            else
            {
                _assetObj            = null;
                _nodeDic             = null;
                _idProperty.intValue = 0;
                _idProperty.serializedObject.ApplyModifiedProperties();
                _key = "Dynamic";
            }
        }
        else //运行时,从RedPointMgr中获取数据
        {
            _key = GetKey(_idProperty.intValue);
        }
    }