Exemplo n.º 1
0
    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();
    }
Exemplo n.º 2
0
    private static void DisplayComponentMenu(BlueprintSettings settings, IComponent component)
    {
        var evt      = Event.current;
        var mousePos = evt.mousePosition;

        EditorUtility.DisplayCustomMenu(
            new Rect(mousePos.x, mousePos.y, 0, 0),
            new[]
        {
            // todo: copy\paste
            new GUIContent("Remove Component"),
        },
            -1,
            (data, options, selected) =>
        {
            switch (options[selected])
            {
            case "Remove Component":
                settings.Components.Remove(component);
                break;
            }
        }, null);
        evt.Use();
    }
Exemplo n.º 3
0
 public BlueprintGenerator(string path, BlueprintSettings settings)
 {
     _path     = path;
     _settings = settings;
 }