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 KEELAN · Dec 26, 2013 at 07:19 PM · gameobjectfindcustom-inspector

How to find all gameObjects in a bounding area?

Hello, I need to find all gameobjects in a cube area, i want to do this in an custom inspector though so i cant use any runtime methods.

Thanks in advance.

Update . The preferably the entire bounds of the objects should be checked agaisnt the area (if there is a way to do that) but if that isnt possible then just pivot point.

The cube is aligned to the global axis, not to any object.

Comment
Add comment · Show 1
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 robertbu · Dec 26, 2013 at 07:24 PM 1
Share

Some info you might want to add to your question:

  • Is it just the pivot point that must be in the cube area, or does the entire object need to be within the cube, or is it any part of the mesh within the specified cube area?

  • If it is the entire object, is it good enough to check a bounds of the of the objects, or do you need the actual mesh checked against the cube area?

  • Are the objects axes aligned or are they rotated?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by tw1st3d · Dec 26, 2013 at 08:58 PM

This is pseudo code, I haven't worked with C# in quite a while, but it should make sense as to what it does. Take a look, and if it doesn't work, try and fix it ( cause that's how you learn :)! )

 using UnityEngine;
 using System.Collections;
 using System;
 
 public class InsideOf : MonoBehavior
 {
     protected List<GameObject> insideMe = new List<GameObject>();
     
     private void OnTriggerEnter(Collider e)
     {
         if(e typeof GameObject)
         {
             if(!this.insideMe.contains(e.gameObject))
             {
                 this.insideMe.add(e.gameObject);
             }
         }
     }
     
     private void OnTriggerExit(Collider e)
     {
         if(e typeof GameObject)
         {
             if(this.insideMe.contains(e.gameObject))
             {
                 this.insideMe.remove(e.gameObject);
             }
         }
     }
 }
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 KEELAN · Dec 26, 2013 at 10:04 PM 0
Share

hello,

That should work for runtime yeah,

Im looking to make a list of objects in a custom inspector gui. So any methods like ontriggerenter/exit wont work. (unless i am mistaken, which is possible)

avatar image
0

Answer by FirePlantGames · Dec 26, 2013 at 10:28 PM

can i suggest a trigger object?

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 KEELAN · Dec 26, 2013 at 11:07 PM 0
Share

as far as i know triggers only work in at runtime.

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

20 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Alternatives to GameObject.Find(); 1 Answer

Finding Children question 3 Answers

Find all gameObjects with same tag 1 Answer

Search for specific entity in an array? 1 Answer

Custom Editor for GameObject Class look like Unity's Custom Inspector for GameObject? 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