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 xToxicInferno · Jul 04, 2010 at 03:46 AM · gameobjectfunctionguitexturestaticfind

Find 2D Texture via Script to use in Static Function

Alright here is what i am trying to do. I have a health script so that when i get shot it displays a hint (much like the one in 'Red Dead Redemption') saying get to cover. The hint is a GUIText object, which is rendered over a GUITexture background. I want it so that when i want to display the hint, the texture fades in and out instead of just popping in and out as it looks odd, and unfinished. So my solution was to make a script which is NOT attached to the GUITexture (for varies reasons) and i want to have it separate from my hint script as i will have more hints (meaning more scripts) then JUST getting shot, and i want it universal. So my idea was this:

static function FadeOut () {
    var HintsBackground = GameObject.Find("HintBackground");
    while (HintsBackground.color.a > .1) {
        HintsBackground.color.a -= Time.deltaTime;
    }
}

The problem is since the function has to be static if i want to call it, i cant simply use: var HintsBackground : GUITexture. So my solution was GameObject.Find...problem is 'color' is NOT a member of GameObject. So what i am asking is, how can i either, change GameObject to GUITexture, or what is the best way to call a GUITexture. Thank you for you time.

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
3
Best Answer

Answer by Tetrad · Jul 04, 2010 at 04:01 AM

var HintsBackground = GameObject.Find("HintBackground");
var background = HintsBackground.GetComponent( "GUITexture" );
// adjust background color here
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 xToxicInferno · Jul 04, 2010 at 04:10 AM 0
Share

Works perfectly! Thank you for such a quick response!

avatar image qJake · Jul 04, 2010 at 09:29 AM 0
Share

We posted the same thing, my code was shorter, and I posted it first, yet you get the accept... man... this community is so backwards sometimes it's unbelievable...

avatar image
2

Answer by qJake · Jul 04, 2010 at 03:59 AM

I think you want HintsBackground.guiTexture.color

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

No one has followed this question yet.

Related Questions

Function to locate game object with smaller distance to target makes the game lag - UnityScript 1 Answer

Finding the angle between two GameObjects 1 Answer

Loading function into array using GameObject.Find 1 Answer

Attaching GameObject and ParticleSystem to C# script 1 Answer

Alternatives to GameObject.Find(); 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