protected void DrawLinkerEditor() { Undo.RecordObject(target, "F"); for (int i = 0; i < lk.monos.Length; i++) { EditorGUILayout.BeginHorizontal(); DrawItem(i); EditorGUILayout.EndHorizontal(); } if (EditorDrawUtils.FixGreenButton("Add Item")) { AddItem(null); } EditorUtility.SetDirty(target); }
public void DrawListColorProvider() { EditorDrawUtils.ListColorGUI("Color", Render.ListColorProvider.Colors); }
void DrawItem(int index) { string li = GUILayout.TextField((index + 1).ToString(), GUILayout.Width(20)); int ii = index + 1; int.TryParse(li, out ii); ii = Mathf.Clamp(ii, 1, lk.names.Count); if (ii != index + 1) { SwitchItemIndexInsert(index, ii - 1); } EditorDrawUtils.BeginStyleBackground(Color.cyan, () => { lk.names[index] = FormatName(lk.names[index]); lk.names[index] = EditorGUILayout.TextField(lk.names[index]); }); Object selectType = GetMonoAtIndex(index); if (selectType != null) { System.Type currentType = selectType.GetType(); GameObject go = null; if (currentType == typeof(GameObject)) { go = (GameObject)selectType; } else if (currentType.IsSubclassOf(typeof(Component))) { go = ((Component)selectType).gameObject; } if (go != null) { List <Object> allowTypes = new List <Object>() { go }; Component[] cs = go.GetComponents <Component>(); allowTypes.AddRange(cs); int selectIndex = allowTypes.IndexOf(selectType); if (selectIndex == -1) { selectIndex = 0; } EditorDrawUtils.BeginStyleBackground(Color.black, () => { selectIndex = EditorGUILayout.Popup(selectIndex, ConvertTypeArrayToStringArray(allowTypes)); }); if (lk.names[index] == "") { lk.names[index] = FormatName(allowTypes[selectIndex].name); } lk.monos[index] = allowTypes[selectIndex]; } } lk.monos[index] = EditorGUILayout.ObjectField(lk.monos[index], typeof(UnityEngine.Object), true); var objfind = GetMonoAtIndex(index); GUILayout.BeginHorizontal(); { if (objfind != null && lk.names[index] != FormatName(objfind.name)) { if (EditorDrawUtils.ColorButton(Color.green, "❤", GUILayout.Width(25))) { lk.names[index] = ""; } } if (EditorDrawUtils.ColorButton(Color.red, "✖", GUILayout.Width(25))) { RemoveItemAtIndex(index); } } GUILayout.EndHorizontal(); }