Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 ronronmx · Jan 18, 2013 at 08:55 PM · editorclonecustom-inspector

Cloning GameObjects with custom inspector script attached

I am running into a little problem on IOS with this particular case.

I have a GameObject which has many children/sub-children, and the root object has a custom inspector script that I wrote attached to it. What the script does is loop through all children/sub-children found on that GameObject and displays them as a list in the inspector, each with a checkbox next to them, which allows me to activate/deactivate each children easily without having to look for them, select them and enable/disable them manually.

On Start(), I run through all my "special" objects and I clone them by the amount of clones needed, at their new position. This works fine when playing in the editor, each child which was deactivated on the original object is also deactivated on the clone. The problem happens when I run the game on IOS, the children on the cloned objects are not deactivated, they're all enabled and the cloned object doesn't match the original object.

So I tried to manually loop through all the children on the original object, get their enabled state, and assign it to the clone's children enabled states. But that didn't work as expected, it seamed that only the first child found was successfully enabled/disabled accordingly, but it stops there and doesn't go through all the other children even though my function to get/set states is recursive.

I know that the problem I'm running into is that since the game is running on IOS, "custom inspector scripts" do not work like they do while testing in the editor, but I'm not sure how to get around that problem. I know I'm doing something wrong, but I can't figure out what exactly!.

Sorry for the lengthy post, but it's kinda hard to explain in a few lines. I can post the code from my custom editor/inspector script and the code which clones all special objects if needed. I am hoping someone will be like "Oh yeah you have to do X for this to work on IOS" hahaha.

Thanks guys! Stephane

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 numberkruncher · Jan 18, 2013 at 09:11 PM 0
Share

Hi Stephane! It seems like the changes that you are making are not being persisted. Are you using SerializedObject and SerializedProperty in your custom inspector? If you aren't then you should be using EditorUtility.SetDirty. I suspect that you would experience the same issue if you were building your game to run on $$anonymous$$ac/Windows/Android, or even if you were to restart Unity and run in the editor.

avatar image numberkruncher · Jan 18, 2013 at 09:13 PM 0
Share

If you are not using either of those methods for ensuring that data is persisted I would be happy to include an example of this in an answer below. I am not sure if SerializedObject can be used in conjunction with that particular property, but EditorUtility.SetDirty will definitely work (because I use it for that)

avatar image numberkruncher · Jan 18, 2013 at 09:14 PM 0
Share

Sorry for so many comments, please also let me know which version of Unity you are using because this will affect my answer.

avatar image ronronmx · Jan 19, 2013 at 07:49 PM 1
Share

Hey man, thanks a lot for your help. After looking into my "recursive" function a little more, I found out that it wasn't working correctly so it wasn't going through all the children and setting them accordingly.

But to answer your question, yes I am using SerializedObject and SerializedProperty in my custom inspector, as well as EditorUtility.SetDirty when I detect a change.

So far so good, I build to PC and ran the game and it works fine, so I'm pretty sure it will work as well on iPhone.

Thanks again!

0 Replies

· Add your reply
  • Sort: 

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

10 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

Related Questions

CustomEditor show an instance of a Class inside a Class 0 Answers

Update editorscript if gameobject is manipulated. 1 Answer

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

Cross project scripting? 1 Answer

How can an editor script know when another script was removed from the project? 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