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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by peterk1968 · May 11, 2015 at 10:07 PM · prefabinspectorscale

Rescaling a prefab - geometric object with hole in middle

Hi Everyone,

I'm an experienced programmer, but fairly new to Unity. I'm hoping this is an easy one. I've created a prefab called Indicator for my game - it's basically made up of 4 elongated cubes arranged in a frame shape and the idea is that I would be able to slide it back and forth and up and down on various scoreboards. It's working well and I'm able to apply various effects on it when the value is changing that look really good. But where I'm stumped, is when I try to rescale the thing to use elsewhere...

alt text

For example, you can see some well behaved indicator prefabs on the Runs Scored and Games Won table. Now, I'm trying to resize it to cover the active players hand of 6 cards over on the left hand side of the screen and I want to make it flash to give a graphic indication that the player has to play a card from his hand.

You can see an instance of a badly rescaled indicator right above the Runs Scored table in this image. As I stretched the prefab out on X, the scaling of the top and bottom components were handled correctly, but the left and right side components were also rescaled making them much fatter. You can actually see the abnormally high scale value in the inspector off to the right. The x dimension of the left side got bumped to 4, but it was originally at 0.15 before I started the stretch.

I can of course, go into the instance by hand and correct the 4 child components of the prefab after the fact, but I'm wondering if there's a way for me to modify the way the editor handles the prefab, so that when I stretch on X, that the left/right components don't get rescaled, and when I stretch on Z that the top and bottom components won't get rescaled?

Would this require a custom editor for the prefab? I've been reading up on OnInspectorUI(), but it seems like a bit of overkill.

Any help appreciated.

=======================================

...and confirmed. I can use a cube or plane, with the frame outline plastered on as an image rather than building a prefab made up of cubes.
The Main Color property of the shader still lets me alter the color of the frame and I;m not locked into what was originally in the image.

Thank you for the advice.

indicatorframeprefab.jpg (196.1 kB)
Comment
Add comment · Show 3
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 AlwaysSunny · May 11, 2015 at 10:14 PM 1
Share

First thought is, this thing has no business being four cubes. It should almost certainly be a UI image with the proper scaling mode to tile a "9-slice" image of a box. Then, positioning this element becomes a matter of setting a single scale to the correct x,y dimensions and placing it in the center of whatever abstract shape it's representing.

If it needs to be cubes, and you really do want exactly what you're asking for, you should write some script which turns a rectangle (or height/width/position, whatever data representation of an intuitive rectangle you like) into scale data for four boundary cubes. It takes a bit of work, but I've done something very similar when I needed resizable boundary colliders to cordon off a physical area.

avatar image peterk1968 · May 12, 2015 at 10:00 AM 0
Share

Fair enough. I thought about doing the frame texture on a plane actually. The reason i didn't is that I want to have effects on it. I need to be able to change colors of the frame and I need it to be able to flash (more of a pulse really....I do a smooth variation between two colors every few seconds) to draw the users attention to whatever it is fra$$anonymous$$g. I thought that if I slapped a frame texture on a single plane or cube, then I wouldn't be able to do those things.

Will experiment a bit with using a image texture.

avatar image AlwaysSunny · May 12, 2015 at 02:26 PM 0
Share

Sure, you can do those things with an Image just as easily. To be clear, I'm talking about an Image component, which is part of the UI system. It's different from putting a textured material on a quad; superior-to in this situation. You should be using UI elements for anything that is logically an interface element.

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

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Change material inside instanced prefab, gameobject.renderer is NULL 1 Answer

How do I scale an object or prefab to a size in Unity units? 1 Answer

How do I scale up a texture along with an ever-expanding underlying body ? 0 Answers

Resize a 3D prefab without affecting scale 2 Answers

OnInspectorGUI with prefabs 2 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