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 svettgunnar · Sep 25, 2011 at 02:36 PM · dodoes

What does this cript do?

Know that this is perhaps an odd question to ask but what does this script do?

 //variables which construct the Rectangle

var Rect = Rect(Screen.width,Screen.height,Screen.width,Screen.height);
var HorizontalPositionx : float;
var VerticalPositiony : float;
var Width : float;
var Height : float;
var particle : GameObject;

var custom : GUIStyle;

function Update(){
Rect.y = Screen.height/VerticalPositiony;
Rect.x = Screen.width/HorizontalPositionx;
Rect.height = Screen.height/Height;
Rect.width = Screen.width/Width;
if (Rect.Contains(Input.mousePosition)){
if(Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began){

// Create a particle if hit

         Instantiate (particle, transform.position, transform.rotation);  

         Application.LoadLevel(0);  

     }

 }

}

//you can edit this to show whatever your button is later but for now this just shows where your rect is

function OnGUI(){

GUI.Box(Rect, "Button Rect", custom);

}

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 Bunny83 · Sep 25, 2011 at 04:09 PM

What the script does? - well, a lot senseless and strange things:

  • The whole rectangle setup doesn't make any sense. HorizontalPositionx, VerticalPositiony, Width and Height doesn't reflect pixel or viewport coordinates. They follow an 1/x - behaviour which is kinda useless.

  • I don't worked much with iPhone / Android but as far as i know Input.mousePosition won't work there. That's why you have the Touch-class. Using both methods will probably prevent the code inside the if from ever being executed. Furthermore the Touch class is not available at other platforms so you can't even create a build for them.

  • The particle generation seems right so far, but executing LoadLevel right after Instantiate makes the Instantiate call useless since all scene objects are deleted after the new level has been loaded.

Comment
Add comment · Show 1 · 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 svettgunnar · Sep 25, 2011 at 05:19 PM 0
Share

Ok, can you tell me how I can make it work? so when I click on a GUI or 3d text or something on an Android/IOS a scene will load...

the only thing I want to work is when I click on a a text in a menu on a phone a scene will load.

avatar image
0

Answer by unluckyBastard · Sep 25, 2011 at 02:57 PM

When you touch an area in the Rect, a particle is instantiated.

Comment
Add comment · Show 1 · 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 svettgunnar · Sep 25, 2011 at 03:41 PM 0
Share

Can you be more specific?

What happens? I mean, how does this work... do I haft to add this script to the main camera and then add an gui text or what?

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

gameObject.GetComponent("Script").enabled = true not working 5 Answers

Creating Dropdown menue for variables in the Inspector using C# 1 Answer

Are there any errors in this bullet script? 1 Answer

Where does GUI end up? 1 Answer

Stop Camera Following Player When Descending 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