protected override TreeViewItem BuildRoot() { TreeViewItem root = new TreeViewItem { id = 0, depth = -1, displayName = "Root" }; root.children = new List <TreeViewItem>(); if (m_data != null) { List <XmlClassData> .Enumerator itor = m_data.GetEnumerator(); while (itor.MoveNext()) { XmlClassData _class = itor.Current; if (_class == null) { continue; } if (!_class.sLogicName.Equals("AnimatorXmlData")) { continue; } AnimatorDataViewTreeItem arrayItem = new AnimatorDataViewTreeItem(_class, 0); root.AddChild(arrayItem); } } return(root); }
protected override void RowGUI(RowGUIArgs args) { base.RowGUI(args); AnimatorDataViewTreeItem treeItem = args.item as AnimatorDataViewTreeItem; if (treeItem == null) { return; } for (int i = 0; i < args.GetNumVisibleColumns(); ++i) { CellGUI(args.GetCellRect(i), treeItem, args.GetColumn(i)); } }
private void CellGUI(Rect cellRect, AnimatorDataViewTreeItem treeitem, int column) { CenterRectUsingSingleLineHeight(ref cellRect); AnimatorDataItem item; switch ((propertyColumns)column) { case propertyColumns.ResourcePath: item = treeitem.m_items[column]; if (item == null) { return; } if (item.param.sType == "System.Boolean") { bool.TryParse(item.param.sValue, out item.bValue); item.bValue = EditorGUI.Toggle(cellRect, item.bValue); item.param.sValue = item.bValue.ToString(); } else if (item.param.sType == "System.Int32") { int.TryParse(item.param.sValue, out item.nValue); item.nValue = EditorGUI.IntField(cellRect, item.nValue); item.param.sValue = item.nValue.ToString(); } else if (item.param.sType == "System.Single") { float.TryParse(item.param.sValue, out item.fValue); item.fValue = EditorGUI.FloatField(cellRect, item.fValue); item.param.sValue = item.fValue.ToString(); } else if (item.param.sType == "System.String") { item.sValue = item.param.sValue; item.sValue = EditorGUI.TextField(cellRect, item.sValue); item.param.sValue = item.sValue; } break; case propertyColumns.DataType: item = treeitem.m_items[column]; if (item == null) { return; } if (item.param.sType == "System.Int32") { int.TryParse(item.param.sValue, out item.nValue); item.nValue = EditorGUI.IntPopup(cellRect, item.nValue, m_ResourceTypes, m_ResourceTypeIndex); item.param.sValue = item.nValue.ToString(); } break; case propertyColumns.AnimationLayer: item = treeitem.m_items[column]; if (item == null) { return; } if (item.param.sType == "System.Int32") { int.TryParse(item.param.sValue, out item.nValue); item.nValue = EditorGUI.IntPopup(cellRect, item.nValue, m_AnimationLayers, m_AnimationLayerIndex); item.param.sValue = item.nValue.ToString(); } break; case propertyColumns.TransitionDuration: item = treeitem.m_items[column]; if (item == null) { return; } if (item.param.sType == "System.Single") { float.TryParse(item.param.sValue, out item.fValue); item.fValue = EditorGUI.FloatField(cellRect, item.fValue); item.param.sValue = item.fValue.ToString(); } break; case propertyColumns.Describe: item = treeitem.m_items[column]; if (item == null) { return; } if (item.param.sType == "System.String") { item.sValue = item.param.sValue; item.sValue = EditorGUI.TextField(cellRect, item.sValue); item.param.sValue = item.sValue; } break; case propertyColumns.DeleteBtn: Rect rectDeleteBtn = new Rect(cellRect.x + 5, cellRect.y, 50, cellRect.height); if (GUI.Button(rectDeleteBtn, "删除")) { if (EditorUtility.DisplayDialog("删除", "是否删除当前行?", "是", "否")) { RemoveClassData(treeitem.m_class.sLogicName); } } break; default: break; } }