Пример #1
0
        /// <summary>
        /// 解析
        /// </summary>
        /// <param name="context"></param>
        public static List <Word> BindingParse(GameObject context, string layerName)
        {
            List <Word> words   = ParseLayerName(context.name);
            string      newName = getGameObjectName(words);

            if (!string.IsNullOrEmpty(newName))
            {
                context.name = newName.Substring(0, Mathf.Min(newName.Length, 20)); //截取长度
            }

            IBinding import = null;

            //解析绑定组件和参数
            foreach (Word word in words)
            {
                if (word.TypeAndParams == null)
                {
                    continue;
                }
                foreach (string key in word.TypeAndParams.Keys)
                {
                    import = LayerWordBinder.GetParser(key);

                    if (import == null)
                    {
                        Debug.LogWarning("Cant parse context ! key :" + key + " , layer:" + layerName);
                        continue;
                    }

                    import.StartBinding(context, word.TypeAndParams[key], layerName);
                }
            }

            return(words);
        }
Пример #2
0
        public static void exitBindingParse(List <Word> words, GameObject context, string layerName)
        {
            IBinding import = null;

            foreach (Word word in words)
            {
                if (word.TypeAndParams == null)
                {
                    continue;
                }
                foreach (string key in word.TypeAndParams.Keys)
                {
                    import = LayerWordBinder.GetParser(key);
                    if (import == null)
                    {
                        continue;
                    }
                    import.ExitBinding(context, word.TypeAndParams[key], layerName);
                }
            }
        }