Unity-UI-Extensions/com.unity.uiextensions

CUIImage sets NaN's to prefab if used with Content size fitter

solidsign opened this issue · 5 comments

When CUIImage and Contant size fitter assigned to one gameobject field "refCurvesControlRatioPoints" is written with NaNs, so the image itself stops being visible

Always just after Contant size fitter assign:
image

ok, I located the problem it in CUIGraphic line 312-315
you divide by rectTrans.rect.width and height but on first refresh they both are zero as layout group is not updated yet and get NaN

smth stupid like making refresh calls delayed removes all the NaNs
public void Refresh() { Invoke(nameof(Refreshx), 0.3f); }
public void Refreshx() {

Thanks for spotting this, will ensure this is included in the next release!

    public void Refresh()
    {
        StartCoroutine(RefreshOnNextFrame());
    }

    public IEnumerator RefreshOnNextFrame()
    {
        yield return new WaitForEndOfFrame();

        ReportSet();

With your fix CUI does not update in editor because of:

Coroutine couldn't be started because the the game object 'xxx' is inactive!
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

Ahh, good old Unity, thanks for the call out @solidsign , will move this back to in-progress and review.

OK, after much musing and tweaking it seems your solution is the only one that will work in the editor, because Unity. Tried several other solutions which sadly all resulted in the same issue.
Also eventually got what you meant by "not working in the editor", given the changes to the curves wouldn't do anything until you switched to game view and changed the viewport.

THanks again for the update @solidsign , pushing to the 2.3 release