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 gedo · Apr 23, 2011 at 07:33 AM · meshchildaccess

How should I describe to access child mesh in Java

Hi all. I have two meshes in an object and one script is attached to the parent mesh. I want to access vertices and normals of child mesh from the script attached to it's parent. I described:

var mesh : Mesh = Find.("testsphere").GetComponent(MeshFilter).mesh;

Then I got an error and it does not work at all. Someone please help me by teaching how I should describe correctly in Java Script!

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

Answer by Uzquiano · Apr 23, 2011 at 07:50 AM

Hi,

First, if you want to access children, maybe you are interested in: Component.GetComponentInChildren GameObject.GetComponentInChildren

Second, if you want to Find() something, you should write like this: Find.("testsphere")

And I think, it should work. And I think you already take a look to MeshFilter.mesh, but just in case

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 gedo · Apr 23, 2011 at 08:17 AM 0
Share

hmm...

function Update () { var mesh : $$anonymous$$esh = gameObject.GetComponentInChildren($$anonymous$$eshFilter).mesh; var normals : Vector3[] = mesh.normals;

 var rotation : Quaternion = Quaternion.AngleAxis(Time.deltaTime * speed, Vector3.up);
 for (var i = 0; i < normals.Length; i++)
     normals[i] = rotation * normals[i];

 mesh.normals = normals;

}

this still keep accessing parent mesh's normals... What's wrong with this?

avatar image Uzquiano · Apr 23, 2011 at 09:30 AM 0
Share

Wel... what this exactly means? "Returns the component of Type type in the GameObject or any of its children using depth first search."

using depth first search? that it was first to the children? the performance doesn't say the same...

try GameObject.Find().... ins$$anonymous$$d of gameObject

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

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How to destroy a parent object when child object is collided 1 Answer

Parent component affect child objects 0 Answers

How to make a child & then undo through scripting 2 Answers

How do I script a prefab like I would code a class? 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