示例#1
0
        public static Template Create(string text, ref int i)
        {
            var template = new Template();
            bufferCount = 0;
            for(; i < text.Length; ++i) {
                var c = text[i];
                if(c == escape) {
                    ++i;
                }
                else if(c == openChar) {
                    template.prefix = new string(buffer, 0, bufferCount);
                    var cpaths = new List<string>();
                    bufferCount = 0;
                    for(++i; i < text.Length; ++i) {
                        if(text[i] == separator) {
                            template.childName = new string(buffer, 0, bufferCount);
                            bufferCount = 0;
                            ++i;
                        }
                        var nc = text[i];
                        if(nc ==  closeChar|| nc == fieldAccess) {
                            cpaths.Add(new string(buffer, 0, bufferCount));
                            bufferCount = 0;
                            ++i;
                            if(nc == closeChar) break;
                        }
                        buffer[bufferCount++] = text[i];
                    }

                    if(cpaths.Count > 0) {
                        template.childPath = cpaths.ToArray();
                    }
                    if(template.childName != null) {
                        template.childNode = Create (text, ref i);
                    }
                    template.nextNode = Create (text, ref i);
                    return template;
                }
                else if(c == endChar) {
                    ++i;
                    template.prefix = new string(buffer, 0, bufferCount);
                    return template;
                }
                else if(c == sepStart) {
                    ++i;
                    template.prefix = new string(buffer, 0, bufferCount);
                    template.sepByNode = Create(text, ref i);
                    template.nextNode = Create(text, ref i);
                    return template;
                }
                buffer[bufferCount++] = text[i];
            }
            template.prefix = new string(buffer, 0, bufferCount);
            return template;
        }
		public void LoadView (string id, View view) {
			content = GetTemplateById (id);
			content.gameObject.SetActive (true);
			ApplySettings (content.Settings);
			content.LoadView (view, OverlayElements);
		}