Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 agriz · Aug 10, 2015 at 11:57 AM · animationbuttonsprite

How do i pass the button event to a script attached to the canvas or empty gameobject?

I have four buttons. All the buttons have the buttons script for onclick.
The process is difficult for me.

I am thinking that passing the button click to the canvas or empty gameobject will make the work easier. Because i want to write some animate script on the gameobject which will be dynamically created.

Right now, it is created in the button script.

 GameObject go = new GameObject(directions[activeItem]);
         SpriteRenderer renderer = go.AddComponent<SpriteRenderer>();
         renderer.sprite = mysprite;
         
         Vector3 center = new Vector3(404,273,0);
         go.transform.position += center;        
         go.transform.localScale = new Vector3 (2, 2, 2);

Game object is created inside the button. So, I don't know how to animate. I just can't use transform.xxx inside the update which will give animation to the buttons.

Please advice what is the best solution for this?
Passing the button click to canvas?
Or animating the gameobject in button itself?

I tried to add the following line to catch the button click it didn't work.

 public Button button_name;
 ....
 
 
 button_name.onClick.AddListener(() => {
    debug. log('test');
  });
 
 But it is giving me error.

I don't know how to animate the sprite inside the button script. So i am struck here!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Cybless · Aug 10, 2015 at 12:42 PM

Is it something like this you are looking for?

https://unity3d.com/learn/tutorials/modules/beginner/ui/ui-transitions

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 agriz · Aug 10, 2015 at 12:50 PM 0
Share

No sir. i have already watched the video. That is not what i wanted.

avatar image agriz · Aug 10, 2015 at 12:51 PM 0
Share

It seems you wrongly understood my question. I wanted to animated a dynamic game object which was created during run time after a button click. I don't want to animate the button. But the game object which was created by the button.

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

animate sprite in a button event 0 Answers

2d sprite animation how to set a button to let your sprite work 0 Answers

(Unity 4.6) Button animations 1 Answer

How to put multiple sprites in one click inside of a game object? 0 Answers

How do I change the sprite of a button when clicking? 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