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 /
avatar image
0
Question by brycem24 · Oct 05, 2014 at 01:43 PM · uibuttonclickeventsystem

Button is not being clicked.

Hi I have been working on a project for the last month or so and I ended up screwing it up badly last night (deleting ground and other stuff) and now once I had it back up and running my NPC's are not working (which is odd because they were not affected). They use Unity's new UI and the way it works is that when you press the button (the dialogue box) it iterates a variable in a script I named count and the dialogue boxes text is the counts text. But count will not iterate. I believe this is because of my lacking of knowledge with Event Systems. It is quite likely one had been deleted and I am just unsure where to place it this time but my buttons appear to be non interactable. I had found a spot for my Event System for when my mouse hovers over it, it appears to light up but the clicking does not work. I feel as though in that position the Event System takes control of my button and it no longer works. So in conclusion I have an NPC with a button that cannot be pressed. Any help is much appreciated.

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 767_2 · Oct 05, 2014 at 01:46 PM 0
Share

show the button script here

avatar image brycem24 · Oct 05, 2014 at 02:08 PM 0
Share

using UnityEngine; using UnityEngine.UI; using System.Collections;

public class chattingScript : $$anonymous$$onoBehaviour

{ public GameObject dialogueBox; public GameObject chatBubble;

 public GameObject storeWindow;
 public Text dialogueText;
 private string targetDialogue;

 public static bool isChatting = false;

 public string[] dialogue = new string[5];
 public int maxDialogue;

 public int count = 0;

 private int numSentences;
 
 private bool isFinished;

 public enum NPCType{Dialogue, Vendor};

 public NPCType myType;

 private char _nextChar;
 private int _nextCharIndice;


 public static bool isInteracting;

 void Start()
 {
     dialogueBox.SetActive(false);
     chatBubble.SetActive(false);
     count = 0;

     storeWindow.SetActive(false);

     targetDialogue = dialogue[count];
     dialogueText.text = null;

     isFinished = false;

 //    StartCoroutine(DisplayText(5f));
 }

 void OnTriggerEnter(Collider col)
 {
     dialogueBox.SetActive(true);
     isChatting = true;
     //InvokeRepeating("TextTyper", 0.5f, 0.5f);
 }

 void OnTriggerExit(Collider col)
 {
     dialogueBox.SetActive(false);
     storeWindow.SetActive(false);
     count = 0;
     isChatting = false;
 }

 void Update()
 {
     dialogueText.text = dialogue[count];


     if (count == 1 && isChatting != true)
     {
         isChatting = true;
     }

     else if (count == 0)
     {
         isChatting = false;
     }

     else if (count >= maxDialogue)
     {
         if (myType == NPCType.Vendor)
         {
             storeWindow.SetActive(true);
             dialogueBox.SetActive(false);
             chatBubble.SetActive(false);
         }
         
         else
             isChatting = false;
     }

     else if(count > maxDialogue)
     {
         storeWindow.SetActive(true);
         dialogueBox.SetActive(false);
         chatBubble.SetActive(false);
     }


     if (isChatting == true || inventoryScript.isOpen == true || trickortreatScript.isTricking == true)
     {
         isInteracting = true;
     }

     else
     {
         isInteracting = false;
     }
 }
 /*
 IEnumerator DisplayText(float delayTime)
 {
     delayTime = 10f;

     for (int i = 0; i < targetDialogue.Length; i++)
     {    
         int initialCount = count;
         Debug.Log(dialogueText.text);
         Debug.LogError(count);
         if (dialogueText.text.Length != targetDialogue.Length)
         {
             char _nextChar = targetDialogue[i];
             dialogueText.text += _nextChar;
             for (int j = 0; dialogueText.text.Length != targetDialogue.Length; j++)
             {
                 yield return new WaitForSeconds(10f);
                 if (j == dialogueText.text.Length)
                 {
                     break;
                 }
             }
         }
         else
         {
             isFinished = true;
         }

     }

 }
  */


That is for displaying the right text. Currently the way it works is that is has a button that has the OnClick thing having it so it calls OnClick in my script which iterates count.alt text

click.png (2.8 kB)
avatar image brycem24 · Oct 05, 2014 at 02:09 PM 0
Share

Sorry it cut off a piece

This part is the part that is called when the button is clicked

 public void OnClick()
 {
     Debug.Log("I was clicked");
     count += 1;
 }

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by unimechanic · Oct 08, 2014 at 02:56 PM

They use Unity's new UI

You can also ask in the Beta group where our developers can investigate the issue.

Comment
Add comment · Share
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

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

29 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

Related Questions

Detect UI Button Click Event in Update method 3 Answers

Unity 4.6's button Bug? 1 Answer

On Button Click Enable - Disable GameObject Through Inspector 1 Answer

How to change selected button in EventSystem or deselect it 5 Answers

Use Event Triggers or something similar on non-UI objects? 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