Code Change Requests

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Raidenthequick
Posts: 34
Joined: Mon Jul 02, 2018 5:00 pm

Code Change Requests

Post by Raidenthequick »

Hey Tony,

I have made a couple code changes on my end that I have to reapply every time I update Dialogue System, which is quite irritating to do. I hope you think they are beneficial changes though, and request for you to add them, or some equivalent, into the core product, which would alleviate this for me and hopefully improve the product as well!

1. Sequencer Fade command

Problem: Depending on the speed of fade and perhaps the client's machine, sometimes we noticed that fading out would not go COMPLETELY BLACK. I'm talking the most slight thing, maybe alpha 254 as opposed to 255.

My solution: Change the sequencer command's OnDestroy method to set the alpha to a hard 0 or 1, like so:

Code: Select all

        public void OnDestroy()
        {
            if (faderCanvas != null) faderCanvas.gameObject.SetActive(stay);
            if (faderImage != null)
            {
                float alpha = fadeIn ? 0.0f : 1.0f;
                faderImage.color = new Color(color.r, color.g, color.b, alpha);
                faderImage.gameObject.SetActive(stay);
            }
        }
2. Proximity Selector

Problem: If I despawn a GameObject or set it to inactive in the scene hierarchy mid-cutscene,, the Proximity Selector's "usablesInRange" list still counts these as valid usables, which caused a few issues for us.

My solution: Clean up the usablesInRange list on CheckTriggerExit (one actual line added, rest are comments):

Code: Select all

        protected virtual void CheckTriggerExit(GameObject other)
        {
            Usable usable = other.GetComponent<Usable>();
            if (usable != null && usable.enabled)
            {
                if (usablesInRange.Contains(usable)) usablesInRange.Remove(usable);
                if (currentUsable == usable)
                {
                    OnDeselectedUsableObject(usable);
                    toldListenersHaveUsable = false;
                    Usable newUsable = null;
                    
                    //remove all that are null / inactive
                    usablesInRange.RemoveAll(usa => usa == null || !usa.gameObject.activeInHierarchy);
                    //NEW LINE HERE ^^^^
                    
                    if (usablesInRange.Count > 0)
                    {
                        newUsable = usablesInRange[0];
                        OnSelectedUsableObject(newUsable);
                        toldListenersHaveUsable = true;
                    }
                    SetCurrentUsable(newUsable);
                }
            }
        }
Would greatly appreciate these, or again something like these if you have a better alternative in mind, to be added in! Appreciate all the work you've done and continued to do for us.
User avatar
Tony Li
Posts: 21080
Joined: Thu Jul 18, 2013 1:27 pm

Re: Code Change Requests

Post by Tony Li »

Hi,

I just added similar code for ProximitySelector to the next release. It'll be in version 2.1.5.

I'll add the Fade command fix to version 2.1.5 also. Thanks for reporting that and sharing your solution.
Raidenthequick
Posts: 34
Joined: Mon Jul 02, 2018 5:00 pm

Re: Code Change Requests

Post by Raidenthequick »

Excellent, thanks!
Raidenthequick
Posts: 34
Joined: Mon Jul 02, 2018 5:00 pm

Re: Code Change Requests

Post by Raidenthequick »

Hey Tony,

I appreciate you making the fade change as requested here, but haha I'm pretty sure you broke fades, unfortunately!

This line during OnDestroy is currently:

Code: Select all

faderImage.color = new Color(color.r, color.g, color.b, fadeIn ? 1 : 0);
But it should be the other way around, with 0 : 1, since fading IN needs to END on it fully hidden (and the converse), same as my code in this thread has it. Will this be fixed for next version? Thanks!
User avatar
Tony Li
Posts: 21080
Joined: Thu Jul 18, 2013 1:27 pm

Re: Code Change Requests

Post by Tony Li »

Oops! I'll be submitting a new version this weekend since the evaluation version requires a small change for Unity Timeline in Unity 2019.1. (Timeline is in a separate package now, so the eval DLL needs to be updated to know this.) I've already made the change to the Fade() command for the new version.
Post Reply