public static void DrawDefaultListElementLabel(Rect area, SerializedProperty property, int index) { var r0 = new Rect(area.xMin, area.yMin, Mathf.Min(25f, area.width), EditorGUIUtility.singleLineHeight); var r1 = new Rect(r0.xMax, area.yMin, Mathf.Max(0f, area.width - r0.width), EditorGUIUtility.singleLineHeight); EditorGUI.LabelField(r0, index.ToString("00:")); EventTriggerTargetPropertyDrawer.DrawTriggerActivationTypeDropdown(r1, property, false); }
private void _targetList_DrawElement(Rect area, int index, bool isActive, bool isFocused) { var element = _targetList.serializedProperty.GetArrayElementAtIndex(index); var targProp = element.FindPropertyRelative(EventTriggerTargetPropertyDrawer.PROP_TRIGGERABLETARG); const float MARGIN = 1.0f; const float WEIGHT_FIELD_WIDTH = 60f; const float PERC_FIELD_WIDTH = 45f; const float FULLWEIGHT_WIDTH = WEIGHT_FIELD_WIDTH + PERC_FIELD_WIDTH; EditorGUI.BeginProperty(area, GUIContent.none, targProp); Rect trigRect; var actInfo = EventTriggerTargetPropertyDrawer.GetTriggerActivationInfo(element); GUIContent labelContent = EditorHelper.TempContent(index.ToString("00: ") + actInfo.ActivationTypeDisplayName); if (this.CustomizeEntryLabel != null) { this.CustomizeEntryLabel(labelContent, index); } if (_drawWeight && area.width > FULLWEIGHT_WIDTH) { var top = area.yMin + MARGIN; var labelRect = new Rect(area.xMin, top, EditorGUIUtility.labelWidth - FULLWEIGHT_WIDTH, EditorGUIUtility.singleLineHeight); var weightRect = new Rect(area.xMin + EditorGUIUtility.labelWidth - FULLWEIGHT_WIDTH, top, WEIGHT_FIELD_WIDTH, EditorGUIUtility.singleLineHeight); var percRect = new Rect(area.xMin + EditorGUIUtility.labelWidth - PERC_FIELD_WIDTH, top, PERC_FIELD_WIDTH, EditorGUIUtility.singleLineHeight); trigRect = new Rect(area.xMin + EditorGUIUtility.labelWidth, top, area.width - EditorGUIUtility.labelWidth, EditorGUIUtility.singleLineHeight); var weightProp = element.FindPropertyRelative(PROP_WEIGHT); float weight = weightProp.floatValue; EditorGUI.LabelField(labelRect, labelContent); weightProp.floatValue = EditorGUI.FloatField(weightRect, weight); float p = (_totalWeight > 0f) ? (100f * weight / _totalWeight) : ((index == 0) ? 100f : 0f); EditorGUI.LabelField(percRect, string.Format("{0:0.#}%", p)); } else { //Draw Triggerable - this is the simple case to make a clean designer set up for newbs var top = area.yMin + MARGIN; var labelRect = new Rect(area.xMin, top, area.width, EditorGUIUtility.singleLineHeight); trigRect = EditorGUI.PrefixLabel(labelRect, labelContent); } //Draw Triggerable - this is the simple case to make a clean designer set up for newbs EditorGUI.BeginChangeCheck(); var targObj = EventTriggerTargetPropertyDrawer.TargetObjectField(trigRect, GUIContent.none, targProp.objectReferenceValue); if (EditorGUI.EndChangeCheck()) { targProp.objectReferenceValue = EventTriggerTargetPropertyDrawer.IsValidTriggerTarget(targObj, actInfo.ActivationType) ? targObj : null; } EditorGUI.EndProperty(); ReorderableListHelper.DrawDraggableElementDeleteContextMenu(_targetList, area, index, isActive, isFocused); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); //Draw ActivationType Popup var r0 = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight); var act = EventTriggerTargetPropertyDrawer.DrawTriggerActivationTypeDropdown(r0, property, true); //Draw Advanced var area = new Rect(position.xMin, r0.yMax, position.width, position.height - r0.height); switch (act) { case TriggerActivationType.TriggerAllOnTarget: this.DrawAdvanced_TriggerAll(area, property); break; case TriggerActivationType.TriggerSelectedTarget: this.DrawAdvanced_TriggerSelected(area, property); break; case TriggerActivationType.SendMessage: this.DrawAdvanced_SendMessage(area, property); break; case TriggerActivationType.CallMethodOnSelectedTarget: this.DrawAdvanced_CallMethodOnSelected(area, property); break; case TriggerActivationType.EnableTarget: this.DrawAdvanced_EnableTarget(area, property); break; case TriggerActivationType.DestroyTarget: this.DrawAdvanced_DestroyTarget(area, property); break; } EditorGUI.EndProperty(); }