public object DOMParse(XmlElement element, params object[] parameters) { var qrPrompt = new QRScannerEffect(); qrPrompt.SelectionType = element.Attributes["selection-type"].Value.ToEnum <QRScannerEffect.ListType>(); qrPrompt.ScannerMessage = element.SelectSingleNode("message").InnerText; foreach (var listElem in element.SelectNodes("qr-id")) { qrPrompt.ValidIds.Add((listElem as XmlElement).InnerText); } return(qrPrompt); }
// ---------------------- // Constructor // --------------------- public QRScannerEffectEditor() { effect = new QRScannerEffect(); effectIds = new List <string>(); listTypeNames = Enum.GetValues(typeof(QRScannerEffect.ListType)) .Cast <QRScannerEffect.ListType>() .Select(v => TC.get("QR.QRScannerEffect.ListType." + v.ToString())) .ToArray(); Action <ReorderableList> listChangedCallback = (r) => { Controller.Instance.AddTool(new ChangeValueTool <QRScannerEffect, List <string> >(effect, effectIds.ToList(), "ValidIds")); }; GenericMenu.MenuFunction2 toAddSelected = (s) => { effectIds.Add((string)s); listChangedCallback(qrIdReorderableList); }; qrIdReorderableList = new ReorderableList(effectIds, typeof(string)) { drawElementCallback = (rect, index, isActive, isFocused) => { EditorGUI.LabelField(rect, (string)qrIdReorderableList.list[index]); }, onAddDropdownCallback = (rect, list) => { var genericMenu = new GenericMenu(); foreach (var qr in qrIds) { genericMenu.AddItem(new GUIContent(qr), false, toAddSelected, qr); } genericMenu.ShowAsContext(); }, onRemoveCallback = (r) => { effectIds.RemoveAt(r.index); listChangedCallback(r); }, onReorderCallback = (r) => listChangedCallback(r) }; }