private void DragAction(Type actionType, string category) { DragAndDropManager.SetMode(DragAndDropManager.DragMode.AddAction); DragAndDrop.PrepareStartDrag(); DragAndDrop.set_objectReferences(new Object[0]); DragAndDrop.SetGenericData("AddAction", this.selectedAction); DragAndDrop.StartDrag("Drag Action"); Event.get_current().Use(); this.SelectAction(actionType, category); }
private void DoActionButton(string category, Type actionType) { string actionLabel = Labels.GetActionLabel(actionType); bool flag = actionType == this.selectedAction && category == this.selectedActionCategory; GUIStyle gUIStyle = flag ? SkillEditorStyles.ActionItemSelected : SkillEditorStyles.ActionItem; GUIStyle gUIStyle2 = flag ? SkillEditorStyles.ActionLabelSelected : SkillEditorStyles.ActionLabel; GUILayout.BeginHorizontal(gUIStyle, new GUILayoutOption[0]); int usageCount = Actions.GetUsageCount(actionType); string text = (usageCount > 0) ? string.Format(Strings.get_ActionSelector_Count_Postfix(), usageCount) : ""; float num = base.get_position().get_width() - 42f; if (usageCount > 0) { num -= gUIStyle2.CalcSize(new GUIContent(text)).x + 3f; } GUILayout.Label(actionLabel, gUIStyle2, new GUILayoutOption[] { GUILayout.MaxWidth(num) }); if (usageCount > 0) { GUILayout.FlexibleSpace(); GUILayout.Label(text, gUIStyle2, new GUILayoutOption[0]); } GUILayout.EndHorizontal(); Rect lastRect = GUILayoutUtility.GetLastRect(); if (this.mousePos.y > this.scrollPosition.y && this.mousePos.y < this.scrollPosition.y + this.scrollViewHeight && lastRect.Contains(this.mousePos)) { this.mouseOverAction = actionType; } if (this.mouseOverAction == actionType) { if (this.eventType == null) { this.SelectAction(actionType, category); if (Event.get_current().get_button() == 1 || EditorGUI.get_actionKey()) { this.GenerateActionContextMenu().ShowAsContext(); } if (Event.get_current().get_clickCount() > 1 && !FsmGraphView.EditingDisable) { this.AddSelectedActionToState(); this.addingAction = true; } GUIUtility.ExitGUI(); return; } if (!this.addingAction && this.eventType == 3) { this.DragAction(actionType, category); GUIUtility.ExitGUI(); return; } if (this.eventType == 1) { DragAndDropManager.Reset(); this.addingAction = false; } } if (flag) { this.beforeSelected = this.prevAction; this.beforeSelectedCategory = this.prevActionCategory; if (Event.get_current().get_type() == 7) { this.selectedRect = GUILayoutUtility.GetLastRect(); this.selectedRect.set_y(this.selectedRect.get_y() - (this.scrollPosition.y + 20f)); this.selectedRect.set_height(this.selectedRect.get_height() + 20f); } } if (this.prevActionWasSelected) { this.afterSelected = actionType; this.afterSelectedCategory = category; } this.prevAction = actionType; this.prevActionCategory = category; this.prevActionWasSelected = flag; }
public static void Reset() { DragAndDropManager.SetMode(DragAndDropManager.DragMode.None); DragAndDrop.SetGenericData("MoveActions", null); DragAndDrop.SetGenericData("AddAction", null); }