private void BuildContextualMenu(ContextualMenuPopulateEvent evt) { if (config.type != null) { if (config.filter == null || !config.filter.SetMember && config.filter.IsValidTarget(MemberData.TargetType.Values)) { evt.menu.AppendAction("To Default", (e) => { if (config.type == typeof(Type)) { member = new MemberData(typeof(object)); } else if (config.type is RuntimeType) { member = MemberData.CreateFromValue(null, config.type); } else { member = new MemberData(ReflectionUtils.CanCreateInstance(config.type) ? ReflectionUtils.CreateInstance(config.type) : null) { startType = config.type, targetTypeName = config.type.FullName, }; } config.OnValueChanged(member); config.owner.OnValueChanged(); config.owner.MarkRepaint(); UpdateControl(); uNodeEditor.GUIChanged(); }, DropdownMenuAction.AlwaysEnabled); if (config.type == typeof(object)) { var types = EditorReflectionUtility.GetCommonType(); foreach (var t in types) { evt.menu.AppendAction("To Value/" + t.PrettyName(), (e) => { member = new MemberData(ReflectionUtils.CanCreateInstance(t) ? ReflectionUtils.CreateInstance(t) : null) { startType = t, targetTypeName = t.FullName, }; config.OnValueChanged(member); config.owner.OnValueChanged(); config.owner.MarkRepaint(); UpdateControl(); uNodeEditor.GUIChanged(); }, DropdownMenuAction.AlwaysEnabled); } } else if (config.type == typeof(Type)) { var mPos = NodeGraph.openedGraph.GetMousePosition(); evt.menu.AppendAction("Change Type", (e) => { TypeSelectorWindow.ShowWindow(mPos, new FilterAttribute() { OnlyGetType = true }, delegate(MemberData[] types) { uNodeEditorUtility.RegisterUndo(config.owner.targetNode); member.CopyFrom(types[0]); config.OnValueChanged(member); config.owner.OnValueChanged(); config.owner.MarkRepaint(); UpdateControl(); uNodeEditor.GUIChanged(); }, new TypeItem[1] { member }).targetObject = config.owner.targetNode; }, DropdownMenuAction.AlwaysEnabled); } if (!config.type.IsValueType) { evt.menu.AppendAction("To Null", (e) => { uNodeEditorUtility.RegisterUndo(config.owner.targetNode); member.CopyFrom(MemberData.Null); config.OnValueChanged(member); config.owner.OnValueChanged(); config.owner.MarkRepaint(); UpdateControl(); uNodeEditor.GUIChanged(); }, DropdownMenuAction.AlwaysEnabled); } } } }