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 MadMapp · May 09, 2013 at 08:39 PM · prefabsvariablesguitexturealphagameobjects

cant set object in prefab object, but can in the scene

hi unity i hope some1 can point me in the right direction, basicly i have an object, a snow man, when i hit the snow man i want a gui to block the screen wait a few seconds and fade out, like the squid ink in mario super karts

if i add my script to the snow man in the scene, the trigger works and the gui pops up, ( the alpha decreasing to fade out is not working)

the problem is my snowman object must be instanciated and it wont let me put my GUItexture object in to the variable GUI1 of my prefab in my project window, i have been hunting and trying for last 2 days to solve this, i am new still to coding and unity but trying my best to learn, any help in this or the alpha problem is greatly apriciated

here is my code:

var collectSound:AudioClip;

var spawnpoint: Transform;// position of spawn

var particle: GameObject;// object to spawn

var GUI1: GameObject;

var FadeNum : float = 0.12;

var displayFor : int= 3;

var alpha : float=1;

function OnTriggerEnter (other : Collider){

if (other.gameObject.tag == "Player") { AudioSource.PlayClipAtPoint(collectSound, transform.position);

 Instantiate(particle, spawnpoint.position, spawnpoint.rotation);

GUI1.guiTexture.enabled = true;

     yield WaitForSeconds ( displayFor);

     //GUI1.guiTexture.color.a = alpha- (FadeNum* Time.deltaTime );
     //if (alpha < 0.1){

     GUI1.guiTexture.enabled = false;

     Destroy(this.gameObject);
 

}

} //}

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

Answer by SubatomicHero · May 10, 2013 at 06:55 AM

its because GUI1 should be of type GUITexture, not a gameobject.

 var GUI1 : GUITexture;
Comment
Add comment · Show 1 · 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 MadMapp · May 10, 2013 at 01:08 PM 0
Share

ya i tried that was also, i had the same issue wasnt able to assign it to the inspector, i have gotten around the problem by making the trigger on the player, thus having the object in the scene, and no longer needing to assign the variable on the not yet Instantiated prefab

cheers for the help though it is very much appreciated,

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

14 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

Related Questions

Drawing Sector around GameObject in GameView: GUITexture or 3D Object 1 Answer

Reinitialize prefab 0 Answers

Scripts/buttons getting old (prefab?) values of variables 1 Answer

2D Tilemap Gameobject Brush Script for Editor 0 Answers

How many variables can i have of type 'Prefab' in a scene at one time? 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