stride icon indicating copy to clipboard operation
stride copied to clipboard

WIP fix: make hue non nullable

Open IXLLEGACYIXL opened this issue 1 year ago • 8 comments

PR Details

makes property hue non nullable as its a non allowed type for attribute properties.

Types of changes

  • [ ] Docs change / refactoring / dependency upgrade
  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

There is no usage in stride of that field thats why it was unnoticed when it was made nullable. I dont know how to test it out. So i need help someone knowing how to test that out in a project.

IXLLEGACYIXL avatar Jun 23 '24 21:06 IXLLEGACYIXL

Technically is a breaking change as float is a value type, so the compiler previously used Nullable<float> for the property type, and that's now becoming a float.

Looks good to me though. I doubt that's going to affect anyone.

fydar avatar Jun 23 '24 21:06 fydar

Technically is a breaking change as float is a value type, so the compiler previously used Nullable<float> for the property type, and that's now becoming a float.

Looks good to me though. I doubt that's going to affect anyone.

previous version didnt even compile if you wanted to set it image

as only primitives are supported, nullable isnt a primitive

IXLLEGACYIXL avatar Jun 23 '24 22:06 IXLLEGACYIXL

The good news is this does let me use the CustomHue property but it doesnt seem to change anything in the editor.

image

[Display("Test", CustomHue = 100f)]
public class Test : SyncScript
{

	[Display("ModelComponent", CustomHue = 250f)]
	public ModelComponent ModelComponent { get; set; }
}

Doprez avatar Jun 23 '24 23:06 Doprez

This somehow breaks the dynamic colour of the Raw file thumbnails.'

uncompressed thumbnail before change image

compressed thumbnail before change image

with this change the thumbnail stays a single colour for some reason with or without a proper value: image

Doprez avatar Jun 24 '24 00:06 Doprez

This somehow breaks the dynamic colour of the Raw file thumbnails.'

That's because CustomHue's function is to affect the thumbnail, not the property header (which kinda makes this feature a bit useless)

It's only used here: https://github.com/stride3d/stride/blob/b40ad46edc2a3ccb1b31bfb4a81eb762d42221ae/sources/editor/Stride.Editor/Thumbnails/CustomAssetThumbnailCompiler.cs#L50 Which is where the thumbnail asset then uses as the color: https://github.com/stride3d/stride/blob/b40ad46edc2a3ccb1b31bfb4a81eb762d42221ae/sources/editor/Stride.Editor/Thumbnails/ThumbnailFromTextureCommand.cs#L79

The thumbnail only persists as a single color (for a given asset) because displayAttribute?.Name.GetHashCode() or type.Name.GetHashCode() are getting hashcodes from strings which are not persistent hashcodes between different sessions (though should persists in a single app session).

As for whether CustomHue ever affected the property header...? Not sure it did? If not, in my opinion a hex string property would be more user friendly instead of using this.

As an FYI, the background color of the header is set here (which is currently not changeable): https://github.com/stride3d/stride/blob/b40ad46edc2a3ccb1b31bfb4a81eb762d42221ae/sources/editor/Stride.Core.Assets.Editor/View/DefaultPropertyTemplateProviders.xaml#L260

Basewq avatar Jul 16 '24 05:07 Basewq

so is that property just useless in the end? seems like a leftover

if oyu set hue color the color stays the same for the thumbnail sooo its anyway pointless as the intention is different?

IXLLEGACYIXL avatar Jul 17 '24 10:07 IXLLEGACYIXL

Very low value since none of the existing assets use it. I would point out that it is technically possible to inherit Asset (or AssetWithSource) and set the Display -> ColorHue for your own custom asset, however creating your own custom asset that appears in the editor involves a lot of setup, so I don't think anyone is aware of this or does this.

Basewq avatar Jul 17 '24 10:07 Basewq

currently setting hue value doesnt compile, and nobody complained

IXLLEGACYIXL avatar Jul 17 '24 10:07 IXLLEGACYIXL