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 ncarota · Nov 18, 2012 at 10:39 AM · editorprefabeditorutility

The Script Equivilent of dragging a hierarchy of meshes over a preexisting prefab?

Hi Guys,

I'm having a hell of a time trying to update pre-existing prefabs during the OnPostprocessModel call. Using the EditorUtility.ReplacePrefab always overwrites the prefab completely.

         List<GameObject> affectedPrefabs = mapAvailablePrefabs(gameObject);
         if (assetPath.Contains("@") == false) {
             string path = assetPath.Replace((gameObject.name +".FBX"),((returnRace(gameObject)) + gameObject.name + ".prefab"));
             //Does .Prefab already exist at this path?
             //This is mainly to insure that at least one prefab is created if base prefab does not exist.
             if (!System.IO.File.Exists(path)){
                 Debug.Log("Creating Prefab: " + path);
                 Object prefab = PrefabUtility.CreateEmptyPrefab(path);
                 EditorUtility.ReplacePrefab(gameObject, prefab, ReplacePrefabOptions.ConnectToPrefab);
             }
             foreach(GameObject prefabPath in affectedPrefabs)
             {
                    //Updating PreFab
                 Debug.Log("Updating Prefab: " + prefabPath.name);
                 EditorUtility.ReplacePrefab(gameObject, prefabPath, ReplacePrefabOptions.ConnectToPrefab);
 
             }
         }

Thanks for you time! Nick

Comment
Add comment · Show 3
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 ncarota · Nov 19, 2012 at 10:16 PM 0
Share

Okay, to clarify since im not getting any responses: I'm just try to update prexisting prefabs with new mesh data? I just don't understand why this is so difficult to answer.

Do I need to write a recursive method to collect the gameobjects components and completely rebuild it on update? It seems a little ridiculous. Why doesn't unity do this automatically anyway?

Cheers, Nick

avatar image DoctorWhy · Nov 19, 2012 at 11:06 PM 0
Share

Is it that you want to only replace a single part of an existing prefab? Or is the problem that the mesh data is not being copied over? What version of Unity are you using?

avatar image ncarota · Nov 19, 2012 at 11:25 PM 0
Share

Im only trying to replace part of an existing prefab. 3.5.6 I think.

Thanks, Nick

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

before and after apply prefab changes callback 0 Answers

use of EditorUtility.CompileCSharp 1 Answer

Getting properties on 'missing' things in Editor Scripts? 4 Answers

Editor utility for handling nested prefabs.. 4 Answers

How can i convert a prefab instance to an ordinary game object? 2 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