private void InitTypeItems()
        {
            NodeType         nodeType = _nodeAttr.Node.GetNodeType();
            CustomDefineType type     = CustomDefine.GetTypeByNodeType(nodeType);

            _typeNameList = CustomDefine.GetCustomDefineListByType(type);
            for (int i = 0; i < _typeNameList.Count; i++)
            {
                GameObject    item = ResourceManager.GetInstance().GetPrefab("Prefabs/Views/EditViews", "SelectCustomizedTypeItem");
                RectTransform tf   = item.GetComponent <RectTransform>();
                tf.SetParent(_itemContainerTf, false);
                Text typeNameText = tf.Find("CustomizedTypeText").GetComponent <Text>();
                typeNameText.text = _typeNameList[i];
                item.GetComponent <Image>().color = UnSelectedColor;
                int itemIndex = i;
                UIEventListener.Get(item).AddClick(() => {
                    OnItemClickHandler(itemIndex, false);
                });
                _itemList.Add(item);
            }
            // 计算content面板的高度
            float preferredHeight = _typeNameList.Count * 30 + 5;

            _contentPreferredHeight    = preferredHeight < _contentDefaultSize.y ? _contentDefaultSize.y : preferredHeight;
            _itemContainerTf.sizeDelta = new Vector2(_contentDefaultSize.x, _contentPreferredHeight);
            _contentScrollRect.Rebuild(CanvasUpdate.PostLayout);
            _curSelectedItemIndex = -1;
            // 默认选中节点值的那个item,如果没有对应的,则不选中任何一个
            int index = _typeNameList.IndexOf(_nodeAttr.GetValueString());

            OnItemClickHandler(index, true);
        }
Ejemplo n.º 2
0
        public static bool IsExist(CustomDefineType type, string typeName)
        {
            Dictionary <string, CustomDefineData> dic = customDefineDic[type];
            CustomDefineData data;

            return(dic.TryGetValue(typeName, out data));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取指定的自定义配置
        /// </summary>
        /// <param name="type"></param>
        /// <param name="typeName"></param>
        /// <returns></returns>
        public static CustomDefineData GetDataByTypeAndName(CustomDefineType type, string typeName)
        {
            Dictionary <string, CustomDefineData> dic = customDefineDic[type];
            CustomDefineData data = null;

            dic.TryGetValue(typeName, out data);
            return(data);
        }
Ejemplo n.º 4
0
        public static List <string> GetCustomDefineListByType(CustomDefineType type)
        {
            List <string> list = new List <string>();
            Dictionary <string, CustomDefineData> dic = customDefineDic[type];

            foreach (var v in dic.Values)
            {
                list.Add(v.typeName);
            }
            return(list);
        }
Ejemplo n.º 5
0
        public static void ModifyDefineParaList(CustomDefineType type, string name, string paraList)
        {
            Dictionary <string, CustomDefineData> dic = customDefineDic[type];
            CustomDefineData data;

            if (dic.TryGetValue(name, out data))
            {
                data.paraListStr = paraList;
            }
            else
            {
                Logger.Log("CustomType of " + type + " with name " + name + " not found!");
            }
        }
        private void InitParas()
        {
            CustomDefineType type     = CustomDefine.GetTypeByNodeType(_nodeAttr.Node.GetNodeType());
            string           typeName = _nodeAttr.Node.GetAttrByIndex(0).GetValueString();
            CustomDefineData data     = CustomDefine.GetDataByTypeAndName(type, typeName);

            // 获取参数名称的列表
            if (data == null)
            {
                _paraNameList = new List <string>();
            }
            else
            {
                if (data.paraListStr == "")
                {
                    _paraNameList = new List <string>();
                }
                else
                {
                    _paraNameList = new List <string>(data.paraListStr.Split(','));
                }
            }
            // 获取参数值的列表
            List <string> paraValueList = GetParaValuesFromParaStr(_nodeAttr.GetValueString());

            for (int i = 0; i < _paraNameList.Count; i++)
            {
                GameObject    item = ResourceManager.GetInstance().GetPrefab("Prefabs/Views/EditViews", "EditParaItem");
                RectTransform tf   = item.GetComponent <RectTransform>();
                tf.SetParent(_itemContainerTf, false);
                EditParaItem itemSt = new EditParaItem
                {
                    go        = item,
                    valueText = tf.Find("ParaValueField").GetComponent <InputField>(),
                };
                Text paraNameText = tf.Find("ParaNameText").GetComponent <Text>();
                paraNameText.text = _paraNameList[i];
                if (i < paraValueList.Count)
                {
                    itemSt.valueText.text = paraValueList[i];
                }
                else
                {
                    itemSt.valueText.text = "";
                }
                _itemList.Add(itemSt);
            }
        }
Ejemplo n.º 7
0
        public override void BindItem(RectTransform parentTf)
        {
            base.BindItem(parentTf);
            List <Dropdown.OptionData> optionList = new List <Dropdown.OptionData>();
            CustomDefineType           type       = CustomDefine.GetTypeByNodeType(_node.GetNodeType());
            List <string> list = CustomDefine.GetCustomDefineListByType(type);

            for (int i = 0; i < list.Count; i++)
            {
                optionList.Add(new Dropdown.OptionData(list[i]));
            }
            _dropDown.options = optionList;
            _dropDown.onValueChanged.AddListener(OnDropdownValueChangedHandler);

            UIEventListener.Get(_editBtnGo).AddClick(OnEditBtnClickHandler);
        }
Ejemplo n.º 8
0
        public static bool ModifyDefineName(CustomDefineType type, string fromName, string toName)
        {
            Dictionary <string, CustomDefineData> dic = customDefineDic[type];

            if (dic.ContainsKey(toName))
            {
                return(false);
            }
            CustomDefineData data;

            if (dic.TryGetValue(fromName, out data))
            {
                data.typeName = toName;
                dic.Remove(fromName);
                if (toName != "")
                {
                    dic.Add(toName, data);
                }
            }
            return(true);
        }
Ejemplo n.º 9
0
        public static bool AddData(CustomDefineType type, string typeName, string paraList)
        {
            if (typeName == "")
            {
                return(false);
            }
            CustomDefineData data = new CustomDefineData
            {
                type        = type,
                typeName    = typeName,
                paraListStr = paraList,
            };
            Dictionary <string, CustomDefineData> dic = customDefineDic[type];

            if (dic.ContainsKey(typeName))
            {
                return(false);
            }
            dic.Add(typeName, data);
            return(true);
        }
Ejemplo n.º 10
0
        public static void RemoveData(CustomDefineType type, string typeName)
        {
            Dictionary <string, CustomDefineData> dic = customDefineDic[type];

            dic.Remove(typeName);
        }