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 venhip · Nov 19, 2012 at 06:38 PM · referencingwireframe

Referencing all objects in scene

Hey, I've recently been attempting to get a wireframe rendering mode to use with one of my cameras and I've also managed to find a script that turns the object it is attached to render as wireframe. Because I want to render every object as wireframe how would I reference the script on every object and activate/deactivate it?

Many thanks.

Comment
Add comment · Show 4
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 fafase · Nov 19, 2012 at 06:50 PM 0
Share

A)Is the script already on each object or do you need to add it at runtime? B)And what is the condition to change the state?

I ask those because if it is not on you need to add it obviously. Then the condition because if you use a collision for instance you already have the reference so you would not need to find the object.

avatar image venhip · Nov 19, 2012 at 06:57 PM 0
Share

The script is already added (but deactivated), and the switching from textured to wiremode will happen when a certain string is entered into a text box and a 'send' button is pressed.

avatar image lil_billy · Nov 19, 2012 at 07:02 PM 0
Share

like i said with my answer us that to send whatever activation message to your objects that enables your script to work

there is no all gameObjects button now i didnt make it look pretty because its just the psuedo you can tailor it to whatever needs you have, and litterally spends weeks making it however efficient you want

avatar image fafase · Nov 19, 2012 at 07:04 PM 0
Share

It actually does not take weeks to make it efficient. It just takes to use GetComponent.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by lil_billy · Nov 19, 2012 at 06:45 PM

var list : GameObject[];

list=gameObject.FindGameObjectsWithTag (tag : String);

for( i in list)

i.sendMessage

following this idea you could do it to just a group of things or could expand it to do all tags thus everything

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
0

Answer by fafase · Nov 19, 2012 at 07:03 PM

ok so two solutions, you can go for @lil_billy solution which is fine if you do not do it for many objects at the same time. SendMessage is real slow compare to GetComponent<>();

so the other way:

 ComponentName script = GameObject.Find("NameofObject").GetComponent<ComponentName>();
 script.TexturedThing = false;
 script.Wiremode = true;

NameofObject is the string passed in the textbox I would guess. Since I do not know how you perform the texturing to wiremode I just gave a pseudocoding. I guess you know your script.

Comment
Add comment · Show 3 · 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 lil_billy · Nov 19, 2012 at 07:15 PM 0
Share

yeah i know sendmessage is bad but it was really just a theory example, like i said you could spend weeks cleaning it up to whatever level of efficiency you want, one way would be to replace sendmessage with directly accessing the script on the object. which is sort of what you did, but that to is not good to do with lots of objects

if you want even more efficiency you could use OnBecameVisible to call the function

it really depends on his exclusive situation

this wont work because its only looking for one object you,

avatar image venhip · Nov 19, 2012 at 08:04 PM 0
Share

The idea is you type in "camera.wiremode" and it'd activate the wiremode component on all the objects. I know how to use GetComponent but I was wondering if rather than having to cache every object I could just search for and activate it on every object.

avatar image fafase · Nov 20, 2012 at 06:24 AM 0
Share

Well you can cache the component ins$$anonymous$$d of the object. The problem is how will go find the appropriate object? Note that iterating through a limited array will be faster than iterating through the whole hierarchy. If you have a pattern like the ones on the left, then the right on the right,you could group them into array of script references.

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

11 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

Related Questions

Wireframe Rendering on Android 0 Answers

Why color not rendering in my shader? 0 Answers

Getting referencing error when trying to position a GUI screen. 2 Answers

Optimising references to other scripts 1 Answer

System.Numerics.BigInteger in Unity 5.6 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