void OnGUI() { if (GUI.Button(new Rect(10, 10, 80, 50), "Change1")) { PrintArr(mTestDragList); for (int i = 0; i < 10; ++i) { mTmpList.Add(mTestDragList[i]); if (mTmpList[i] is ResItemInfo) { (mTmpList[i] as ResItemInfo).iCount = i + 11000; } else { (mTmpList[i] as EqptItemInfo).Exp = i + 22000; } } Debug.LogWarning("========================="); PrintArr(mTmpList); Debug.LogWarning("========================="); PrintArr(mTestDragList); } if (GUI.Button(new Rect(100, 10, 80, 50), "Change2")) { PrintArr(mTestDragList); for (int i = 0; i < 10; ++i) { if (mTestDragList[i] is ResItemInfo) { ResItemInfo resItem = new ResItemInfo(); resItem = mTestDragList[i] as ResItemInfo; mTmpList.Add(resItem); } else { EqptItemInfo eqptItem = new EqptItemInfo(); eqptItem = mTestDragList[i] as EqptItemInfo; mTmpList.Add(eqptItem); } if (mTmpList[i] is ResItemInfo) { (mTmpList[i] as ResItemInfo).iCount = i + 11000; } else { (mTmpList[i] as EqptItemInfo).Exp = i + 22000; } } Debug.LogWarning("========================="); PrintArr(mTmpList); Debug.LogWarning("========================="); PrintArr(mTestDragList); } }
// Use this for initialization void Start() { for (int i = 0; i < 10; ++i) { ResItemInfo resItem = new ResItemInfo(); resItem.iCount = i + 10000; resItem.mStrName = "Res_" + i.ToString(); mTestDragList.Add(resItem); EqptItemInfo eqptItem = new EqptItemInfo(); eqptItem.Exp = i + 20000; eqptItem.mStrName = "Eqpt_" + i.ToString(); mTestDragList.Add(eqptItem); } }
void OnGUI() { if (GUI.Button(new Rect(0, 50, 100, 50), "Add")) { ArrayList ArrList = new ArrayList(); int idx = 0; for (int i = 0; i < 10; ++i) { ResItemInfo resItem = new ResItemInfo(); resItem.iCount = i + 10000; resItem.mIndex = ++idx; resItem.mStrName = "Res_" + idx.ToString(); ArrList.Add(resItem); EqptItemInfo eqptItem = new EqptItemInfo(); eqptItem.Exp = i + 20000; eqptItem.mIndex = ++idx; eqptItem.mStrName = "Eqpt_" + idx.ToString(); ArrList.Add(eqptItem); } Debug.LogWarning("========Len = " + ArrList.Count); BindDataSource(ArrList, 1); } if (GUI.Button(new Rect(0, 100, 100, 50), "Del")) { } if (GUI.Button(new Rect(0, 150, 100, 50), "Del&Add")) { } return; if (GUI.Button(new Rect(0, 50, 100, 50), "Add")) { AddItems(); } if (GUI.Button(new Rect(0, 100, 100, 50), "Del")) { DelItems(); } if (GUI.Button(new Rect(0, 150, 100, 50), "Del&Add")) { DelItems(); AddItems(); } }