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 Kitokid · Mar 15, 2015 at 07:03 PM · c#variableguitext

can´t link a gui text to my script

hey guys im new to unity and i got the following problem : (i use unity 5.0 so i didnt found any usefull tutorials) i want to edit a GUIText with my script but when i try to link my GUIText to my variable in the script it basicly do not work and im not sure what i did wrong (i already did it with a normal sphere and it works so basicly i know how it is supposed to work) would be rly nice if u can help me out:) (here is my script may i did there something wrong aswell)

the script is about moving a sphere and collect some objects so your score increases and yeah the i cant eddit the guitext to display the score using UnityEngine; using System.Collections;

public class PlayerMovement : MonoBehaviour { private int count; public GUIText countText; //this is the variable i want to be linked public float speed; public Rigidbody rb; void Start() { rb = GetComponent (); count = 0; countText.text = "Count: " + count.ToString (); } void FixedUpdate () { float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertical = Input.GetAxis ("Vertical"); Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical); rb.AddForce (movement * speed); } void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Pick-Up") { other.gameObject.SetActive (false); count = count + 1; countText.text = "Count: " + count.ToString (); } } }

Comment
Add comment · Show 4
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 dr3th · Mar 17, 2015 at 03:18 PM 2
Share

Please format the Code Properly using the code button.

avatar image Hmmcrunchy · Apr 02, 2015 at 06:39 PM 0
Share

HI I second this, not sure about you $$anonymous$$itokid but im trying the rolling ball tutorial off unity site -

the part where you create a GUIText and set its value in the code you cant then drag a text panel on to the players counttext variable as it needs a GUI text and there does not appear to be a GUI Text component anymore ??!

do we use UI and change the code - bit of a newbie here

avatar image KdRWaylander · Apr 03, 2015 at 07:13 AM 0
Share

Hi,

You should find some useful hints here: http://answers.unity3d.com/questions/937681/how-do-i-pop-up-a-canvas-when-a-click-some-key-fro.html

But ins$$anonymous$$d of a Canvas you want to use a Text and you don't need the "press on a key" part.

avatar image Hmmcrunchy · Apr 03, 2015 at 09:29 AM 0
Share

Thanks :) just found the part about using render to create a new GUI text which works

Thanks for reply

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to change font size in ongui function 0 Answers

Problem with getting component, help please? ^^' 2 Answers

Renderer on object disabled after level reload 1 Answer


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