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 Baintastic · Jan 09, 2015 at 05:42 AM · editorscenecopy

Unity 4.6 Copying Complex GameObjects Between Scenes Resets Fields In the Editor

If I try to copy game objects that have a lot of working parts (specifically canvases) between scenes, the fields get cleared and it's way too much work to re-enter them manually. Can anyone explain an elegant way to do this?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Baintastic · Jan 13, 2015 at 09:22 PM

Okay, I found a workaround for this. It's a little ugly, but it works like a charm.

  1. Add the code below to a new Javascript file in your project.

  2. Create a new scene.

  3. In the project panel, select the scene that has the gameobject(s) you want to copy.

  4. File > Load Scene [Additive] <-- NEW FEATURE WOW! This will copy the whole existing scene into your new scene.

  5. Remove all gameobjects that you just imported except for the one(s) you want to copy.

  6. Save the scene.

  7. Open the scene you want to copy the gameobjects into.

  8. In the project panel, select the scene you created.

  9. File > Load Scene [Additive] again and GREAT SUCCESS!

    #if UNITY_EDITOR

    @MenuItem("File/Load Scene [Additive]")

      static function Apply ()
         {
            var strScenePath : String = AssetDatabase.GetAssetPath(Selection.activeObject);
            if (strScenePath == null)
            {
               EditorUtility.DisplayDialog("Select Scene", "You Must Select a Scene first!", "Ok");
               return;
            }
      
            Debug.Log("Opening " + strScenePath + " additively");
            EditorApplication.OpenSceneAdditive(strScenePath);
            return;
         }
       #endif
    
    

source: http://forum.unity3d.com/threads/scene-copy-game-objects-from-one-scene-to-another.19803/

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 Baintastic · May 15, 2015 at 06:38 PM 0
Share

Since Unity5, copying Canvas GameObjects (the reason for this post) has improved significantly, so this method isn't all that useful to me anymore.

avatar image DMCH · May 19, 2015 at 11:27 PM 0
Share

Hey Baintastic. Cheers for taking the time to share what you found. I'm running into similar territory. The main trouble is having to update the references and event triggers, when iterating on a prefabbed canvas which is present on multiple scenes. Can you elaborate a little on how Unity 5 improved things for you? Cheers!

avatar image Baintastic · May 20, 2015 at 07:13 PM 0
Share

I had a canvas full of UI elements I was using for a menu. I was trying to copy it in between scenes and all of the script fields in canvas were being cleared out, meaning the references weren't being carried over. With Unity5, I'm able to copy canvases between scenes without losing references. That is why I don't need the solution in the answer anymore.

avatar image
0

Answer by skylem · Jan 13, 2015 at 08:32 PM

You could write something to store temporary data as you transition between scenes im not sure what parameters your losing upon scene transition but you Could use PlayerPrefs.SetString then load the string on next scene and if it equals certain parameters then u apply them to your new gameobject

If i wanted a scene to remember i've destroyed something when i leave the scene i would store a Bool for isDestroyed then reload it when i re enter the scene. There is most definitely alternatives and probably even better methods i just thought id mention how i've dealt with this in the past.

there is also the DontDestroyOnLoad

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 Baintastic · Jan 13, 2015 at 08:49 PM 0
Share

Thanks for the answer! but I'm talking about getting objects copied between scenes in the editor, not during the actual running of the game. I'll update the question.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Objects that appear in the editor's game view do not appear in the game build 0 Answers

How can I Select/focus the SceneView in Editor? 2 Answers

Gizmos.GUIDrawTexture - draw texture below? 0 Answers

Editor plays all sounds in the scene even when game is stopped 0 Answers

Is it possible to override SceneView / AnimX Private Types? 0 Answers


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