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 matta9001 · Sep 18, 2014 at 12:57 AM · javascript4.6beta

Unity 4.6 beta button with Javascript rather than C#

I don't know how much experience you guys have with the new beta. But i am in a bad position because all the new tutorials and explanations are in C#. I should probably learn it, but i would rather not at the moment. But the new gui button has an option to fire a public class. I dont really exactly know what it is because i use Javascript. But i tried making my function a static function, did not show up, a public function, it did not show up. Is there some sort of prefix i should put before the function. Because i just want it to fire a function from a different gameobject.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Anxo · Sep 18, 2014 at 01:20 AM

I have not messed with the new Beta but I know the new GUI is based on the NGUI which I do use and its buttons trigger a public void method inside of a class.. (a function inside of a script). If you wish to continue using Javascript while using these buttons you could write a small C# script that just sends button calls along but it would be very inconvenient. Something like this.

 // All scripts in C# and this stuff. 
 using UnityEngin;
 using System.Collection;
 
 public Class ButtonExtention : Monobehaviour {
   /// Here is where the actual script is. where all the content goes. 
 public GameObject JavascriptButtonReciver;
 
 public void ButtonA{
  // Button A was pressed, Send it to the javascript
  JavascriptButtonReciver.BroadcastMessage("ButtonA");
 }
 public void ButtonB{
  // Button B was pressed.
 JavascriptButtonReciver.BroadcastMessage("ButtonB");
 }
 
 }

This would allow you to make as many public voids receivers as you want and then have the message relayed to your javascript as "BraodcastMessage" works the same in Javascript as it does in C# so you can broadcast messages from one to the other.

Forgive the errors as I am not near Unity to test the code. But you get the idea.

Comment
Add comment · Show 4 · 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
avatar image matta9001 · Sep 18, 2014 at 01:39 AM 0
Share

I am sure the developers of unity have sort of implemented something so that us javascript coders can actually make use of the new features. I see what you are saying in the script you wrote, but this might be too much work for something that might be pretty simple

avatar image Eric5h5 · Sep 18, 2014 at 02:29 AM 0
Share

It's not based on NGUI.

avatar image Anxo · Sep 18, 2014 at 02:04 PM 0
Share

Its not? I thought the they hired the guys who made NGUI to make the new GUI system. It even looks very similar in the videos.

avatar image HarshadK · Sep 18, 2014 at 02:16 PM 0
Share

He initially worked on that but later he left and since then Unity GUI has deviated from NGUI a lot.

To quote Aron $$anonymous$$ook (NGUI guy) from his forum itself (New Unity GUI and NGUI):

I left Unity back at the end of November last year after working there for 13 months. NGUI and uGUI are completely different systems now and I can't comment much on uGUI beyond what was said in the past. I'll leave the talking to those who are actively developing it (and there are quire a few very talented guys on it).

I am focusing on NGUI because it's also what I am using myself in my own projects (currently Windward). The development / fixes / polish happen naturally.

avatar image
0

Answer by orb · Sep 18, 2014 at 01:40 AM

Well, you can do it the same way as in C#:

 #pragma strict
 
 import UnityEngine.EventSystems;
 
 class Filth extends MonoBehaviour implements IPointerEnterHandler
 {
     function OnPointerEnter(data : PointerEventData)
     {
         Debug.Log(data.position.x+", "+data.position.y);
     }
 }

You can implement any of the events like that. You just need to explicitly declare a class and not lazily just fill a file with methods. But now you're getting close to the verbosity of C# and still not getting faster compile times or namespaces ;)

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

25 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

Related Questions

A node in a childnode? 1 Answer

How to have no alignment 4.6 GUI 0 Answers

IPhone doesn't use same UI as in Game view in Unity 1 Answer

unity 4.6 button functions? 1 Answer

Unity webplayer crashing browser when it is loaded and unloaded into a page using JavaScript 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