private void StartOnGUI(SerializedProperty property, GUIContent label) { _currentProp = property; _label = label; _currentKeysProp = _currentProp.FindPropertyRelative("_keys"); _currentValuesProp = _currentProp.FindPropertyRelative("_values"); _currentValuesProp.arraySize = _currentKeysProp.arraySize; _lst = CachedReorderableList.GetListDrawer(_memberLookupTable, _currentProp, _lst_DrawHeader, _lst_DrawElement, _lst_OnAdd, _lst_OnRemove, null, null, _lst_OnReorder); //_lst.draggable = false; _memberLookupTable.Clear(); for (int i = 0; i < _currentKeysProp.arraySize; i++) { _memberLookupTable.Add(i); } if (this.fieldInfo != null) { var attrib = this.fieldInfo.GetCustomAttributes(typeof(VariantCollection.AsPropertyListAttribute), false).FirstOrDefault() as VariantCollection.AsPropertyListAttribute; if (attrib != null && attrib.TargetType != null) { this.ConfigurePropertyList(attrib.TargetType); } } }
private void StartOnGUI(SerializedProperty property, GUIContent label) { var attrib = this.attribute as ReorderableArrayAttribute; if (attrib != null) { _disallowFoldout = attrib.DisallowFoldout; _removeBackgroundWhenCollapsed = attrib.RemoveBackgroundWhenCollapsed; _draggable = attrib.Draggable; _drawElementAtBottom = attrib.DrawElementAtBottom; _hideElementLabel = attrib.HideElementLabel; _childPropertyAsLabel = attrib.ChildPropertyToDrawAsElementLabel; _childPropertyAsEntry = attrib.ChildPropertyToDrawAsElementEntry; _elementLabelFormatString = attrib.ElementLabelFormatString; _elementPadding = attrib.ElementPadding; } _label = label; _lst = this.GetList(property, label); if (_lst.index >= _lst.count) { _lst.index = -1; } }
private void Init(SerializedProperty prop, GUIContent label) { _currentLabel = label; _targetList = CachedReorderableList.GetListDrawer(prop.FindPropertyRelative(PROP_TARGETS), _targetList_DrawHeader, _targetList_DrawElement, _targetList_OnAdd); if (!_customInspector) { if (this.fieldInfo != null) { var attribs = this.fieldInfo.GetCustomAttributes(typeof(SPEvent.ConfigAttribute), false) as SPEvent.ConfigAttribute[]; if (attribs != null && attribs.Length > 0) { _drawWeight = attribs[0].Weighted; _alwaysExpanded = attribs[0].AlwaysExpanded; } } else { _drawWeight = false; _alwaysExpanded = false; } } _triggerTargetDrawer.DrawWeight = _drawWeight; }
private CachedReorderableList GetList(SerializedProperty property, GUIContent label) { var lst = CachedReorderableList.GetListDrawer(property, _maskList_DrawHeader, _maskList_DrawElement); lst.draggable = _draggable; if (property.arraySize > 0) { if (_drawElementAtBottom) { lst.elementHeight = EditorGUIUtility.singleLineHeight; } else { var pchild = property.GetArrayElementAtIndex(0); if (_internalDrawer != null) { lst.elementHeight = _internalDrawer.GetPropertyHeight(pchild, label); } else { lst.elementHeight = SPEditorGUI.GetDefaultPropertyHeight(pchild, label) + 1f; } } } else { lst.elementHeight = EditorGUIUtility.singleLineHeight; } return(lst); }
private void BeginProperty(SerializedProperty property, GUIContent label) { var valuesProp = property.FindPropertyRelative(PROP_VALUES); _label = label; _lst = CachedReorderableList.GetListDrawer(valuesProp, _lst_DrawHeader, _lst_DrawElement); _lst.displayAdd = false; _lst.displayRemove = false; _lst.draggable = false; if (valuesProp.arraySize > 0) { var el = valuesProp.GetArrayElementAtIndex(0); if (OverridePropertyDrawer != null) { _lst.elementHeight = OverridePropertyDrawer.GetPropertyHeight(el, GUIContent.none); } else { _lst.elementHeight = SPEditorGUI.GetPropertyHeight(el); } } else { _lst.elementHeight = EditorGUIUtility.singleLineHeight; } }
private void StartOnGUI(SerializedProperty property, GUIContent label) { _currentProp = property; _label = label; _currentKeysProp = _currentProp.FindPropertyRelative("_keys"); _currentValuesProp = _currentProp.FindPropertyRelative("_values"); _currentValuesProp.arraySize = _currentKeysProp.arraySize; _lst = CachedReorderableList.GetListDrawer(_currentKeysProp, _lst_DrawHeader, _lst_DrawElement, _lst_OnAdd, _lst_OnRemove); //_lst.draggable = false; if (this.fieldInfo != null) { var attrib = this.fieldInfo.GetCustomAttributes(typeof(VariantCollection.AsPropertyListAttribute), false).FirstOrDefault() as VariantCollection.AsPropertyListAttribute; _propertyListTargetType = (attrib != null) ? attrib.TargetType : null; if (attrib != null && attrib.TargetType != null) { _propertyListTargetType = attrib.TargetType; _propertyListMembers = (from m in DynamicUtil.GetEasilySerializedMembersFromType(_propertyListTargetType, System.Reflection.MemberTypes.Field | System.Reflection.MemberTypes.Property, DynamicMemberAccess.Write) select m).ToArray(); _propertyListNames = (from m in _propertyListMembers select m.Name).ToArray(); } } }
private void Init(SerializedProperty property, GUIContent label) { _currentLabel = label; _maskList = CachedReorderableList.GetListDrawer(property.FindPropertyRelative("_masks"), _maskList_DrawHeader, _maskList_DrawElement); if (_maskList.index >= _maskList.count) { _maskList.index = -1; } }
private void StartOnGUI(SerializedProperty property, GUIContent label) { var attrib = this.attribute as ReorderableArrayAttribute; if (attrib != null) { _disallowFoldout = attrib.DisallowFoldout; _removeBackgroundWhenCollapsed = attrib.RemoveBackgroundWhenCollapsed; _draggable = attrib.Draggable; _drawElementAtBottom = attrib.DrawElementAtBottom; _hideElementLabel = attrib.HideElementLabel; _childPropertyAsLabel = attrib.ChildPropertyToDrawAsElementLabel; _childPropertyAsEntry = attrib.ChildPropertyToDrawAsElementEntry; _elementLabelFormatString = attrib.ElementLabelFormatString; _elementPadding = attrib.ElementPadding; _allowDragAndDrop = attrib.AllowDragAndDrop; if (!string.IsNullOrEmpty(attrib.OnAddCallback)) { _addCallback = (lst) => { lst.serializedProperty.arraySize++; lst.index = lst.serializedProperty.arraySize - 1; lst.serializedProperty.serializedObject.ApplyModifiedProperties(); var prop = lst.serializedProperty.GetArrayElementAtIndex(lst.index); var obj = EditorHelper.GetTargetObjectOfProperty(prop); obj = com.spacepuppy.Dynamic.DynamicUtil.InvokeMethod(lst.serializedProperty.serializedObject.targetObject, attrib.OnAddCallback, obj); EditorHelper.SetTargetObjectOfProperty(prop, obj); lst.serializedProperty.serializedObject.Update(); }; } else { _addCallback = null; } } _label = label; _lst = this.GetList(property, label); if (_lst.index >= _lst.count) { _lst.index = -1; } if (this.fieldInfo != null) { this.ElementType = TypeUtil.GetElementTypeOfListType(this.fieldInfo.FieldType); } }
protected virtual CachedReorderableList GetList(SerializedProperty property, GUIContent label) { var lst = CachedReorderableList.GetListDrawer(property, _maskList_DrawHeader, _maskList_DrawElement, _maskList_OnElementAdded); lst.draggable = _draggable; if (property.arraySize > 0) { if (_drawElementAtBottom) { lst.elementHeight = EditorGUIUtility.singleLineHeight; } else { var pchild = property.GetArrayElementAtIndex(0); /* * if (_internalDrawer != null) * { * lst.elementHeight = _internalDrawer.GetPropertyHeight(pchild, label); * } * else if (ElementIsFlatChildField(pchild)) * { * //we don't draw this way if it's a built-in type from Unity * pchild.isExpanded = true; * if (_hideElementLabel) * { * lst.elementHeight = SPEditorGUI.GetDefaultPropertyHeight(pchild, label, true) + 2f - EditorGUIUtility.singleLineHeight; * } * else * { * lst.elementHeight = SPEditorGUI.GetDefaultPropertyHeight(pchild, label, true) + 2f; //height when showing label * } * } * else * { * lst.elementHeight = SPEditorGUI.GetDefaultPropertyHeight(pchild, label) + 1f; * } */ lst.elementHeight = this.GetElementHeight(pchild, label, false) + 2f; } } else { lst.elementHeight = EditorGUIUtility.singleLineHeight; } return(lst); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { this.ConfigureSettings(); if (_disallowFoldout || property.isExpanded) { float h = 0f; var objProp = property.FindPropertyRelative(PROP_OBJ); var textProp = property.FindPropertyRelative(PROP_TEXT); var lst = CachedReorderableList.GetListDrawer(textProp, _maskList_DrawHeader, _maskList_DrawElement); lst.headerHeight = EditorGUIUtility.singleLineHeight + 2f; if (objProp.objectReferenceValue == null) { lst.displayAdd = true; lst.displayRemove = true; lst.elementHeight = EditorGUIUtility.singleLineHeight * TEXTSRC_AREA_LINES + EditorGUIUtility.singleLineHeight + 3f; h += lst.GetHeight(); } else if (objProp.objectReferenceValue is ITextSource) { var src = objProp.objectReferenceValue as ITextSource; int cnt = src.Count; textProp.arraySize = cnt; lst.displayAdd = false; lst.displayRemove = false; lst.elementHeight = EditorGUIUtility.singleLineHeight * TEXTSRC_AREA_LINES + EditorGUIUtility.singleLineHeight + 3f; h += lst.GetHeight(); } else if (objProp.objectReferenceValue is TextAsset) { textProp.arraySize = 1; lst.displayAdd = false; lst.displayRemove = false; lst.elementHeight = EditorGUIUtility.singleLineHeight * TEXTSRC_AREA_LINES + EditorGUIUtility.singleLineHeight + 3f; h += lst.GetHeight(); } return(h); } else { return(EditorGUIUtility.singleLineHeight); } }
private void StartOnGUI(SerializedProperty property, GUIContent label) { var attrib = this.attribute as ReorderableArrayAttribute; if (attrib != null) { _disallowFoldout = attrib.DisallowFoldout; _removeBackgroundWhenCollapsed = attrib.RemoveBackgroundWhenCollapsed; _draggable = attrib.Draggable; _drawElementAtBottom = attrib.DrawElementAtBottom; _hideElementLabel = attrib.HideElementLabel; _childPropertyAsLabel = attrib.ChildPropertyToDrawAsElementLabel; _childPropertyAsEntry = attrib.ChildPropertyToDrawAsElementEntry; _elementLabelFormatString = attrib.ElementLabelFormatString; _elementPadding = attrib.ElementPadding; _allowDragAndDrop = attrib.AllowDragAndDrop; _showTooltipInHeader = attrib.ShowTooltipInHeader; } _labelContent = label; _lst = this.GetList(property, label); if (_lst.index >= _lst.count) { _lst.index = -1; } if (this.fieldInfo != null) { this.DragDropElementType = TypeUtil.GetElementTypeOfListType(this.fieldInfo.FieldType); if (!string.IsNullOrEmpty(_childPropertyAsEntry) && this.DragDropElementType != null) { var field = this.DragDropElementType.GetMember(_childPropertyAsEntry, System.Reflection.MemberTypes.Field, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).FirstOrDefault() as System.Reflection.FieldInfo; if (field != null) { this.DragDropElementType = field.FieldType; } } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (EditorHelper.AssertMultiObjectEditingNotSupported(position, property, label)) { return; } if (Application.isPlaying) { GUI.enabled = false; } _property = property; GUI.Box(position, GUIContent.none); var r0 = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight); _matPropRefDrawer.OnGUI(r0, property, label); //because we mirror the properties of MaterialPropertyReference, this works position = new Rect(position.xMin, r0.yMax, position.width, position.height - r0.height); EditorGUI.indentLevel++; _valuesProp = property.FindPropertyRelative(PROP_VALUES); var lst = CachedReorderableList.GetListDrawer(_valuesProp, _valuesList_DrawHeader, _valuesList_DrawElement); lst.headerHeight = 0f; lst.elementHeight = EditorGUIUtility.singleLineHeight; var r2 = new Rect(position.xMin, position.yMin, position.width, lst.GetHeight()); var r3 = new Rect(position.xMin, position.yMax - EditorGUIUtility.singleLineHeight * 1.25f, position.width, EditorGUIUtility.singleLineHeight); lst.DoList(EditorGUI.IndentedRect(r2)); EditorGUI.PropertyField(r3, property.FindPropertyRelative(PROP_POSITION)); EditorGUI.indentLevel--; _property = null; _valuesProp = null; if (Application.isPlaying) { GUI.enabled = true; } }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { float h; if (EditorHelper.AssertMultiObjectEditingNotSupportedHeight(property, label, out h)) { return(h); } var valuesProp = property.FindPropertyRelative(PROP_VALUES); var lst = CachedReorderableList.GetListDrawer(valuesProp, _valuesList_DrawHeader, _valuesList_DrawElement); lst.headerHeight = 1f; lst.elementHeight = EditorGUIUtility.singleLineHeight; h = lst.GetHeight(); h += EditorGUIUtility.singleLineHeight * 2.5f; //material line, position slider, and a small padding return(h); }
private void OnGUIEnd() { if (_lst != null) { _lst.serializedProperty = null; } if (_textProp != null) { if (_mode != Mode.Text) { _textProp.arraySize = 0; } } _lst = null; _textProp = null; _objProp = null; _label = null; _mode = Mode.Text; }
private CachedReorderableList GetList(SerializedProperty property, GUIContent label) { var lst = CachedReorderableList.GetListDrawer(property, _maskList_DrawHeader, _maskList_DrawElement, _addCallback); lst.draggable = _draggable; if (property.arraySize > 0) { if (_drawElementAtBottom) { lst.elementHeight = EditorGUIUtility.singleLineHeight; } else { var pchild = property.GetArrayElementAtIndex(0); if (_internalDrawer != null) { lst.elementHeight = _internalDrawer.GetPropertyHeight(pchild, label); } else if (pchild.hasChildren && pchild.objectReferenceValue is MonoBehaviour) { //we don't draw this way if it's a built-in type from Unity lst.elementHeight = SPEditorGUI.GetDefaultPropertyHeight(pchild, label, true) + 2f; } else { lst.elementHeight = SPEditorGUI.GetDefaultPropertyHeight(pchild, label) + 1f; } } } else { lst.elementHeight = EditorGUIUtility.singleLineHeight; } return(lst); }
private void OnGUIStart(SerializedProperty property, GUIContent label) { _textProp = property.FindPropertyRelative(PROP_TEXT); _objProp = property.FindPropertyRelative(PROP_OBJ); _label = label; _lst = CachedReorderableList.GetListDrawer(_textProp, _maskList_DrawHeader, _maskList_DrawElement); _lst.headerHeight = EditorGUIUtility.singleLineHeight + 2f; if (_objProp.objectReferenceValue == null) { _mode = Mode.Text; _lst.displayAdd = true; _lst.displayRemove = true; _lst.elementHeight = EditorGUIUtility.singleLineHeight * TEXTSRC_AREA_LINES + EditorGUIUtility.singleLineHeight + 3f; } else if (_objProp.objectReferenceValue is ITextSource) { _mode = Mode.TextSource; var src = _objProp.objectReferenceValue as ITextSource; int cnt = src.Count; _textProp.arraySize = cnt; _lst.displayAdd = false; _lst.displayRemove = false; _lst.elementHeight = EditorGUIUtility.singleLineHeight * TEXTSRC_AREA_LINES + EditorGUIUtility.singleLineHeight + 3f; } else if (_objProp.objectReferenceValue is TextAsset) { _mode = Mode.TextAsset; _textProp.arraySize = 1; _lst.displayAdd = false; _lst.displayRemove = false; _lst.elementHeight = EditorGUIUtility.singleLineHeight * TEXTSRC_AREA_LINES + EditorGUIUtility.singleLineHeight + 3f; } }
private void Init(SerializedProperty property, GUIContent label, bool searchForAttribs) { _target = EditorHelper.GetTargetObjectOfProperty(property) as SPAnimClipCollection; _currentLabel = label; _defaultLayer = 0; _isStaticColl = false; _hideDetailRegion = false; _animList = CachedReorderableList.GetListDrawer(property.FindPropertyRelative(PROP_ANIMSTATES), _animList_DrawHeader, _animList_DrawElement, _animList_OnAdded, null, _animList_OnSelect); if (_animList.index >= _animList.count) { _animList.index = -1; } if (searchForAttribs && this.fieldInfo != null) { //config var configAttrib = this.fieldInfo.GetCustomAttributes(typeof(SPAnimClipCollection.ConfigAttribute), false).FirstOrDefault() as SPAnimClipCollection.ConfigAttribute; if (configAttrib != null) { _hideDetailRegion = configAttrib.HideDetailRegion; _defaultLayer = configAttrib.DefaultLayer; _entryPrefix = configAttrib.Prefix; if (!string.IsNullOrEmpty(configAttrib.Hash)) { _currentLabel.text = string.Format("{0} - ({1})", _currentLabel.text, configAttrib.Hash); } } else { _entryPrefix = null; } var staticCollAttrib = this.fieldInfo.GetCustomAttributes(typeof(SPAnimClipCollection.StaticCollectionAttribute), false).FirstOrDefault() as SPAnimClipCollection.StaticCollectionAttribute; if (staticCollAttrib != null) { _isStaticColl = true; var statesProp = property.FindPropertyRelative(PROP_ANIMSTATES); int cnt = staticCollAttrib.Names.Length; if (statesProp.arraySize > cnt) { statesProp.arraySize = cnt; } else if (statesProp.arraySize < cnt) { int sz = statesProp.arraySize; statesProp.arraySize = cnt; for (int i = sz; i < cnt; i++) { var stateProp = statesProp.GetArrayElementAtIndex(i); stateProp.FindPropertyRelative("_name").stringValue = staticCollAttrib.Names[i]; stateProp.FindPropertyRelative("_clip").objectReferenceValue = null; stateProp.FindPropertyRelative("_weight").floatValue = 1f; stateProp.FindPropertyRelative("_speed").floatValue = 1f; stateProp.FindPropertyRelative("_layer").intValue = _defaultLayer; stateProp.FindPropertyRelative("_wrapMode").intValue = 0; stateProp.FindPropertyRelative("_blendMode").intValue = 0; stateProp.FindPropertyRelative(PROP_ANIMSTATE_MASKS).arraySize = 0; } } for (int i = 0; i < statesProp.arraySize; i++) { statesProp.GetArrayElementAtIndex(i).FindPropertyRelative("_name").stringValue = staticCollAttrib.Names[i]; } _animList.displayAdd = false; _animList.displayRemove = false; _animList.draggable = false; if (_animList.index >= cnt) { _animList.index = cnt - 1; } } else { _isStaticColl = false; _animList.displayAdd = true; _animList.displayRemove = true; _animList.draggable = true; } } }
private void StartOnGUI(SerializedProperty property, GUIContent label) { var attrib = this.attribute as ReorderableArrayAttribute; if (attrib != null) { _disallowFoldout = attrib.DisallowFoldout; _removeBackgroundWhenCollapsed = attrib.RemoveBackgroundWhenCollapsed; _draggable = attrib.Draggable; _drawElementAtBottom = attrib.DrawElementAtBottom; _hideElementLabel = attrib.HideElementLabel; _childPropertyAsLabel = attrib.ChildPropertyToDrawAsElementLabel; _childPropertyAsEntry = attrib.ChildPropertyToDrawAsElementEntry; _allowDragAndDrop = attrib.AllowDragAndDrop; _showTooltipInHeader = attrib.ShowTooltipInHeader; if (!string.IsNullOrEmpty(attrib.OnAddCallback)) { _addCallback = (lst) => { lst.serializedProperty.arraySize++; lst.index = lst.serializedProperty.arraySize - 1; lst.serializedProperty.serializedObject.ApplyModifiedProperties(); var prop = lst.serializedProperty.GetArrayElementAtIndex(lst.index); var obj = EditorHelper.GetTargetObjectOfProperty(prop); obj = com.spacepuppy.Dynamic.DynamicUtil.InvokeMethod(lst.serializedProperty.serializedObject.targetObject, attrib.OnAddCallback, obj); EditorHelper.SetTargetObjectOfProperty(prop, obj); lst.serializedProperty.serializedObject.Update(); }; } else { _addCallback = null; } } _labelContent = label; _lst = this.GetList(property, label); if (_lst.index >= _lst.count) { _lst.index = -1; } if (this.fieldInfo != null) { this.DragDropElementType = TypeUtil.GetElementTypeOfListType(this.fieldInfo.FieldType); if (!string.IsNullOrEmpty(_childPropertyAsEntry) && this.DragDropElementType != null) { var field = this.DragDropElementType.GetMember(_childPropertyAsEntry, System.Reflection.MemberTypes.Field, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).FirstOrDefault() as System.Reflection.FieldInfo; if (field != null) { this.DragDropElementType = field.FieldType; } } } }