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
1
Question by Rabwin · May 08, 2011 at 04:26 AM · texture2dguitextureuvanimation

Animate a GuiTexture to make a spinning object

I've been looking around for this and most of the other answers didn't help or were wrong somehow.

I've basically copied what this JavaScript does (but re-wrote it in c#). Unfortunately this script is for controlling materials on a 3d object and not a Gui Texture.

So what I've got so far, is created the strip of images of the object spinning on each frame. Set the texture on the GuiTexture, and played around with the width and right border values to get it to show just one frame.

The problem I'm having is being able to set the offset of this texture, but I can't do it like in the link. I also can't seem to edit the border values through script so I won't be able to change width and border values to do it.

By the looks of it, I think I'm going to have to have to resort to this instead, since it seems like the only possible way for it to work. Yay for having to recreate every single frame into it's own image and using an array of Texture2D.

Comment
Add comment · Show 2
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 Eric5h5 · May 08, 2011 at 05:28 AM 0
Share

Any reason for using GUITexture? It doesn't seem appropriate, given the limitations.

avatar image Rabwin · May 08, 2011 at 06:32 PM 0
Share

I'm not exactly sure how else to go about this, should I have used a 3d object ins$$anonymous$$d and sat him in front of the camera? It seems a bit dodgy, or is that still a good way.

2 Replies

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

Answer by Rabwin · May 14, 2011 at 07:08 AM

Can't change tiling or the scroll of a gui texture so my only solution was to either make a plane and set that to camera.nearplane (or wahtever it's called) or scroll through different textures using a similar code for frames per second. This second option is what I chose.

I made a separate image for each frame and set them into cache using numbered names for each image during the awake function.

using this in ongui, I could scroll through them at a good constant speed and create my animated gui.

// Calculate index curFrame += Time.deltaTime * frameScrollSpeed;

// repeat when exhausting all frames int index = Mathf.FloorToInt(curFrame) % guiPic.Length;

// change frame according to index GUI.DrawTexture(new Rect(10, 8, 30, 28), guiPic[index]);

frameScrollSpeed is a float of the speed I wanted.
guiPic is an array of type Texture2D.

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
2

Answer by burgunfaust · May 08, 2011 at 03:11 PM

GUITexture is very limited. But it's limitations make it stronger for what it does do well, making GUIs. What you are trying to do will not work, to best of my knowledge with guitexture, but you should be a ble to do it with a regular 3D object, even as part of a GUI.

EDIT: Try looking at this, specifically the character visual setup. I uses a sprite sheet for a topdown. http://www.rebelplanetcreations.com/downloads/Other/Tutorials/HowToMakeAGameInUnity3D.pdf

Comment
Add comment · Show 5 · 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 Rabwin · May 08, 2011 at 06:14 PM 0
Share

What do you mean, a 3d object as part of a GUI? Is that like creating an object and setting it as a child of the camera while it's sitting in front of it.

avatar image burgunfaust · May 09, 2011 at 12:31 PM 0
Share

A GUI is just a 2d menu in 2d space (the screen). Just do what you are trying to do on a 3d object. Then go from there on how to proceed with what you are trying to do. Is this for a game menu of some sort or what?

avatar image Rabwin · May 10, 2011 at 04:50 AM 0
Share

It's part of a user interface while the player is in-game. To be more specific on what I'm trying to do, theres a spinning image of a gem I have, and next to it is a gui text that updates using a score.

I have the tiled strip of the gem's frames setup, I just can't manage to do this.

avatar image burgunfaust · May 10, 2011 at 12:56 PM 0
Share

Look above at my edit.

avatar image Rabwin · May 14, 2011 at 06:59 AM 0
Share

Unfortunately this type of scrolling of a texture only works on objects and not the gui texture like I wanted.

I had by now already found another solution, and that was unfortunately to create an image for each frame and then scroll through that cache of textures.

Thanks for your support though, I couldn't have come up with my solution without talking to you.

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

1 Person is following this question.

avatar image

Related Questions

ReadPixels requires an offset while in the Editor? 2 Answers

Why are my GUI textures distorted? 1 Answer

Unassigned Reference Exception. How to create and add a texture 2D in the inspector? 0 Answers

When to use OnGUI() ? 1 Answer

Is it possible to remove elements from a Texture2D array? 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