Search Unity

Custom editor broken, more specifically gradient interpolation algorithm

Discussion in 'Editor & General Support' started by TheRebirth2393390183, Jan 13, 2020.

  1. TheRebirth2393390183

    TheRebirth2393390183

    Joined:
    Jun 5, 2017
    Posts:
    8
    Edit: Looks like I posted this thread in a wrong section. Sorry.
    I wrote a few scripts for a custom editor (which is a modified version of KamakuraShader https://github.com/kayac/kamakura-shaders) where it displays a ReorderableList and each element in this list itself is also a list of gradients. In this editor I expect to be able to insert, remove, move up, move down gradients in each GradientGroup. While I'm editing gradients, the texture asset that belongs to this asset should also be updated.
    So far there're still multiple issues. Most of them are minor issues that do nothing more than affecting user experiences, including:
    1.Editor control feels very laggy since there's always a 0.3s~1.0s delay between mouse hover and highlight's appearing, while profilers only came up with a few spikes of less than 20ms CPU time.
    2.Insert / Remove / Move Up / Move Down works, but gradients don't update until I click one of those.
    3.Realtime texture update doesn't work, which is why I added a "Refresh" button.

    However there's one single problem that makes this custom editor unusable (not completely broken though): if I have gradients with more than 2 color keys, textures generated with these settings will look wrong.
    https://i.postimg.cc/CKhT5JX3/Snipaste-2020-01-14-00-31-49.png

    Now I'm stuck on this issue for a whole day. I wanted to post this on Unity Answers but unfortunately the upload function was broken. Also, I'm sorry if there's to much code.
    For now I want to focus the last issue, which is the gradient interpolation algorithm in UpdateTexture() function in GradientListAssetEditor.cs, more specifically between line 462 and line 517. Any suggestion is appreciated!:)
     

    Attached Files: