本文整理汇总了C#中UnityEditorInternal.ReorderableList类的典型用法代码示例。如果您正苦于以下问题:C# ReorderableList类的具体用法?C# ReorderableList怎么用?C# ReorderableList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReorderableList类属于UnityEditorInternal命名空间,在下文中一共展示了ReorderableList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTag
protected virtual void AddTag(ReorderableList list) {
int index = list.serializedProperty.arraySize;
list.serializedProperty.arraySize++;
list.index = index;
var newElement = property.GetArrayElementAtIndex(index);
newElement.FindPropertyRelative("name").stringValue = "New Tag";
}
示例2: OnEnable
void OnEnable()
{
_targetList = new ReorderableList(this.serializedObject, this.serializedObject.FindProperty(PROP_TARGETS), true, true, true, true);
_targetList.drawHeaderCallback = _targetList_DrawHeader;
_targetList.drawElementCallback = _targetList_DrawElement;
_targetList.onAddCallback = _targetList_OnAdd;
}
示例3: StartOnGUI
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();
}
}
}
示例4: OnEnable
public void OnEnable() {
data = (InkLibrary) target;
list = new ReorderableList(data.inkLibrary, typeof(InkFile), false, true, false, false);
// list.elementHeight = 60;
list.drawHeaderCallback = (Rect rect) => {
EditorGUI.LabelField(rect, "Ink Library");
};
list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
InkFile inkFile = ((List<InkFile>)list.list)[index];
Rect objectFieldRect = new Rect(rect.x, rect.y, rect.width - 80, rect.height-4);
if(!inkFile.isMaster) {
objectFieldRect.x += 14;
objectFieldRect.width -= 14;
}
Rect selectRect = new Rect(objectFieldRect.xMax, rect.y, 80, rect.height-4);
// Rect titleRect = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
// Rect inkAssetRect = new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight * 1, rect.width, EditorGUIUtility.singleLineHeight);
// Rect jsonAssetRect = new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight * 2, rect.width, EditorGUIUtility.singleLineHeight);
//
// inkFile.compileAutomatically = EditorGUI.Toggle(titleRect, "Compile Automatically", inkFile.compileAutomatically);
EditorGUI.BeginDisabledGroup(true);
inkFile.inkAsset = EditorGUI.ObjectField(objectFieldRect, inkFile.inkAsset, typeof(DefaultAsset)) as DefaultAsset;
EditorGUI.EndDisabledGroup();
if(GUI.Button(selectRect, "Select")) {
Selection.activeObject = inkFile.inkAsset;
}
// inkFile.jsonAsset = EditorGUI.ObjectField(jsonAssetRect, new GUIContent("JSON File"), inkFile.jsonAsset, typeof(TextAsset)) as TextAsset;
};
}
示例5: OnEnable
protected virtual void OnEnable()
{
hideFlags = HideFlags.HideAndDontSave;
instance = target as Gesture;
advanced = serializedObject.FindProperty("advancedProps");
friendlyGestures = serializedObject.FindProperty("friendlyGestures");
requireGestureToFail = serializedObject.FindProperty("requireGestureToFail");
combineTouches = serializedObject.FindProperty("combineTouches");
combineTouchesInterval = serializedObject.FindProperty("combineTouchesInterval");
useSendMessage = serializedObject.FindProperty("useSendMessage");
sendMessageTarget = serializedObject.FindProperty("sendMessageTarget");
sendStateChangeMessages = serializedObject.FindProperty("sendStateChangeMessages");
friendlyGesturesList = new ReorderableList(serializedObject, friendlyGestures, false, false, false, true);
friendlyGesturesList.headerHeight = 0;
friendlyGesturesList.drawElementCallback += (rect, index, active, focused) =>
{
rect.height = 16;
var gesture = friendlyGestures.GetArrayElementAtIndex(index).objectReferenceValue as Gesture;
if (gesture == null)
{
// Killing null elements.
indexToRemove = index;
EditorGUI.LabelField(rect, GUIContent.none);
return;
}
EditorGUI.LabelField(rect, string.Format("{0} @ {1}", gesture.GetType().Name, gesture.name), GUIElements.BoxLabelStyle);
};
friendlyGesturesList.onRemoveCallback += list => { indexToRemove = list.index; };
}
示例6: OnAddItem
private void OnAddItem(ReorderableList list)
{
ReorderableList.defaultBehaviours.DoAddButton(list);
SerializedProperty col = colorsProperty.GetArrayElementAtIndex(list.index);
col.colorValue = Color.white;
}
示例7: AddToSortLayerList
private void AddToSortLayerList(ReorderableList list)
{
base.serializedObject.ApplyModifiedProperties();
InternalEditorUtility.AddSortingLayer();
base.serializedObject.Update();
list.index = list.serializedProperty.arraySize - 1;
}
示例8: OnEnable
public void OnEnable()
{
prop_FontAsset = serializedObject.FindProperty("fontAsset");
prop_SpriteAsset = serializedObject.FindProperty("spriteAsset");
prop_StyleSheet = serializedObject.FindProperty("styleSheet");
m_list = new ReorderableList(serializedObject, serializedObject.FindProperty("fallbackFontAssets"), true, true, true, true);
m_list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
{
var element = m_list.serializedProperty.GetArrayElementAtIndex(index);
rect.y += 2;
EditorGUI.PropertyField( new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), element, GUIContent.none);
};
m_list.drawHeaderCallback = rect =>
{
EditorGUI.LabelField(rect, "<b>Fallback Font Asset List</b>", TMP_UIStyleManager.Label);
};
prop_WordWrapping = serializedObject.FindProperty("enableWordWrapping");
prop_Kerning = serializedObject.FindProperty("enableKerning");
prop_ExtraPadding = serializedObject.FindProperty("enableExtraPadding");
prop_TintAllSprites = serializedObject.FindProperty("enableTintAllSprites");
prop_WarningsDisabled = serializedObject.FindProperty("warningsDisabled");
// Get the UI Skin and Styles for the various Editors
TMP_UIStyleManager.GetUIStyles();
}
示例9: AddButton
public void AddButton(Rect rect, ReorderableList list)
{
GenericMenu menu = new GenericMenu();
menu.AddItem(new GUIContent("Add Motion Field"), false, new GenericMenu.MenuFunction(this.AddChildAnimation));
menu.AddItem(EditorGUIUtility.TempContent("New Blend Tree"), false, new GenericMenu.MenuFunction(this.AddBlendTreeCallback));
menu.Popup(rect, 0);
}
示例10: OnEnable
protected virtual void OnEnable()
{
// String Tables property
stringTablesProp = serializedObject.FindProperty("stringTables");
stringTablesList = new ReorderableList(serializedObject, stringTablesProp, true, true, true, true);
stringTablesList.drawHeaderCallback = (Rect rect) => {
EditorGUI.LabelField(rect, "String Tables");
};
stringTablesList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
Rect r = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
SerializedProperty element = stringTablesProp.GetArrayElementAtIndex(index);
EditorGUI.PropertyField(r, element, new GUIContent(""));
};
// Register Types property
registerTypesProp = serializedObject.FindProperty("registerTypes");
registerTypeList = new ReorderableList(serializedObject, registerTypesProp, true, true, true, true);
registerTypeList.drawHeaderCallback = (Rect rect) => {
EditorGUI.LabelField(rect, "Type Lists");
};
registerTypeList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
Rect r = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
SerializedProperty element = registerTypesProp.GetArrayElementAtIndex(index);
EditorGUI.PropertyField(r, element, new GUIContent(""));
};
}
示例11: OnEnable
private void OnEnable()
{
instance = target as TouchManager;
layers = serializedObject.FindProperty("layers");
displayDevice = serializedObject.FindProperty("displayDevice");
useSendMessage = serializedObject.FindProperty("useSendMessage");
sendMessageTarget = serializedObject.FindProperty("sendMessageTarget");
sendMessageEvents = serializedObject.FindProperty("sendMessageEvents");
refresh();
layersList = new ReorderableList(serializedObject, layers, true, true, false, false);
layersList.drawHeaderCallback += rect => GUI.Label(rect, LAYERS_HEADER);
layersList.drawElementCallback += (rect, index, active, focused) =>
{
rect.height = 16;
rect.y += 2;
if (index >= layers.arraySize) return;
var layer = layers.GetArrayElementAtIndex(index).objectReferenceValue as TouchLayer;
if (layer == null)
{
EditorGUI.LabelField(rect, "null");
return;
}
EditorGUI.LabelField(rect, layer.Name);
};
}
示例12: GetListDrawer
public static CachedReorderableList GetListDrawer(SerializedProperty property, ReorderableList.HeaderCallbackDelegate drawHeaderCallback, ReorderableList.ElementCallbackDelegate drawElementCallback,
ReorderableList.AddCallbackDelegate onAddCallback = null, ReorderableList.RemoveCallbackDelegate onRemoveCallback = null, ReorderableList.SelectCallbackDelegate onSelectCallback = null,
ReorderableList.ChangedCallbackDelegate onChangedCallback = null, ReorderableList.ReorderCallbackDelegate onReorderCallback = null, ReorderableList.CanRemoveCallbackDelegate onCanRemoveCallback = null,
ReorderableList.AddDropdownCallbackDelegate onAddDropdownCallback = null)
{
if (property == null) throw new System.ArgumentNullException("property");
if (!property.isArray) throw new System.ArgumentException("SerializedProperty must be a property for an Array or List", "property");
int hash = com.spacepuppyeditor.Internal.PropertyHandlerCache.GetPropertyHash(property);
CachedReorderableList lst;
if (_lstCache.TryGetValue(hash, out lst))
{
lst.serializedProperty = property;
}
else
{
lst = new CachedReorderableList(property.serializedObject, property);
_lstCache[hash] = lst;
}
lst.drawHeaderCallback = drawHeaderCallback;
lst.drawElementCallback = drawElementCallback;
lst.onAddCallback = onAddCallback;
lst.onRemoveCallback = onRemoveCallback;
lst.onSelectCallback = onSelectCallback;
lst.onChangedCallback = onChangedCallback;
lst.onReorderCallback = onReorderCallback;
lst.onCanRemoveCallback = onCanRemoveCallback;
lst.onAddDropdownCallback = onAddDropdownCallback;
return lst;
}
示例13: RecreateListControl
public void RecreateListControl()
{
if ((UnityEngine.Object) this.m_Controller == (UnityEngine.Object) null)
return;
this.m_Views = new List<MixerGroupView>((IEnumerable<MixerGroupView>) this.m_Controller.views);
if (this.m_Views.Count == 0)
{
this.m_Views.Add(new MixerGroupView()
{
guids = this.m_Controller.GetAllAudioGroupsSlow().Select<AudioMixerGroupController, GUID>((Func<AudioMixerGroupController, GUID>) (gr => gr.groupID)).ToArray<GUID>(),
name = "View"
});
this.SaveToBackend();
}
ReorderableList list = new ReorderableList((IList) this.m_Views, typeof (MixerGroupView), true, false, false, false);
list.onReorderCallback += new ReorderableList.ReorderCallbackDelegate(this.EndDragChild);
list.elementHeight = 16f;
list.headerHeight = 0.0f;
list.footerHeight = 0.0f;
list.showDefaultBackground = false;
list.index = this.m_Controller.currentViewIndex;
if (this.m_Controller.currentViewIndex >= list.count)
Debug.LogError((object) ("State mismatch, currentViewIndex: " + (object) this.m_Controller.currentViewIndex + ", num items: " + (object) list.count));
this.m_ReorderableListWithRenameAndScrollView = new ReorderableListWithRenameAndScrollView(list, this.m_State);
this.m_ReorderableListWithRenameAndScrollView.onSelectionChanged += new System.Action<int>(this.SelectionChanged);
this.m_ReorderableListWithRenameAndScrollView.onNameChangedAtIndex += new System.Action<int, string>(this.NameChanged);
this.m_ReorderableListWithRenameAndScrollView.onDeleteItemAtIndex += new System.Action<int>(this.Delete);
this.m_ReorderableListWithRenameAndScrollView.onGetNameAtIndex += new Func<int, string>(this.GetNameOfElement);
this.m_ReorderableListWithRenameAndScrollView.onCustomDrawElement += new ReorderableList.ElementCallbackDelegate(this.CustomDrawElement);
}
示例14: OnEnable
protected virtual void OnEnable(){
database = ItemDatabase.Load ();
parameterTypeNames = TypeUtility.GetSubTypeNames (typeof(FsmVariable));
parameterTypeNames = ArrayUtility.Insert<string> (parameterTypeNames, "None", 0);
customDataList = new ReorderableList(serializedObject,
serializedObject.FindProperty("customData"),
true, true, true, true);
customDataList.elementHeight = EditorGUIUtility.singleLineHeight * 3+10;
customDataList.onRemoveCallback = (ReorderableList list) => {
list.serializedProperty.serializedObject.Update();
DestroyImmediate(list.serializedProperty.GetArrayElementAtIndex(list.index).objectReferenceValue,true);
AssetDatabase.SaveAssets();
list.serializedProperty.DeleteArrayElementAtIndex(list.index);
list.serializedProperty.serializedObject.ApplyModifiedProperties();
};
customDataList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
var element = customDataList.serializedProperty.GetArrayElementAtIndex(index);
FsmVariable variable = element.objectReferenceValue as FsmVariable;
rect.y+=2;
int m = parameterTypeNames.ToList ().FindIndex (x => x == (variable!= null?variable.GetType ().Name:""));
m = Mathf.Clamp (m, 0, int.MaxValue);
rect.height=EditorGUIUtility.singleLineHeight;
m = EditorGUI.Popup (rect,"Parameter Type", m, parameterTypeNames);
string typeName=parameterTypeNames [m];
string variableTypeName = (variable == null ? "None" : variable.GetType ().Name);
if(typeName != variableTypeName){
DestroyImmediate(element.objectReferenceValue,true);
if(typeName != "None"){
variable = ScriptableObject.CreateInstance (TypeUtility.GetTypeByName(typeName)[0]) as FsmVariable;
variable.hideFlags = HideFlags.HideInHierarchy;
if (EditorUtility.IsPersistent (element.serializedObject.targetObject)) {
AssetDatabase.AddObjectToAsset (variable, element.serializedObject.targetObject);
AssetDatabase.SaveAssets ();
}
element.serializedObject.Update();
element.objectReferenceValue = variable;
element.serializedObject.ApplyModifiedProperties ();
}
}
if(variable != null){
SerializedObject mVariable=new SerializedObject(variable);
mVariable.Update();
rect.y+=EditorGUIUtility.singleLineHeight+2;
EditorGUI.PropertyField(rect,mVariable.FindProperty("name"));
rect.y+=EditorGUIUtility.singleLineHeight+2;
EditorGUI.PropertyField(rect,mVariable.FindProperty("value"));
mVariable.ApplyModifiedProperties();
}
};
customDataList.drawHeaderCallback = (Rect rect) => {
EditorGUI.LabelField(rect, "Custom Data");
};
}
示例15: GetList
private ReorderableList GetList(SerializedProperty property) {
if (reorderableList != null) return reorderableList;
reorderableList = new ReorderableList(property.serializedObject, property, true, true, true, true);
reorderableList.drawElementCallback += DrawElement;
reorderableList.drawHeaderCallback += DrawHeader;
reorderableList.onAddCallback += AddTag;
return reorderableList;
}