IvanMurzak / Unity-Theme

Create palettes of colors and components for change specific color on a specific visual element. Very useful to UI.
MIT License
99 stars 6 forks source link

Themes #2

Closed iiidefektiii closed 1 year ago

iiidefektiii commented 1 year ago

I am trying to extend this package to fit what I am trying to do. How can I access themes list in ThemeDatabase? It doesn't recognize theme as a property even though its used in the script.

Also I see no functionality to allow for runtime changes for things like toggles. Changing from a toggle active to toggle inactive. Most functionality is not exposed to account for it.

Also another issue I came across was hidden objects when a theme is changed do not update even when the object become active.

IvanMurzak commented 1 year ago

Hello,

I am trying to extend this package to fit what I am trying to do. How can I access themes list in ThemeDatabase? It doesn't recognize theme as a property even though its used in the script.

'ThemeDatabase' class are made from multiple separate '.cs' files, the 'themes' collection exists in 'ThemeDatabase.Editor.cs'. I split that code because that is needed only for rendering in Unity Editor inspector window. Do you want to inherit from the class?

Also I see no functionality to allow for runtime changes for things like toggles. Changing from a toggle active to toggle inactive. Most functionality is not exposed to account for it.

The amount of ColorBinder components are limited, but it is super ease to make your own custom ColorBinder, just need to inherit from 'BaseColorBinder' class and implement few lines. Take a look for this class as an example - 'SpriteRendererColorBinder'.

Also another issue I came across was hidden objects when a theme is changed do not update even when the object become active.

Good point, I will fix it.

iiidefektiii commented 1 year ago

Thanks for the response @IvanMurzak. This package could be very useful.

I am trying to extend this package to fit what I am trying to do. How can I access themes list in ThemeDatabase? It doesn't recognize theme as a property even though its used in the script.

'ThemeDatabase' class are made from multiple separate '.cs' files, the 'themes' collection exists in 'ThemeDatabase.Editor.cs'. I split that code because that is needed only for rendering in Unity Editor inspector window. Do you want to inherit from the class?

This one is because I want to use a json file that contains the theme properties and their color, but set it at runtime. because I cannot access theme directly it will duplicate itself every time without doing a check to see if it exists. Weird one I know but there is a reason I am trying it at runtime.

The amount of ColorBinder components are limited, but it is super ease to make your own custom ColorBinder, just need to inherit from 'BaseColorBinder' class and implement few lines. Take a look for this class as an example - 'SpriteRendererColorBinder'.

I have made my own, but in order to swap properties its using at runtime I need to change the "Color Name" property even on the Image Color Binder. At least this seems to be the best approach but anything I've tried I cannot change the Color Name at runtime in code. Right now my only solution is to have 2 Color Binders one for Active and one for Inactive and switch (enable) them when the toggle is clicked.

Also another issue I came across was hidden objects when a theme is changed do not update even when the object become active.

Good point, I will fix it.

I'm not sure how this will work, you have it setting on enable but if you have a parent RectTransform hidden and enable it the child does not update because it was never turned off to enable, the parent was. Right now my work around is using CanvasGroups that Show or Hide by setting the groups alpha to 0 or 1 so I am not hiding any RectTransform directly.