示例#1
0
    public void setValue(Transform tr, object map, bool isLuatable = false)
    {
        if (map == null)
        {
            map = new Hashtable();
        }

        CLUIElement  cell   = null;
        CLUIFormRoot root   = null;
        int          count  = tr.childCount;
        Transform    cellTr = null;

        for (int i = 0; i < count; i++)
        {
            cellTr = tr.GetChild(i);
            cell   = cellTr.GetComponent <CLUIElement> ();
            if (cell != null && !string.IsNullOrEmpty(cell.jsonKey))
            {
                if (cell.valueIsNumber)
                {
                    cell.value = getVal(map, cell.jsonKey).ToString();
//					cell.value = MapEx.getInt(map, cell.jsonKey).ToString();
                }
                else
                {
                    cell.value = getVal(map, cell.jsonKey).ToString();
                }
            }

            root = cellTr.GetComponent <CLUIFormRoot> ();
            if (root != null)
            {
                if (!string.IsNullOrEmpty(root.jsonKey))
                {
                    setValue(root.transform, getVal(map, root.jsonKey), isLuatable);
                }
                else
                {
                    setValue(root.transform, map, isLuatable);
                }
            }
            else
            {
                if (cellTr.childCount > 0)
                {
                    setValue(cellTr, map, isLuatable);
                }
            }
        }
    }
示例#2
0
    public object getValue(Transform tr, object map, bool isLuaTable)
    {
        if (map == null)
        {
            if (isLuaTable)
            {
                map = CLBaseLua.mainLua.NewTable();
            }
            else
            {
                map = new Hashtable();
            }
        }
        CLUIElement  cell  = null;
        CLUIFormRoot root  = null;
        int          count = tr.childCount;

        for (int i = 0; i < count; i++)
        {
            cell = tr.GetChild(i).GetComponent <CLUIElement> ();
            if (cell != null && !string.IsNullOrEmpty(cell.jsonKey))
            {
                setVal(map, cell.jsonKey, cell.value);
            }

            root = tr.GetChild(i).GetComponent <CLUIFormRoot> ();
            if (root != null && !string.IsNullOrEmpty(root.jsonKey))
            {
                setVal(map, root.jsonKey, getValue(tr.GetChild(i), null, isLuaTable));
            }
            else
            {
                map = getValue(tr.GetChild(i), map, isLuaTable);
            }
        }
        return(map);
    }