private System.Collections.Generic.List <string> GetModules(FeatureBase feature) { if (this.cacheModules.TryGetValue(feature, out var list) == false) { list = new System.Collections.Generic.List <string>(); var script = MonoScript.FromScriptableObject(feature); var text = script.text; var matches = System.Text.RegularExpressions.Regex.Matches(text, @"AddModule\s*\<(.*?)\>"); foreach (System.Text.RegularExpressions.Match match in matches) { if (match.Groups.Count > 0) { var systemType = match.Groups[1].Value; var spl = systemType.Split('.'); systemType = spl[spl.Length - 1]; list.Add(systemType); } } this.cacheModules.Add(feature, list); } return(list); }
private void OnEnable() { _messageHandlersList = new UnityEditorInternal.ReorderableList(this.serializedObject, this.serializedObject.FindProperty(PROP_MSGHANDLERS)); _messageHandlersList.elementHeight = EditorGUIUtility.singleLineHeight; _messageHandlersList.drawHeaderCallback = _lst_DrawHeader; _messageHandlersList.drawElementCallback = _lst_DrawElement; }
private void OnReorderItems(UnityEditorInternal.ReorderableList reorderableList, int oldindex, int newindex) { var list = this.lists[oldindex]; this.lists[oldindex] = this.lists[newindex]; this.lists[newindex] = list; }
public void GenerateList(FieldInspector fieldInspector) { List = new UReorderableList(fieldInspector.Property.serializedObject, fieldInspector.Property, true, true, true, true); List.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, string.Format("{0}: {1}", fieldInspector.Label, fieldInspector.Property.arraySize), EditorStyles.boldLabel); }; List.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { SerializedProperty element = fieldInspector.Property.GetArrayElementAtIndex(index); rect.x += 10; rect.y += 2; rect.width -= 10; EditorGUI.PropertyField(rect, element, true); }; List.drawElementBackgroundCallback = (Rect rect, int index, bool isActive, bool isFocused) => { if (Event.current.type == EventType.Repaint) { GUIStyle gUIStyle = (index % 2 != 0) ? "CN EntryBackEven" : "CN EntryBackodd"; gUIStyle = (!isActive && !isFocused) ? gUIStyle : "RL Element"; rect.x += 2; rect.width -= 6; gUIStyle.Draw(rect, false, isActive, isActive, isFocused); } }; List.elementHeightCallback = (int index) => { return(EditorGUI.GetPropertyHeight(fieldInspector.Property.GetArrayElementAtIndex(index)) + 6); }; }
public override void OnGUI(UnityEngine.Rect position, SerializedProperty property, UnityEngine.GUIContent label) { ReorderableListAttribute attr = attribute as ReorderableListAttribute; string tooltip = (attr == null ? string.Empty : attr.Tooltip); UnityEditorInternal.ReorderableList list = GetList(property); float height; if (list.serializedProperty.arraySize == 0) { height = 20.0f; } else { height = 0.0f; for (var i = 0; i < list.serializedProperty.arraySize; i++) { height = Mathf.Max(height, EditorGUI.GetPropertyHeight(list.serializedProperty.GetArrayElementAtIndex(i))); } } list.drawHeaderCallback = (Rect r) => { EditorGUI.LabelField(r, new GUIContent(label.text, tooltip)); }; list.elementHeight = height; list.DoList(position); }
public override void Initialize(Config config) { Type[] types = null; try { types = CodeGeneratorUtil.LoadTypesFromCodeGeneratorAssemblies(); } catch (Exception ex) { _configException = ex; } if (_configException == null) { var defaultEnabledDataProviderNames = initPhase <ICodeGeneratorDataProvider>(types, out _availableDataProviderTypes, out _availableDataProviderNames); var defaultEnabledGeneratorNames = initPhase <ICodeGenerator>(types, out _availableGeneratorTypes, out _availableGeneratorNames); var defaultEnabledPostProcessorNames = initPhase <ICodeGenFilePostProcessor>(types, out _availablePostProcessorTypes, out _availablePostProcessorNames); _codeGeneratorConfig = new CodeGeneratorConfig(config, defaultEnabledDataProviderNames, defaultEnabledGeneratorNames, defaultEnabledPostProcessorNames); _contexts = new List <string>(_codeGeneratorConfig.contexts); _contextList = new UnityEditorInternal.ReorderableList(_contexts, typeof(string), true, true, true, true); _contextList.drawHeaderCallback = rect => EditorGUI.LabelField(rect, "Contexts"); _contextList.drawElementCallback = (rect, index, isActive, isFocused) => { rect.width -= 20; _contexts[index] = EditorGUI.TextField(rect, _contexts[index]); }; _contextList.onAddCallback = list => list.list.Add("New Context"); _contextList.onCanRemoveCallback = list => list.count > 1; _contextList.onChangedCallback = list => GUI.changed = true; } }
private void OnEnable() { // Testing entries /* * layers.Add(new AnimatorLayer("Test 1", new List<AnimatorState>())); * layers.Add(new AnimatorLayer("Test 2", new List<AnimatorState>())); * layers.Add(new AnimatorLayer("Test 3", new List<AnimatorState>())); * * inputs.Add(new AnimatorInput()); * inputs.Add(new AnimatorInput()); * inputs.Add(new AnimatorInput()); */ inputlist = new ReorderableList(inputs, typeof(Input)); inputlist.drawElementCallback += DrawInputElementCallback; inputlist.elementHeightCallback += InputElementHeightCallback; inputlist.onAddCallback += ONInputAddCallback; inputlist.headerHeight = 0; layerlist = new ReorderableList(layers, typeof(AnimatorLayer)); layerlist.drawElementCallback += DrawLayerElementCallback; layerlist.elementHeightCallback += LayerElementHeightCallback; layerlist.onAddCallback += ONLayerAddCallback; layerlist.headerHeight = 0; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (this.list == null) { var items = property.FindPropertyRelative("items"); this.list = new UnityEditorInternal.ReorderableList(property.serializedObject, items, true, false, true, true); this.list.drawHeaderCallback = (rect) => { GUI.Label(rect, label); }; this.list.onAddCallback = (list) => { items.arraySize = items.arraySize + 1; items.GetArrayElementAtIndex(items.arraySize - 1).objectReferenceValue = null; }; this.list.drawElementCallback = (rect, index, active, focused) => { EditorGUI.PropertyField(rect, items.GetArrayElementAtIndex(index), label, true); }; this.list.onRemoveCallback = (list) => { var idx = list.index; var item = items.GetArrayElementAtIndex(idx); if (item.objectReferenceValue != null) { Object.DestroyImmediate(item.objectReferenceValue, true); } items.DeleteArrayElementAtIndex(idx); }; } this.list.DoList(position); }
private void OnRemoveItem(UnityEditorInternal.ReorderableList reorderableList) { var idx = this.listCategories.index; this.lists.RemoveAt(idx); this.listCategories.list.RemoveAt(idx); }
public override void EditItem(EquipmentType item, int itemIndex) { base.EditItem(item, itemIndex); _equipmentHandlerDrawer = ReflectionDrawerUtility.BuildEditorHierarchy(ReflectionUtility.GetFieldInherited(item.GetType(), "equipmentHandler"), item); _restrictionList = new UnityEditorInternal.ReorderableList(selectedItem.blockTypes, typeof(int), false, true, true, true); _restrictionList.drawHeaderCallback += rect => GUI.Label(rect, "Restrictions"); _restrictionList.drawElementCallback += (rect, index, active, focused) => { rect.height = 16; rect.y += 2; rect.width -= 30; rect.x += 30; // Some selection room if (index < 0 || index >= selectedItem.blockTypes.Length) { return; } // Trying to block self, not allowed. if (selectedItem.blockTypes[index] == selectedItem) { var t = rect; t.width = 200; GUI.backgroundColor = Color.red; EditorGUI.LabelField(t, "Can't block self"); rect.x += 205; // +5 for margin rect.width -= 205; } ObjectPickerUtility.RenderObjectPickerForType(rect, string.Empty, selectedItem.blockTypes[index], typeof(EquipmentType), (val) => { selectedItem.blockTypes[index] = (EquipmentType)val; }); GUI.backgroundColor = Color.white; }; _restrictionList.onAddCallback += list => { var l = new List <EquipmentType>(selectedItem.blockTypes); l.Add(null); selectedItem.blockTypes = l.ToArray(); list.list = selectedItem.blockTypes; window.Repaint(); }; _restrictionList.onRemoveCallback += list => { // Remove the element itself var l = new List <EquipmentType>(selectedItem.blockTypes); l.RemoveAt(list.index); selectedItem.blockTypes = l.ToArray(); list.list = selectedItem.blockTypes; window.Repaint(); }; }
private void OnAddAnimation(UnityEditorInternal.ReorderableList list) { AnimationClip selectedAnimation = null; if (list.index >= 0 && list.index < list.list.Count) { selectedAnimation = list.list[list.index] as AnimationClip; } if (selectedAnimation != null) { var selectedPath = AssetDatabase.GetAssetPath(selectedAnimation); var newAnimation = Object.Instantiate(selectedAnimation); AssetDatabase.AddObjectToAsset(newAnimation, target); AssetDatabase.SaveAssets(); AssetDatabase.ImportAsset(selectedPath); } else { var clip = AnimatorController.AllocateAnimatorClip("New Clip"); AssetDatabase.AddObjectToAsset(clip, target); AssetDatabase.SaveAssets(); } }
void DoAddParameterLinkMenu(Rect rect, UnityEditorInternal.ReorderableList list) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("All"), false, () => { foreach (EditorParamRef parameter in missingParameterAutomations) { AddParameterAutomation(parameter.Name); } }); menu.AddSeparator(string.Empty); foreach (EditorParamRef parameter in missingParameterAutomations) { string text = parameter.Name; if (InitialParameterValueExists(parameter.Name)) { text += " (has initial value)"; } menu.AddItem(new GUIContent(text), false, (userData) => { AddParameterAutomation(userData as string); }, parameter.Name); } menu.DropDown(rect); }
//returns a reorderable list with an edit button linked to an editor window protected UnityEditorInternal.ReorderableList GetDefaultEditButtonList(SerializedProperty sentProperty, string sentLabel) { //create reorderable list UnityEditorInternal.ReorderableList reorderableList = new UnityEditorInternal.ReorderableList(sentProperty.serializedObject, sentProperty, true, true, true, true); reorderableList.drawHeaderCallback = (Rect rect) => { //Draw header EditorGUI.LabelField(rect, sentLabel); }; //Set how list elements are drawn reorderableList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { //Get the property from the element SerializedProperty element = reorderableList.serializedProperty.GetArrayElementAtIndex(index); //Add extra height padding rect.y += 2; //display edit button if (GUI.Button(new Rect(rect.x + 10, rect.y, 60, EditorGUIUtility.singleLineHeight), "Edit")) { //if pressed, call edit action editAction(element); } float totalButtonWidth = 80F; Rect newPosition = new Rect(rect.x + totalButtonWidth, rect.y, rect.width - totalButtonWidth, rect.height); EditorStyles.label.clipping = TextClipping.Clip; DrawHeader(newPosition, element); }; //implement onAdd reorderableList.onAddCallback = (UnityEditorInternal.ReorderableList list) => { OnAddElement(list); }; return(reorderableList); }
public ReorderableList(UnityEditorInternal.ReorderableList list, string label = null) { this.list = list; this.label = label; list.drawElementCallback = (rect, index, isActive, isFocused) => { var element = list.serializedProperty.GetArrayElementAtIndex(index); rect.y += 2; var height = EditorGUI.GetPropertyHeight(element); EditorGUI.PropertyField( new Rect(rect.x, rect.y, rect.width, height), element, true); }; list.elementHeightCallback = (index) => { var element = list.serializedProperty.GetArrayElementAtIndex(index); var height = EditorGUI.GetPropertyHeight(element); return(height + 10); }; if (label != null) { list.drawHeaderCallback = rect => { EditorGUI.LabelField(rect, label); }; } }
protected void HandleOnAdd(UnityEditorInternal.ReorderableList p_list) { List <KVPair <int, GameObject> > v_clonedList = p_list.list is List <KVPair <int, GameObject> >?(p_list.list as List <KVPair <int, GameObject> >).CloneList() : new List <KVPair <int, GameObject> >(); v_clonedList.Add(new KVPair <int, GameObject>()); FillSelectedWithList(v_clonedList, false, true); _needRecreateList = true; }
private void OnEnable() { list = new UnityEditorInternal.ReorderableList(serializedObject, serializedObject.FindProperty("AudioObjects"), true, true, true, true) { drawElementCallback = DrawElement, onAddCallback = OnAdd, drawHeaderCallback = (Rect rect) => { UnityEditor.EditorGUI.LabelField(rect, "Audio Objects in this bundle"); } }; }
public static SerializedProperty GetArrayElement(this UnityEditorInternal.ReorderableList list, int index) { if (list.serializedProperty != null && list.serializedProperty.arraySize > index) { return(list.serializedProperty.GetArrayElementAtIndex(index)); } return(null); }
public override void OnEnable() { base.OnEnable(); plyAttributesProperty = serializedObject.FindProperty("plyAttributes"); list = new UnityEditorInternal.ReorderableList(serializedObject, plyAttributesProperty, true, true, true, true); list.drawHeaderCallback += rect => EditorGUI.LabelField(rect, "plyGame attributes"); list.drawElementCallback += (rect, index, active, focused) => { rect.height = 16; rect.y += 3; rect.width /= 4; var atts = plyAttributes; var t = (plyGameConsumableInventoryItem)target; int currentIndex = 0; for (int i = 0; i < atts.Count; i++) { if (atts[i].id == t.plyAttributes[index].id) { currentIndex = i; } } rect.width -= 5; currentIndex = EditorGUI.Popup(rect, currentIndex, attributresStrings); t.plyAttributes[index].id = new UniqueID(atts[currentIndex].id.Value.ToString()); rect.x += rect.width + 5; t.plyAttributes[index].color = EditorGUI.ColorField(rect, t.plyAttributes[index].color); //rect.x += rect.width + 5; var r3 = rect; r3.width = 55; r3.x += rect.width + 5; EditorGUI.LabelField(r3, "IsBonus?"); r3.x += 60; r3.width = 20; t.plyAttributes[index].addToBonus = EditorGUI.Toggle(r3, t.plyAttributes[index].addToBonus); rect.x += rect.width + 5; rect.x += 95; var r4 = rect; r4.width = 40; EditorGUI.LabelField(r4, "Add"); rect.x += r4.width + 5; t.plyAttributes[index].toAdd = EditorGUI.IntField(rect, t.plyAttributes[index].toAdd); if (GUI.changed) { serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(this); } }; }
void SelectClip(ReorderableList list) { if (0 <= list.index && list.index < m_OverrideMotions.arraySize) { using (var element = m_OverrideMotions.GetArrayElementAtIndex(list.index)) using (var m_OriginalMotionProperty = element.FindPropertyRelative("m_OriginalMotion")) EditorGUIUtility.PingObject(m_OriginalMotionProperty.objectReferenceValue); } }
public static void DoReorderableList <TSetting>(TSetting setting, IList list, Type listType, ref UnityEditorInternal.ReorderableList mReorderableList, ref Vector2 mReorderableScrollPosition, ref Vector2 mSettingsScrollPosition, UnityEditorInternal.ReorderableList.ElementCallbackDelegate drawElementCallback = null, Action enableAction = null, Action disableAction = null) where TSetting : ScriptableObject { if (mReorderableList == null) { mReorderableList = new UnityEditorInternal.ReorderableList(list, listType, true, false, false, false); mReorderableList.headerHeight = 0; mReorderableList.showDefaultBackground = false; mReorderableList.drawElementCallback = drawElementCallback; } QuickGUILayout.Space(); using (new QuickEditorGUILayout.HorizontalBlock()) { QuickGUILayout.Space(); if (GUILayout.Button(EditorGUIUtility.FindTexture("Toolbar Plus"), GUIStyle.none, GUILayout.Width(16))) { list.Add(Activator.CreateInstance(listType)); mReorderableList.index = list.Count - 1; mReorderableList.GrabKeyboardFocus(); mSettingsScrollPosition.y = float.MaxValue; } QuickGUILayout.Space(); if (GUILayout.Button(EditorGUIUtility.FindTexture("Toolbar Minus"), GUIStyle.none, GUILayout.Width(16))) { if (mReorderableList.index >= 0 && mReorderableList.index <= list.Count - 1) { Undo.RecordObject(setting, "Removed Import Preset"); list.RemoveAt(mReorderableList.index); mReorderableList.index = Mathf.Max(0, mReorderableList.index - 1); mReorderableList.GrabKeyboardFocus(); } } QuickGUILayout.FlexibleSpace(); if (enableAction != null) { QuickGUILayout.Button("Enable.All", EditorStyles.miniButtonRight, () => { enableAction(); }); } if (disableAction != null) { QuickGUILayout.Button("Disable.All", EditorStyles.miniButtonLeft, () => { disableAction(); }); } } //QEditorGUIStaticAPI.Space(); QuickGUILayout.DrawRect(EditorGUILayout.GetControlRect(false, 2), QuickEditorColors.WhiteCoffee); using (var scroll = new EditorGUILayout.ScrollViewScope(mReorderableScrollPosition)) { mReorderableScrollPosition = scroll.scrollPosition; mReorderableList.DoLayoutList(); } }
void SetupTargetList() { float vSpace = 2; float floatFieldWidth = EditorGUIUtility.singleLineHeight * 3f; float hBigSpace = EditorGUIUtility.singleLineHeight * 2 / 3; mTargetList = new UnityEditorInternal.ReorderableList( serializedObject, FindProperty(x => x.m_Targets), true, true, true, true); // Needed for accessing field names as strings CinemachineTargetGroup.Target def = new CinemachineTargetGroup.Target(); mTargetList.drawHeaderCallback = (Rect rect) => { rect.width -= EditorGUIUtility.singleLineHeight + 2 * (floatFieldWidth + hBigSpace); Vector2 pos = rect.position; pos.x += EditorGUIUtility.singleLineHeight; rect.position = pos; EditorGUI.LabelField(rect, "Target"); pos.x += rect.width + hBigSpace; rect.width = floatFieldWidth; rect.position = pos; EditorGUI.LabelField(rect, "Weight"); pos.x += rect.width + hBigSpace; rect.position = pos; EditorGUI.LabelField(rect, "Radius"); }; mTargetList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { SerializedProperty elemProp = mTargetList.serializedProperty.GetArrayElementAtIndex(index); rect.y += vSpace; rect.height = EditorGUIUtility.singleLineHeight; Vector2 pos = rect.position; //rect.width -= hSpace + 2 * EditorGUIUtility.singleLineHeight; rect.width -= 2 * (floatFieldWidth + hBigSpace); EditorGUI.PropertyField(rect, elemProp.FindPropertyRelative(() => def.target), GUIContent.none); float oldWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = EditorGUIUtility.singleLineHeight; pos.x += rect.width; rect.width = floatFieldWidth + hBigSpace; rect.position = pos; EditorGUI.PropertyField(rect, elemProp.FindPropertyRelative(() => def.weight), new GUIContent(" ")); pos.x += rect.width; rect.position = pos; EditorGUI.PropertyField(rect, elemProp.FindPropertyRelative(() => def.radius), new GUIContent(" ")); EditorGUIUtility.labelWidth = oldWidth; }; mTargetList.onAddCallback = (UnityEditorInternal.ReorderableList l) => { var index = l.serializedProperty.arraySize; ++l.serializedProperty.arraySize; SerializedProperty elemProp = mTargetList.serializedProperty.GetArrayElementAtIndex(index); elemProp.FindPropertyRelative(() => def.weight).floatValue = 1; }; }
void SetupChildList() { float vSpace = 2; mChildList = new UnityEditorInternal.ReorderableList(serializedObject, serializedObject.FindProperty(() => Target.m_ChildCameras), true, true, true, true); mChildList.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, "Virtual Camera Children"); }; mChildList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { rect.y += vSpace; Vector2 pos = rect.position; rect.height = EditorGUIUtility.singleLineHeight; SerializedProperty element = mChildList.serializedProperty.GetArrayElementAtIndex(index); EditorGUI.PropertyField(rect, element, GUIContent.none); }; mChildList.onChangedCallback = (UnityEditorInternal.ReorderableList l) => { if (l.index < 0 || l.index >= l.serializedProperty.arraySize) { return; } Object o = l.serializedProperty.GetArrayElementAtIndex( l.index).objectReferenceValue; CinemachineVirtualCameraBase vcam = (o != null) ? (o as CinemachineVirtualCameraBase) : null; if (vcam != null) { vcam.transform.SetSiblingIndex(l.index); } }; mChildList.onAddCallback = (UnityEditorInternal.ReorderableList l) => { var index = l.serializedProperty.arraySize; var vcam = CinemachineMenu.CreateDefaultVirtualCamera(); Undo.SetTransformParent(vcam.transform, Target.transform, ""); vcam.transform.SetSiblingIndex(index); }; mChildList.onRemoveCallback = (UnityEditorInternal.ReorderableList l) => { Object o = l.serializedProperty.GetArrayElementAtIndex( l.index).objectReferenceValue; CinemachineVirtualCameraBase vcam = (o != null) ? (o as CinemachineVirtualCameraBase) : null; if (vcam != null) { Undo.DestroyObjectImmediate(vcam.gameObject); } }; }
protected override void OnUpdateList(UnityEditorInternal.ReorderableList r) { var list = new List <string>(); for (int i = 1; i <= property.arraySize; i++) { list.Add(property.displayName + "#" + i); } r.list = list; }
public ReorderableList(SerializedObject serializedObject, SerializedProperty serializedProperty, Func <int, GUIContent> propertyContentCallback) { this.serializedProperty = serializedProperty; this.propertyContentCallback = propertyContentCallback; header = serializedProperty.displayName; list = new UnityEditorInternal.ReorderableList(serializedObject, serializedProperty); list.drawElementCallback = DrawElement; list.drawHeaderCallback = DrawHeader; }
void OnAddClip(UnityEditorInternal.ReorderableList list) { int idx = m_clipData.arraySize; m_clipData.InsertArrayElementAtIndex(idx); if (idx == 0) { m_clipData.GetArrayElementAtIndex(idx).FindPropertyRelative("m_volume").floatValue = 1f; } }
private void ONLayerAddCallback(ReorderableList list) { AnimatorLayer layer = new AnimatorLayer(this); if (inputs.Count > 0) { layer.stateMachine.SetStatesFromInputOptions(inputs[0].options); } layers.Add(layer); }
private void OnRemoveAnimation(UnityEditorInternal.ReorderableList list) { AnimationClip animation = list.list[list.index] as AnimationClip; if (animation != null) { Object.DestroyImmediate(animation, true); AssetDatabase.SaveAssets(); } }
/// <summary> Constructor to set up references </summary> public void OnEnable() { m_requirements = serializedObject.FindProperty("m_requirements"); m_valuesMix = serializedObject.FindProperty("m_valuesMix"); m_values = serializedObject.FindProperty("m_values"); m_eventsMix = serializedObject.FindProperty("m_eventsMix"); m_events = serializedObject.FindProperty("m_events"); m_modVolume = serializedObject.FindProperty("m_modVolume"); m_volume = serializedObject.FindProperty("m_volume"); m_modPlaybackSpeed = serializedObject.FindProperty("m_modPlaybackSpeed"); m_playbackSpeed = serializedObject.FindProperty("m_playbackSpeed"); m_modClips = serializedObject.FindProperty("m_modClips"); m_modClipsType = serializedObject.FindProperty("m_modClipsType"); m_clipData = serializedObject.FindProperty("m_clipData"); m_modDelayChance = serializedObject.FindProperty("m_modDelayChance"); m_delayChance = serializedObject.FindProperty("m_delayChance"); m_modDelay = serializedObject.FindProperty("m_modDelay"); m_minMaxDelay = serializedObject.FindProperty("m_minMaxDelay"); m_modRandomizeVolume = serializedObject.FindProperty("m_modRandomizeVolume"); m_randomizeVolume = serializedObject.FindProperty("m_randomizeVolume"); m_modMinMaxVolume = serializedObject.FindProperty("m_modMinMaxVolume"); m_minMaxVolume = serializedObject.FindProperty("m_minMaxVolume"); m_modRandomizePlaybackSpeed = serializedObject.FindProperty("m_modRandomizePlaybackSpeed"); m_randomizePlaybackSpeed = serializedObject.FindProperty("m_randomizePlaybackSpeed"); m_modMinMaxPlaybackSpeed = serializedObject.FindProperty("m_modMinMaxPlaybackSpeed"); m_minMaxPlaybackSpeed = serializedObject.FindProperty("m_minMaxPlaybackSpeed"); ValuesOrEvents reqVal = (ValuesOrEvents)m_requirements.enumValueIndex; valuesGroup = new AnimBool((reqVal & ValuesOrEvents.Values) != 0, Repaint); eventsGroup = new AnimBool((reqVal & ValuesOrEvents.Events) != 0, Repaint); clipsVisible = new AnimBool(m_modClips.boolValue, Repaint); m_eventsReorderable = new UnityEditorInternal.ReorderableList(serializedObject, m_events, true, false, true, true); m_eventsReorderable.elementHeight = EditorGUIUtility.singleLineHeight; m_eventsReorderable.drawElementCallback = DrawEventElement; m_eventsReorderable.drawHeaderCallback = DrawEventHeader; m_valuesReorderable = new UnityEditorInternal.ReorderableList(serializedObject, m_values, true, false, true, true); m_valuesReorderable.drawElementCallback = DrawValuesElement; m_valuesReorderable.drawHeaderCallback = DrawValueHeader; m_valuesReorderable.elementHeight = 2f * (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing); m_clipsReorderable = new UnityEditorInternal.ReorderableList(serializedObject, m_clipData, true, false, true, true); m_clipsReorderable.elementHeight = EditorGUIUtility.singleLineHeight; m_clipsReorderable.drawElementCallback = DrawClipElement; m_clipsReorderable.drawHeaderCallback = DrawClipHeader; if (m_editorUtils == null) { // Get editor utils for this m_editorUtils = PWApp.GetEditorUtils(this); } }
public override void OnEnable() { base.OnEnable(); plyAttributesProperty = serializedObject.FindProperty("plyAttributes"); list = new UnityEditorInternal.ReorderableList(serializedObject, plyAttributesProperty, true, true, true, true); list.drawHeaderCallback += rect => EditorGUI.LabelField(rect, "plyGame attributes"); list.drawElementCallback += (rect, index, active, focused) => { rect.height = 16; rect.y += 3; rect.width /= 4; var atts = plyAttributes; var t = (plyGameConsumableInventoryItem)target; int currentIndex = 0; for (int i = 0; i < atts.Count; i++) { if (atts[i].id == t.plyAttributes[index].id) currentIndex = i; } rect.width -= 5; currentIndex = EditorGUI.Popup(rect, currentIndex, attributresStrings); t.plyAttributes[index].id = new UniqueID(atts[currentIndex].id.Value.ToString()); rect.x += rect.width + 5; t.plyAttributes[index].color = EditorGUI.ColorField(rect, t.plyAttributes[index].color); //rect.x += rect.width + 5; var r3 = rect; r3.width = 55; r3.x += rect.width + 5; EditorGUI.LabelField(r3, "IsBonus?"); r3.x += 60; r3.width = 20; t.plyAttributes[index].addToBonus = EditorGUI.Toggle(r3, t.plyAttributes[index].addToBonus); rect.x += rect.width + 5; rect.x += 95; var r4 = rect; r4.width = 40; EditorGUI.LabelField(r4, "Add"); rect.x += r4.width + 5; t.plyAttributes[index].toAdd = EditorGUI.IntField(rect, t.plyAttributes[index].toAdd); if (GUI.changed) { serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(this); } }; }
private void OnAdd(UnityEditorInternal.ReorderableList reList) { var index = reList.serializedProperty.arraySize; reList.serializedProperty.arraySize++; reList.index = index; var element = reList.serializedProperty.GetArrayElementAtIndex(index); element.FindPropertyRelative("Name").stringValue = ""; element.FindPropertyRelative("Clip").objectReferenceValue = null; }
/// <summary> /// Initialize native reorderable list by <paramref name="options"/>. /// </summary> /// <param name="listProperty"></param> /// <param name="options"></param> protected virtual void InitializeNative(SerializedProperty listProperty, NativeFunctionOptions options) { Native = new UnityEditorInternal.ReorderableList( listProperty.serializedObject, listProperty, options.Draggable, options.DisplayHeader, options.DisplayAddButton, options.DisplayRemoveButton ); }
private void SetupAnimationList() { if( animationList != null ) return; animationList = new UnityEditorInternal.ReorderableList( animations, typeof( AnimationClip ), false, true, true, true ); animationList.onChangedCallback += OnAnimationListChanged; animationList.onAddCallback += OnAddAnimation; animationList.onRemoveCallback += OnRemoveAnimation; animationList.drawHeaderCallback += DrawAnimationListHeader; animationList.drawElementCallback += DrawAnimationListElement; }
public override void OnEnable() { base.OnEnable(); plyAttributesProperty = serializedObject.FindProperty("plyAttributes"); list = new UnityEditorInternal.ReorderableList(serializedObject, plyAttributesProperty, true, true, true, true); list.drawHeaderCallback += rect => EditorGUI.LabelField(rect, "plyGame attributes"); list.drawElementCallback += (rect, index, active, focused) => { rect.height = 16; rect.y += 3; var r2 = rect; r2.width /= 3; r2.width -= 5; r2.x += (r2.width * 2) + 10; rect.width /= 3; var atts = plyAttributes; var t = (plyGameEquippableInventoryItem)target; int currentIndex = 0; for (int i = 0; i < atts.Count; i++) { if (atts[i].id == t.plyAttributes[index].id) currentIndex = i; } rect.width -= 5; currentIndex = EditorGUI.Popup(rect, currentIndex, attributresStrings); t.plyAttributes[index].id = new UniqueID(atts[currentIndex].id.Value.ToString()); rect.x += rect.width + 5; t.plyAttributes[index].color = EditorGUI.ColorField(rect, "", t.plyAttributes[index].color); r2.width /= 2; r2.width -= 5; EditorGUI.LabelField(r2, "Add " + atts[currentIndex].def.screenName); r2.x += r2.width; t.plyAttributes[index].toAdd = EditorGUI.IntField(r2, t.plyAttributes[index].toAdd); if (GUI.changed) { serializedObject.ApplyModifiedProperties(); EditorUtility.SetDirty(this); } }; }
public override void OnEnable() { base.OnEnable(); item = (ItemCollectionBase)target; //serializer = new SerializedObject(target); serializer = serializedObject; collectionName = serializer.FindProperty("collectionName"); restrictByWeight = serializer.FindProperty("restrictByWeight"); restrictMaxWeight = serializer.FindProperty("restrictMaxWeight"); itemButtonPrefab = serializer.FindProperty("itemButtonPrefab"); items = serializer.FindProperty("_items"); filters = serializer.FindProperty("filters"); useReferences = serializer.FindProperty("useReferences"); canContainCurrencies = serializer.FindProperty("canContainCurrencies"); canDropFromCollection = serializer.FindProperty("canDropFromCollection"); canUseItemsFromReference = serializer.FindProperty("canUseItemsFromReference"); canUseFromCollection = serializer.FindProperty("canUseFromCollection"); canDragInCollection = serializer.FindProperty("canDragInCollection"); canPutItemsInCollection = serializer.FindProperty("canPutItemsInCollection"); canStackItemsInCollection = serializer.FindProperty("canStackItemsInCollection"); canUnstackItemsInCollection = serializer.FindProperty("canUnstackItemsInCollection"); manuallyDefineCollection = serializer.FindProperty("manuallyDefineCollection"); container = serializer.FindProperty("container"); itemManager = Editor.FindObjectOfType<ItemManager>(); if (itemManager == null) Debug.LogError("No item manager found in scene, cannot edit item."); manualItemsList = new UnityEditorInternal.ReorderableList(serializer, items, true, true, true, true); manualItemsList.drawHeaderCallback += rect => { EditorGUI.LabelField(rect, "Select items"); }; manualItemsList.drawElementCallback += (rect, index, active, focused) => { rect.height = 16; rect.y += 2; EditorGUI.PropertyField(rect, items.GetArrayElementAtIndex(index)); }; }
public void Initialize(EntitasPreferencesConfig config) { _codeGenerators = UnityCodeGenerator.GetCodeGenerators(); var codeGeneratorNames = _codeGenerators.Select(cg => cg.Name).ToArray(); _codeGeneratorConfig = new CodeGeneratorConfig(config, codeGeneratorNames); _pools = new List<string>(_codeGeneratorConfig.pools); _poolList = new UnityEditorInternal.ReorderableList(_pools, typeof(string), true, true, true, true); _poolList.drawHeaderCallback = rect => EditorGUI.LabelField(rect, "Custom Pools");; _poolList.drawElementCallback = (rect, index, isActive, isFocused) => { rect.width -= 20; _pools[index] = EditorGUI.TextField(rect, _pools[index]); }; _poolList.onAddCallback = list => list.list.Add("New Pool"); _poolList.onCanRemoveCallback = list => true; _poolList.onChangedCallback = list => GUI.changed = true; }
public void OnEnable() { equipTypes = serializedObject.FindProperty("_equipTypes"); list = new UnityEditorInternal.ReorderableList(serializedObject, equipTypes, true, true, true, true); list.drawHeaderCallback += rect => EditorGUI.LabelField(rect, "Which types can be placed in this field?"); list.drawElementCallback += (rect, index, active, focused) => { rect.height = 16; rect.y += 3; var i = equipTypes.GetArrayElementAtIndex(index); i.intValue = EditorGUI.Popup(rect, i.intValue, InventoryEditorUtility.equipTypesStrings); //EditorGUI.PropertyField(rect, equipTypes.GetArrayElementAtIndex(index)); //EditorGUILayout.Popup(e.intValue, InventoryEditorUtility.equipTypesStrings); }; }
public override void OnEnable() { base.OnEnable(); id = serializedObject.FindProperty("_id"); itemName = serializedObject.FindProperty("_name"); description = serializedObject.FindProperty("_description"); properties = serializedObject.FindProperty("_properties"); useCategoryCooldown = serializedObject.FindProperty("_useCategoryCooldown"); category = serializedObject.FindProperty("_category"); icon = serializedObject.FindProperty("_icon"); weight = serializedObject.FindProperty("_weight"); requiredLevel = serializedObject.FindProperty("_requiredLevel"); rarity = serializedObject.FindProperty("_rarity"); buyPrice = serializedObject.FindProperty("_buyPrice"); sellPrice = serializedObject.FindProperty("_sellPrice"); isDroppable = serializedObject.FindProperty("_isDroppable"); isSellable = serializedObject.FindProperty("_isSellable"); isStorable = serializedObject.FindProperty("_isStorable"); maxStackSize = serializedObject.FindProperty("_maxStackSize"); cooldownTime = serializedObject.FindProperty("_cooldownTime"); var t = (InventoryItemBase)target; propertiesList = new UnityEditorInternal.ReorderableList(serializedObject, properties, true, true, true, true); propertiesList.drawHeaderCallback += rect => GUI.Label(rect, "Item properties"); propertiesList.elementHeight = 40; propertiesList.drawElementCallback += (rect, index, active, focused) => { PropertiesDrawElement(rect, index, active, focused, true, true); }; propertiesList.onAddCallback += (list) => { var l = new List<InventoryItemProperty>(t.properties); l.Add(new InventoryItemProperty()); t.properties = l.ToArray(); GUI.changed = true; // To save.. EditorUtility.SetDirty(target); serializedObject.ApplyModifiedProperties(); Repaint(); }; }
public EquipEditor(string name, EditorWindow window) { this.name = name; this.window = window; this.requiresDatabase = true; typeList = new UnityEditorInternal.ReorderableList(InventoryEditorUtility.selectedDatabase != null ? InventoryEditorUtility.selectedDatabase.equipStatTypes : new string[] { }, typeof(System.Type), false, true, true, true); typeList.drawHeaderCallback += rect => EditorGUI.LabelField(rect, "Types to scan"); typeList.drawElementCallback += (rect, index, active, focused) => { rect.height = 16; rect.y += 2; var r = rect; r.width -= 60; var statTypes = InventoryEditorUtility.selectedDatabase.equipStatTypes; EditorGUI.LabelField(r, (string.IsNullOrEmpty(statTypes[index]) == false && System.Type.GetType(statTypes[index]) != null) ? System.Type.GetType(statTypes[index]).FullName : "(NOT SET)"); var r2 = rect; r2.width = 60; r2.height = 14; r2.x += r.width; if (GUI.Button(r2, "Set")) { var typePicker = InventoryItemTypePicker.Get(); typePicker.Show(InventoryEditorUtility.selectedDatabase); typePicker.OnPickObject += type => { statTypes[index] = type.AssemblyQualifiedName; window.Repaint(); GUI.changed = true; // To save.. }; } }; typeList.onAddCallback += list => { var l = new List<string>(InventoryEditorUtility.selectedDatabase.equipStatTypes); l.Add(null); InventoryEditorUtility.selectedDatabase.equipStatTypes = l.ToArray(); list.list = InventoryEditorUtility.selectedDatabase.equipStatTypes; window.Repaint(); }; typeList.onRemoveCallback += list => { var l = new List<string>(InventoryEditorUtility.selectedDatabase.equipStatTypes); l.RemoveAt(list.index); InventoryEditorUtility.selectedDatabase.equipStatTypes = l.ToArray(); list.list = InventoryEditorUtility.selectedDatabase.equipStatTypes; window.Repaint(); }; resultList = new UnityEditorInternal.ReorderableList(InventoryEditorUtility.selectedDatabase != null ? InventoryEditorUtility.selectedDatabase.equipStats : new InventoryEquipStat[] { }, typeof(InventoryEquipStat), true, true, false, false); resultList.drawHeaderCallback += rect => { var r = rect; r.width = 40; r.x += 15; // Little offset on the start EditorGUI.LabelField(r, "Show"); var r2 = rect; r2.width -= r.width; r2.x += r.width + 20; r2.width /= 3.2f; EditorGUI.LabelField(r2, "From type"); r2.x += r2.width; EditorGUI.LabelField(r2, "Display name"); r2.x += r2.width; EditorGUI.LabelField(r2, "Category"); }; //resultList.elementHeight = 30; resultList.drawElementCallback += (rect, index, active, focused) => { rect.height = 16; rect.y += 2; var stat = InventoryEditorUtility.selectedDatabase.equipStats[index]; var r = rect; r.width = 40; stat.show = EditorGUI.Toggle(r, stat.show); var r2 = rect; r2.width -= r.width; r2.x += r.width + 5; r2.width /= 3.2f; EditorGUI.LabelField(r2, stat.fieldInfoNameVisual); r2.x += r2.width + 5; stat.name = EditorGUI.TextField(r2, stat.name); r2.x += r2.width + 5; stat.category = EditorGUI.TextField(r2, stat.category); }; }
public override void OnEnable() { base.OnEnable(); tar = (InventoryPlayer)target; equipLocations = serializedObject.FindProperty("equipLocations"); dynamicallyFindUIElements = serializedObject.FindProperty("dynamicallyFindUIElements"); characterUIPath = serializedObject.FindProperty("characterUIPath"); inventoryPaths = serializedObject.FindProperty("inventoryPaths"); skillbarPath = serializedObject.FindProperty("skillbarPath"); characterCollection = serializedObject.FindProperty("characterCollection"); inventoryCollections = serializedObject.FindProperty("inventoryCollections"); skillbarCollection = serializedObject.FindProperty("skillbarCollection"); itemDatabase = InventoryEditorUtility.GetItemDatabase(true, false); if (itemDatabase == null) Debug.LogError("No item database found in scene, cannot edit item."); list = new UnityEditorInternal.ReorderableList(serializedObject, equipLocations, false, true, false, false); list.elementHeight = 66; list.drawHeaderCallback += rect => { EditorGUI.LabelField(rect, "Equipment binding"); }; list.drawElementCallback += (rect, index, active, focused) => { rect.height = 16; rect.y += 2; var r3 = rect; r3.width = 25; rect.x += 30; rect.width -= 30; var r = rect; var r2 = rect; r2.width -= EditorGUIUtility.labelWidth; r2.x += EditorGUIUtility.labelWidth; r3.x += 8; r3.y += 24; var t = equipLocations.GetArrayElementAtIndex(index).FindPropertyRelative("equipTransform").objectReferenceValue as Transform; if (t != null && t.IsChildOf(((InventoryPlayer) target).transform)) { EditorGUI.Toggle(r3, GUIContent.none, true, "VisibilityToggle"); } else { EditorGUI.Toggle(r3, GUIContent.none, false, "VisibilityToggle"); } GUI.enabled = false; EditorGUI.ObjectField(r, equipLocations.GetArrayElementAtIndex(index).FindPropertyRelative("associatedField"), new GUIContent("Associated field")); GUI.enabled = true; rect.y += 18; EditorGUI.PropertyField(rect, equipLocations.GetArrayElementAtIndex(index).FindPropertyRelative("equipTransform")); if (t != null && t.IsChildOf(((InventoryPlayer)target).transform) == false) { rect.y += 18; EditorGUI.HelpBox(rect, "Equip transform has to be a child of this character.", MessageType.Error); } rect.y += 18; EditorGUI.PropertyField(rect, equipLocations.GetArrayElementAtIndex(index).FindPropertyRelative("equipHandlerType")); }; if (tar.characterCollection != null && tar.characterCollection.container != null) { if (IsOutOfSync()) { ReSync(); } } }
public plyStatsEditor(string name, EditorWindow window) { this.name = name; this.window = window; this.requiresDatabase = true; resultList = new UnityEditorInternal.ReorderableList(attributes, typeof(plyGameAttributeDatabaseModel), false, true, false, false); resultList.drawHeaderCallback += rect => { var r = rect; r.width = 40; r.x += 15; // Little offset on the start EditorGUI.LabelField(r, "Show"); var r2 = rect; r2.width -= 50; r2.width /= 3; r2.x += 50; EditorGUI.LabelField(r2, "Display name"); r2.x += r2.width; EditorGUI.LabelField(r2, "Category"); r2.x += r2.width; EditorGUI.LabelField(r2, "Formatter"); }; //resultList.elementHeight = 30; resultList.drawElementCallback += (rect, index, active, focused) => { rect.height = 16; rect.y += 2; if (index >= InventoryEditorUtility.selectedDatabase.plyAttributes.Length) return; var stat = InventoryEditorUtility.selectedDatabase.plyAttributes[index]; var r2 = rect; r2.width -= 50; r2.width /= 3; r2.width -= 10; r2.x += 50; var r = rect; r.width = 40; r.x += 15; stat.show = EditorGUI.Toggle(r, stat.show); GUI.enabled = stat.show; if (index >= 0 && index <= attributresStrings.Length) EditorGUI.LabelField(r2, attributresStrings[index]); r2.x += r2.width; r2.x += 10; stat.category = EditorGUI.TextField(r2, stat.category); GUI.enabled = true; if (GUI.changed) { EditorUtility.SetDirty(InventoryEditorUtility.selectedDatabase); } }; }