Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
2
Question by Trash-_-Panda · Aug 13, 2020 at 04:43 PM · canvaslagperformance optimizationbuild settings

Enabling canvas lags build, but only the first time on the first load

The Problem

So I've got a branching dialogue system that I'm pretty happy with so far, but the full build of the game lags for about half a second on machines that aren't dedicated gaming computers when the first dialogue is opened but only the first time the dialogue is opened and only the first time the game is loaded. I've tried to work in every optimization I could find for canvas drawing (all but two of the fourteen items starts with the canvas relevant components disabled, so unless two static images and a canvas scalar are destroying performance I'm not sure what's going on) and update functions that might cause expensive calculations have if statements to prevent them doing those calculations when unnecessary


Chart of the dialogue system

alt text


Relevant code for dTrigger

     void Start()
     {
         player = FindObjectOfType<IsoPlayerMovement>();
         spriteRenderer = GetComponent<SpriteRenderer>();
         characters = FindObjectsOfType<DialogueTrigger>();
     }
 
     void Update()
     {
         if(!player.inConversation)
         {
         distanceToPlayer = Vector3.Distance(player.transform.position, transform.position);
             if(distanceToPlayer < talkRange)
             {
                 bool closest = true;
                 foreach(DialogueTrigger character in characters)
                 {
                     if(character.distanceToPlayer < distanceToPlayer)
                     {
                         closest = false;
                         spriteRenderer.color = Color.gray;
                     }
                 }
 
                 if(closest)
                     {
                         spriteRenderer.color = Color.green;
 
                         if(Input.GetKeyDown(KeyCode.Space))
                         {
                             player.inConversation = true;
                             dialogueCanvas.GetComponent<Canvas>().enabled = true;
                             dialogueCanvas.GetComponent<DialogueManager>().SetEnabled();
                         }
                     }
             }
             else
             {
                 spriteRenderer.color = Color.gray;
             }
         }
     }


dialoguetree.png (25.4 kB)
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image elpramnoj · Jan 11, 2021 at 02:13 PM 0
Share

Have you discovered any more information on this problem? Having a similar issue. First time enabling a world-space canvas produces a considerable lag spike for me. Considering doing some ugly hacky thing and "pre-loading" it when the scene loads but would prefer an actual solution.

avatar image Trash-_-Panda elpramnoj · Jan 11, 2021 at 11:11 PM 0
Share

In short: I did the ugly hacky thing and preloaded the assets that were causing performance issues

I also followed some of the advice I found here: https://create.unity3d.com/Unity-UI-optimization-tips like putting separate canvases on different chunks of the UI and disabling the canvas instead of the object the canvas is on. I think I turned off all the graphic raycasters I wasn't using. But I'm also using overlay canvases so your mileage may vary. Hope this helps!

avatar image elpramnoj Trash-_-Panda · Jan 11, 2021 at 11:29 PM 0
Share

Interesting, thank you for responding! In case any other poor souls find their way here, I ended up doing something different. Found buried in another thread, somebody suggested using a canvas group to control the opacity of the canvas and to leave the canvas active. Since the canvas I was having issues with is very $$anonymous$$imal, it wasn't a big deal to leave it active; this was the easiest solution.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

218 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

FPS drop beacause Dialog with 200 images in it 0 Answers

Not in a hurry, but does anybody wanna share some good optimization practices? 0 Answers

Does using multiple World Space Canvases affect performance? 0 Answers

Bad Performance URP 0 Answers

MoveTowards used on a path causes lag in build 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges