Пример #1
0
    public void RefreshUIElementState()
    {
        foreach (var tKv in mUIElementDic)
        {
            UIElementData tUIElementData = tKv.Value;

            tUIElementData.RefreshState();
        }
    }
Пример #2
0
    /// <summary>
    /// 解析View脚本中的元素
    /// </summary>
    private void ParseViewScriptData()
    {
        if (File.Exists(mViewPath) == false)
        {
            return;
        }

        string tViewContent = File.ReadAllText(mViewPath);

        string tStartTag = @"{//CheckNullElementStartTag";
        string tEndTag   = @"};//CheckNullElementEndTag";

        int tStartIndex = tViewContent.IndexOf(tStartTag) + tStartTag.Length;
        int tCount      = tViewContent.IndexOf(tEndTag) - tStartIndex;

        string tContent = tViewContent.Substring(tStartIndex, tCount);

        string[] tLineSplitStrArr = tContent.Split('\n');

        for (int i = 0; i < tLineSplitStrArr.Length; ++i)
        {
            string tLineStr = tLineSplitStrArr[i];
            if (tLineStr.Contains(',') == false)
            {
                continue;
            }

            string[] tDotSplitStrArr = tLineStr.Split(',');

            string tPattern = "tElementDic.Add\\(new KeyValuePair<string, string>\\(\"([\\s\\S]+)\",\"([\\s\\S]+)\"\\)\\);";

            Match  tMatch    = Regex.Match(tLineStr, tPattern);
            string tPathStr  = tMatch.Groups[1].Value;
            string tTypeName = tMatch.Groups[2].Value;



            int    tGoNameStartIndex = tPathStr.LastIndexOf("/") + 1;
            string tGoName           = tPathStr.Substring(tGoNameStartIndex);
            if (string.IsNullOrEmpty(tGoName))
            {
                tGoName = mPrefabGo.name;
            }

            string        tVarName = GetVariableNameByStr(tGoName, tTypeName);
            UIElementData tElement = UIElementData.Create(mPrefabGo, tVarName, tPathStr, tTypeName);
            tElement.RefreshState();

            mUIElementDic.Add(tElement.mVarName, tElement);
        }
    }