Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component Drawer for CompoentID #36

Open
rapushka opened this issue Nov 6, 2023 · 0 comments
Open

Component Drawer for CompoentID #36

rapushka opened this issue Nov 6, 2023 · 0 comments
Milestone

Comments

@rapushka
Copy link
Owner

rapushka commented Nov 6, 2023

the way, how it may work:

[UsedImplicitly]
public class IdDrawer : IComponentDrawer
{
  public bool HandlesType(Type type) => type == typeof(FavoriteComponent);

  public IComponent DrawComponent(IComponent component)
  {
    var componentID = ((FavoriteComponent)component).Value;
    var names = ComponentsLookup<GameScope>.Instance.ComponentNames;
    var temp = EditorGUILayout.Popup(nameof(componentID.Index), componentID.Index, names);
#if DEBUG
    componentID.Name = names[temp];
#endif
    return component;
  }
}

for component:

[GameScope] public sealed class FavoriteComponent : ValueComponent<GameComponentID> { }

and also it requres

[Serializable]
public class ComponentID<TScope> : ComponentIDBase
  where TScope : IScope
{

// ...

#if DEBUG
  public string Name
  {
    set
    {
      _name = value;
      _cashedIndex = null;
    }
  }
#endif

// ...

}
@rapushka rapushka added this to the v0.0.2 milestone Nov 6, 2023
@rapushka rapushka modified the milestones: v0.1.0, v0.2.0 Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant