private void Draw() { _searchString = ToolbarSearchUI.DrawHorizontal(_searchString); foreach (var option in string.IsNullOrEmpty(_searchString) ? _options : _options.Where(x => Regex.IsMatch(x, _searchString, RegexOptions.IgnoreCase))) { GUILayout.BeginHorizontal(GUI.skin.box); if (GUILayout.Button(option, GUIStyle.none, GUILayout.Height(20f), GUILayout.Width(position.width - 15f))) { _selectAction(option); Close(); } GUILayout.EndHorizontal(); } }
private void DrawComponentsUI() { _searchString = ToolbarSearchUI.DrawHorizontal(_searchString); var dict = new Dictionary <string, Type>(); if (string.IsNullOrEmpty(_searchString)) { foreach (var componentType in _possibleComponents) { dict.Add(componentType.FullName, componentType); } } else { foreach (var component in _possibleComponents.Where(x => Regex.IsMatch(x.Name, _searchString, RegexOptions.IgnoreCase))) { dict.Add(component.Name, component); } } foreach (var component in _entityComponents) { dict.Remove(component.Type.Name); } foreach (var key in dict.Keys) { GUILayout.BeginHorizontal(GUI.skin.box); if (GUILayout.Button(key, GUIStyle.none, GUILayout.Height(20f), GUILayout.Width(position.width - 15f))) { try { var component = Activator.CreateInstance(dict[key]) as IComponent; _entityComponents.Add(component); } catch (Exception e) { Debug.LogError(e); throw; } Close(); } GUILayout.EndHorizontal(); } }
private void SelectItem() { var proptypes = SettingHelper.PrototypeSettings.Settings.Select(x => x.Name).ToArray(); GUILayout.BeginHorizontal(); _searchString = ToolbarSearchUI.DrawHorizontal(_searchString); if (GUILayout.Button("", GUIStyleHelper.Plus, GUILayout.Height(18), GUILayout.Width(18f))) { SelectWindow.Show("Select Blueprint", proptypes, AddItem); } GUILayout.EndHorizontal(); var items = (string.IsNullOrEmpty(_searchString) ? SettingHelper.BlueprintSettings.Settings : SettingHelper.BlueprintSettings.Settings.Where(x => Regex.IsMatch(x.Name, _searchString, RegexOptions.IgnoreCase))) .OrderBy(x => x.Name) .ToList(); _scroll = GUILayout.BeginScrollView(_scroll); for (int i = 0; i < items.Count; i++) { GUILayout.BeginHorizontal(); if (GUILayout.Button(items[i].Name)) { GUI.FocusControl(""); _itemObject = new SerializedObject(items[i]); _selected = items[i]; } if (GUILayout.Button("", GUIStyleHelper.Minus, GUILayout.Width(18))) { DestroyImmediate(items[i], true); SettingHelper.BlueprintSettings.Settings.RemoveAll(x => x == null); AssetDatabase.SaveAssets(); SettingHelper.BlueprintSettings.SetDirty(); } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); }
private void DrawBlueprintUI() { _searchString = ToolbarSearchUI.DrawHorizontal(_searchString); foreach (var blueprintSetting in SettingHelper.BlueprintSettings.Settings) { GUILayout.BeginHorizontal(GUI.skin.box); if (GUILayout.Button(blueprintSetting.Name, GUIStyle.none, GUILayout.Height(20f), GUILayout.Width(position.width - 15f))) { try { _entityComponents.Clear(); _entityComponents.AddRange(blueprintSetting.Components.DeepClone()); // add component wrappers to gameObject if (_target != null && _entityComponents != null) { foreach (var entityComponent in _entityComponents.Where(x => x.WrapperType != null)) { if (_target.GetComponent(entityComponent.WrapperType) == null) { _target.AddComponent(entityComponent.WrapperType); } } } } catch (Exception e) { Debug.LogError(e); throw; } Close(); } GUILayout.EndHorizontal(); } }