Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
avatar image
0
Question by Spid3rtech · Feb 10, 2017 at 07:08 PM · uicanvaslaginteractionfix

Interacting with sign, canvas lags when activating.

So I have a script where when I get into the radius of my sign an image of the keyboard letter "E" will pop up so the player knows that they need to press "E" to interact. Once they do interact, I activate two items that are on a canvas, and which are disabled before the game even starts. Once they press "E" the signs background UI pops up(The color behind the text), and the signs text itself pops up. The only problem is that when you press "E" the game freezes for about 2 seconds and then the UI pops up. But keep in mind that it does not lag in Unity itself, only in the build, and I have tried it on multiple computers, so it's not just mine acting up.

My question is, is there any way to make UI pop up smoothly and not make the game lag? I know you could try putting it on a different layer and just switch layers when they interact(I think that works), but are there any other ways? Thank you for any help that I get. :)

Also, here is the script for the sign: using System.Collections; using System.Collections.Generic; using UnityEngine;

 public class Signs : MonoBehaviour {
 
     [SerializeField]
     private GameObject signText;
     [SerializeField]
     private GameObject signBackground;
     private bool signOpen;
     private bool inRadius;
     [SerializeField]
     private Transform player;
     private float distance;
     [SerializeField]
     private float distanceUntilInteraction;
     [SerializeField]
     private GameObject eImage;
 
     // Update is called once per frame
     void Update () {
 
         distance = Vector3.Distance(transform.position, player.position);
 
         if (distance < distanceUntilInteraction)
         {
             inRadius = true;
             eImage.SetActive(true);
         }
 
         else
         {
             inRadius = false;
             eImage.SetActive(false);
         }
 
         if (Input.GetKeyDown("e") && signOpen == false && inRadius == true)
         {
             signText.SetActive(true);
             signBackground.SetActive(true);
             signOpen = true;
         }
 
         else if (Input.GetKeyDown("e") && signOpen == true || inRadius == false)
         {
             signText.SetActive(false);
             signBackground.SetActive(false);
             signOpen = false;
         }
     }
 }
 
Comment
Add comment · Show 1
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 hexagonius · Feb 11, 2017 at 04:45 PM 0
Share

the easiest would be to create a development build with auto attach profiler option and then running it on the target device. the profiler should spike the moment it lags.you should then be able to see what's causing the performance impact in the Profiler

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

2 canvases working weird with buttons 0 Answers

Lags when clicking so many times,Have problem when clicking so many times 1 Answer

UI 4.6 Text - Bad call to Text or bug? 1 Answer

Can't click or highlight a button. 0 Answers

Select material of Canvas Renderer 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