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 octaviomejiadiaz · Nov 08, 2012 at 03:41 AM · guigameobjectbutton

GameObject touchable instead GUI button

i have this

 if( GUI.Button( new Rect( xPos, yPos, width, height ), "Start Video Texture Two" ) )
         {
             // create the video texture
             _videoTextureTwo = new VideoTexture( "skyfall.m4v", 480, 264, false, 0, true );

}

i want to make instead a GUI button make a GameObject for example an cube touchable, and send this star video blab la. so. . what do i can do for it?

please help im stock

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by silverdreamx · Nov 08, 2012 at 07:11 AM

You can add a Collider component to your GameObject. Then, to check for touch on the object, on the Update() function of your GameObject, do a RaycastHit test like below:

 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
 RaycastHit hitInfo;
 if (collider.Raycast(ray, out hitInfo, 1.0e8f))
 {
     if (!Physics.Raycast(ray, hitInfo.distance - 0.01f))
     {
        // do your button handling here
     }
 }

Hope this is helpful!

Comment
Add comment · Show 2 · 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 octaviomejiadiaz · Nov 08, 2012 at 04:20 PM 0
Share

HI, THAN$$anonymous$$S FOR ANSWER, BUT THIS CODE IS C++??

THE CODE THAT I NEE TO PUT IS THIS.

IN THE CODE TAHT YOU POST, WHERE DO I PUT THE GA$$anonymous$$EOBJECT NA$$anonymous$$E OR HOW TO DIRECT THE FUNCTION TO THIS EXACT GA$$anonymous$$EOBJECT.

PLEASE HELP.

// create the video texture _videoTextureTwo = new VideoTexture( "skyfall.m4v", 640, 360, false, 0, true ); // apply the texture to a material and set the UVs targetTwo.renderer.shared$$anonymous$$aterial.mainTexture = _videoTextureTwo.texture; LiveTextureBinding.update$$anonymous$$aterialUVScaleForTexture( targetTwo.renderer.shared$$anonymous$$aterial, _videoTextureTwo.texture ); // add some event handlers _videoTextureTwo.videoDidStartEvent = () => { Debug.Log( "Video two started" ); }; _videoTextureTwo.videoDidFinishEvent = () => { // when the video finishes if we are not set to loop this instance is no longer valid and this texture is not set to loop _videoTextureTwo = null; Debug.Log( "Video two finished" ); };

avatar image silverdreamx · Nov 12, 2012 at 03:33 AM 0
Share

Sorry for the late reply... The code is in C# unity script.

I'm not sure how you are doing this, but if you want an additional button, you will have to create a new game object for the button. To do the collision detection for the button game object, attach a Collider component to the button game object, and then add the Update function mentioned above. The button will then be separate from where you create the video texture, though your event handling will need to be done in the button.

avatar image
0

Answer by stantler · Nov 08, 2012 at 07:10 AM

Check this

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
avatar image
0

Answer by octaviomejiadiaz · Nov 08, 2012 at 04:29 PM

but this is not C++ isnt ?

sorry im new on this, this is the code C++ that i want to change : i have to change all this to a touchable GameObject :

if( GUI.Button( new Rect( xPos, yPos, width, height ), "Start Video Texture Two" ) ) { // create the video texture _videoTextureTwo = new VideoTexture( "skyfall.m4v", 640, 360, false, 0, true ); // apply the texture to a material and set the UVs targetTwo.renderer.sharedMaterial.mainTexture = _videoTextureTwo.texture; LiveTextureBinding.updateMaterialUVScaleForTexture( targetTwo.renderer.sharedMaterial, _videoTextureTwo.texture ); // add some event handlers _videoTextureTwo.videoDidStartEvent = () => { Debug.Log( "Video two started" ); }; _videoTextureTwo.videoDidFinishEvent = () => { // when the video finishes if we are not set to loop this instance is no longer valid and this texture is not set to loop _videoTextureTwo = null; Debug.Log( "Video two finished" ); }; }

 Please heeeeeelp i so stock
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

11 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

Related Questions

Char select / GUI button question. 3 Answers

Detect Click on Gameobject 0 Answers

How do I make individual buttons change individual variables? 0 Answers

Cube click pop-up menu 0 Answers

Using GUI and check what button was pressed 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