public MapSelectionDropdown(AdvancedDropdownState state, GameInfo_Volume[] gameVolumes, Game game) : base(state) { GameVolumes = gameVolumes; LevelNames = MapNames.GetMapNames(game) ?? new Dictionary <int, Dictionary <int, string> >(); WorldNames = MapNames.GetWorldNames(game) ?? new Dictionary <int, string>(); minimumSize = new Vector2(50, 400f); }
public TypeSelectDropdown(AdvancedDropdownState state, Action <Type> onTypeSelectedCallback, Type[] constraints = null, Type[] requiredInterfaces = null) : base(state) { this.constraints = constraints ?? new Type[0]; this.requiredInterfaces = requiredInterfaces ?? new Type[0]; Vector2 customMinimumSize = minimumSize; customMinimumSize.y = 250; minimumSize = customMinimumSize; onTypeSelected = onTypeSelectedCallback; }
void CreatePropertyDropdown() { if (referenceObject == null) { Debug.LogError("Reference Object is null. Lookup cannot be created"); return; } HashSet <string> propertyPaths = new HashSet <string>(); Dictionary <string, PropertyData> propertyLookup = new Dictionary <string, PropertyData>(); var iterator = new ScriptableObjectIterator(referenceObject); var configuration = (AssetListConfiguration)target; foreach (SerializedProperty prop in iterator) { if (prop.propertyType == SerializedPropertyType.Generic) { if (prop.isArray) { propertyPaths.Add(prop.propertyPath); propertyLookup.Add(prop.propertyPath, new PropertyData(configuration, prop)); if (!prop.NextVisible(false)) { break; } iterator.PauseIteratorOnce = true; } //We can't display generic fields anyway. continue; } propertyPaths.Add(prop.propertyPath); propertyLookup.Add(prop.propertyPath, new PropertyData(configuration, prop)); } if (propertyDropdownState == null) { propertyDropdownState = new AdvancedDropdownState(); } propertyDropdown = new PropertyDropdown(propertyDropdownState, propPath => { SerializedProperty column = columns.GetArrayElementAtIndex(columns.arraySize++); column.FindPropertyRelative("PropertyPath").stringValue = propPath; column.FindPropertyRelative("Title").stringValue = ObjectNames.NicifyVariableName(propPath); column.FindPropertyRelative("PropertyType").intValue = (int)propertyLookup[propPath].Type; column.FindPropertyRelative("IsArray").boolValue = propertyLookup[propPath].IsArray; serializedObject.ApplyModifiedProperties(); }, propertyPaths, propertyLookup); }
private void RenderDestinationElementDevice(TableAuthoring tableAuthoring, WireListData wireListData, Rect cellRect, Action <WireListData> updateAction) { if (GUI.Button(cellRect, wireListData.DestinationDevice, EditorStyles.objectField) || GUI.Button(cellRect, "", GUI.skin.GetStyle("IN ObjectField"))) { if (_destinationElementDeviceDropdownState == null) { _destinationElementDeviceDropdownState = new AdvancedDropdownState(); } var dropdown = new ItemSearchableDropdown <ICoilDeviceAuthoring>( _destinationElementDeviceDropdownState, tableAuthoring, "Coil Devices", item => { wireListData.DestinationDevice = item.Name; updateAction(wireListData); } ); dropdown.Show(cellRect); } }
private void RenderPlayfieldElement(TableAuthoring tableAuthoring, SwitchListData switchListData, Rect cellRect, Action <SwitchListData> updateAction) { if (GUI.Button(cellRect, switchListData.PlayfieldItem, EditorStyles.objectField) || GUI.Button(cellRect, "", GUI.skin.GetStyle("IN ObjectField"))) { if (_itemPickDropdownState == null) { _itemPickDropdownState = new AdvancedDropdownState(); } var dropdown = new ItemSearchableDropdown <ISwitchableAuthoring>( _itemPickDropdownState, tableAuthoring, "Switchable Items", item => { switchListData.PlayfieldItem = item.Name; updateAction(switchListData); } ); dropdown.Show(cellRect); } }
private void RenderSourceElementPlayfield(TableAuthoring tableAuthoring, WireListData wireListData, Rect cellRect, Action <WireListData> updateAction) { if (GUI.Button(cellRect, wireListData.SourcePlayfieldItem, EditorStyles.objectField) || GUI.Button(cellRect, "", GUI.skin.GetStyle("IN ObjectField"))) { if (_sourceElementDeviceDropdownState == null) { _sourceElementDeviceDropdownState = new AdvancedDropdownState(); } var dropdown = new ItemSearchableDropdown <ISwitchAuthoring>( _sourceElementDeviceDropdownState, tableAuthoring, "Switch Items", item => { wireListData.SourcePlayfieldItem = item.Name; updateAction(wireListData); } ); dropdown.Show(cellRect); } }
public AnimationStepAdvancedDropdown(AdvancedDropdownState state) : base(state) { this.minimumSize = new Vector2(200, 300); }
internal ContentActionsDropdown(AdvancedDropdownState state) : base(state) { }
public MapSelectionDropdown(AdvancedDropdownState state, string directory) : this(state) { this.directory = directory; BuildFileList(); }
public GenericAdvancedDropdown(string title, AdvancedDropdownState state) : base(state) { this.title = title; }
public GameModeSelectionDropdown(AdvancedDropdownState state) : base(state) { minimumSize = new Vector2(50, 500f); }
public CustomEaseAdvancedDropdown(AdvancedDropdownState state) : base(state) { this.minimumSize = new Vector2(200, 300); }
public ProductDropDown(AdvancedDropdownState state) : base(state) { }
public AddComponentDataSource(AdvancedDropdownState state) { m_State = state; }
public LocalizationDropdown(AdvancedDropdownState state) : base(state) { minimumSize = new UnityEngine.Vector2(400f, 400f); }
public BetterAdvancedDropdown(AdvancedDropdownState state, AdvancedDropdownItem <TPayload> root, Action <TPayload> onItemSelectedCallback) : base(state) { this.root = root; this.onItemSelectedCallback = onItemSelectedCallback; }
public AdvancedTypePopup(IEnumerable <Type> types, int maxLineCount, AdvancedDropdownState state) : base(state) { SetTypes(types); minimumSize = new Vector2(minimumSize.x, EditorGUIUtility.singleLineHeight * maxLineCount + k_HeaderHeight); }
//public SerializedProperty property; public PS1ActorSelectionDropdown(AdvancedDropdownState state, Settings.Mode mode, int actorIndex) : base(state) { this.mode = mode; this.actorIndex = actorIndex; minimumSize = new UnityEngine.Vector2(50, 300f); }
public CreateNodesAdvancedDropdown(AdvancedDropdownState state) : base(state) { }
//public SerializedProperty property; public MapSelectionDropdown(AdvancedDropdownState state) : base(state) { minimumSize = new UnityEngine.Vector2(50, 400f); }
public AdvancedGenericMenu(string name, AdvancedDropdownState state) : base(state) { Name = name; }
public MapSelectionDropdown(AdvancedDropdownState state, string directory) : this(state) { this.directory = directory; files = FindFiles().ToArray(); }
public CollectionItemDropdown(AdvancedDropdownState state, Type targetItemType) : base(state) { itemType = targetItemType; collections = CollectionsRegistry.Instance.GetCollectionsByItemType(itemType); minimumSize = new Vector2(200, 300); }
void CreateIconPropertyDropdown() { if (referenceObject == null) { Debug.LogError("Reference Object is null. Lookup cannot be created"); return; } HashSet <string> iconPropertyPaths = new HashSet <string>(); var iterator = new ScriptableObjectIterator(referenceObject); //Property paths that are also arrays HashSet <string> iconArrayPropertyPaths = new HashSet <string>(); SerializedProperty skipUntil = null; foreach (SerializedProperty prop in iterator) { //Skip until the end of the array property if (skipUntil != null) { if (!SerializedProperty.EqualContents(prop, skipUntil)) { continue; } skipUntil = null; } if (prop.propertyType == SerializedPropertyType.Generic && prop.isArray) { bool hasTextureProperty = false; SerializedProperty temp = prop.Copy(); SerializedProperty end = prop.GetEndProperty(); while (temp.NextVisible(true) && !SerializedProperty.EqualContents(temp, end)) { if (temp.propertyType != SerializedPropertyType.ObjectReference) { continue; } if (!typeStrings.Contains(temp.type)) { continue; } hasTextureProperty = true; break; } if (hasTextureProperty) { //Add the array property to the list if there was a valid texture property inside it. iconPropertyPaths.Add(prop.propertyPath); iconArrayPropertyPaths.Add(prop.propertyPath); //Define the next property as the destination to advance the for loop to. skipUntil = end; } } if (prop.propertyType != SerializedPropertyType.ObjectReference) { continue; } if (typeStrings.Contains(prop.type)) { iconPropertyPaths.Add(prop.propertyPath); } } iconPropertyDropdown = null; switch (iconPropertyPaths.Count) { case 0: Debug.LogError("No appropriate property paths found."); return; case 1: Debug.Log("Only one appropriate property path found. It has been automatically assigned."); AssignPropPath(iconPropertyPaths.First()); return; } if (iconPropertyDropdownState == null) { iconPropertyDropdownState = new AdvancedDropdownState(); } iconPropertyDropdown = new PropertyDropdown(iconPropertyDropdownState, AssignPropPath, iconPropertyPaths, null); void AssignPropPath(string propPath) { iconPropertyPath.stringValue = propPath; if (iconArrayPropertyPaths.Contains(propPath)) { iconIsArray.boolValue = true; iconArrayPropertyInformation.FindPropertyRelative("ArrayPropertyType").intValue = (int)SerializedPropertyType.ObjectReference; } serializedObject.ApplyModifiedProperties(); } }
public GenericAdvancedDropdown(AdvancedDropdownState state) : base(state) { }
public NodeDropdown(AdvancedDropdownState state, Action <ClassTypeDropdownItem> callback) : base(state) { this.Callback = callback; minimumSize = new Vector2(230, 320); }
public KnownTraitsDropdown(AdvancedDropdownState state, SemanticTagCondition condition, Action doTraitNameChanged) : base(state) { m_SemanticTagCondition = condition; m_DoTraitNameChanged = doTraitNameChanged; minimumSize = new Vector2(150, 200); }
public TypePopupCache(AdvancedTypePopup typePopup, AdvancedDropdownState state) { TypePopup = typePopup; State = state; }
protected override void OnEnable() { base.OnEnable(); assetType = serializedObject.FindProperty("assetType"); missingPropertyDisplay = serializedObject.FindProperty("missingPropertyDisplay"); additionalColumns = serializedObject.FindProperty("additionalColumns"); columns = serializedObject.FindProperty("columns"); typeString = serializedObject.FindProperty("typeString"); nameDisplay = serializedObject.FindProperty("nameDisplay"); iconPropertyPath = serializedObject.FindProperty("iconPropertyPath"); iconIsArray = serializedObject.FindProperty("iconIsArray"); iconArrayPropertyInformation = serializedObject.FindProperty("iconArrayPropertyInformation"); type = Type.GetType(typeString.stringValue); if (type == null) { return; } typeIsTextureOrSprite = typeof(Texture).IsAssignableFrom(type) || typeof(Sprite).IsAssignableFrom(type); typeIsAsset = !type.IsSubclassOf(typeof(Component)); backgroundOffset = new RectOffset(20, 6, 2, 0); reorderableList = new ReorderableList(serializedObject, columns) { drawElementCallback = (rect, index, active, focused) => { float min = rect.y; if (index % 2 == 0) { EditorGUI.DrawRect(backgroundOffset.Add(rect), new Color(0f, 0f, 0f, 0.075f)); } SerializedProperty column = columns.GetArrayElementAtIndex(index); SerializedProperty propertyPath = column.FindPropertyRelative("PropertyPath"); SerializedProperty title = column.FindPropertyRelative("Title"); rect.height = EditorGUIUtility.singleLineHeight; EditorGUI.PropertyField(rect, title); rect.NextGUIRect(); using (new EditorGUI.DisabledScope(true)) EditorGUI.PropertyField(rect, propertyPath); var propertyType = (SerializedPropertyType)column.FindPropertyRelative("PropertyType").intValue; string propertyName = null; bool captureHeight = false; if (propertyType == SerializedPropertyType.Generic) { /* * bool IsArray; * ArrayIndexing ArrayIndexing; * string ArrayPropertyKey; * string ArrayQuery; * int ArrayIndex; * string ArrayPropertyPath; */ captureHeight = true; bool isArray = column.FindPropertyRelative("IsArray").boolValue; if (isArray) { var arrayPropertyInformation = column.FindPropertyRelative("ArrayPropertyInformation"); ArrayDataDrawer.OnGUI(ref rect, propertyPath, arrayPropertyInformation, referenceObject, null, rect.x - 20, -16); var arrayPropertyPath = arrayPropertyInformation.FindPropertyRelative("ArrayPropertyPath"); if (!string.IsNullOrEmpty(arrayPropertyPath.stringValue)) { propertyType = (SerializedPropertyType)arrayPropertyInformation.FindPropertyRelative("ArrayPropertyType").intValue; propertyName = GetPropertyDisplayString(propertyType); } } } else { propertyName = GetPropertyDisplayString(propertyType); } if (propertyName != null) { rect.NextGUIRect(); EditorGUI.PropertyField(rect, column.FindPropertyRelative(propertyName)); } if (captureHeight) { if (heightOverrideLookup.ContainsKey(index)) { heightOverrideLookup[index] = rect.yMax - min; } else { heightOverrideLookup.Add(index, rect.yMax - min); } } }, headerHeight = 0, elementHeightCallback = index => { if (heightOverrideLookup.TryGetValue(index, out float height)) { return(height); } return(EditorGUIUtils.HeightWithSpacing * 3); }, onReorderCallback = list => heightOverrideLookup.Clear(), displayAdd = false, onRemoveCallback = list => { //Refresh property dropdown (this currently is only done to refresh the "enabled" state of the properties) propertyDropdownState = null; CreatePropertyDropdown(); heightOverrideLookup.Clear(); ReorderableList.defaultBehaviours.DoRemoveButton(list); } }; referenceObject = LoadAssetByTypeName(type, type.IsSubclassOf(typeof(Component)), (AssetType)assetType.intValue); if (referenceObject != null) { CreatePropertyDropdown(); } }
internal ProxyGroupActionsDropdown(AdvancedDropdownState state) : base(state) { }