Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

PrefabUtility.CreatePrefab triggers editor refresh each time - slow to generate lots of prefabs

Discussion in 'Editor & General Support' started by Prodigga, Nov 29, 2017.

  1. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    Hi, in our game we need to generate a bunch of prefabs before the game is built. We have some editor code to generate all the GameObject we need, then on each one we call PrefabUtility.CreatePrefab to create a prefab of that GameObject.

    The issue is each time we call PrefabUtility.CreatePrefab, the editor refreshes/reimports. It makes it really slow to generate lots of prefabs. Can we disable the refreshing/reimporting and perform one big refresh at the end of everything?
     
  2. TrialByFun

    TrialByFun

    Joined:
    Jun 23, 2009
    Posts:
    97
    Sorry, haven't got an answer for you, but I'm a +1 on this. ( I know its an older version ) but under Unity 4.5 creating a prefab didn't trigger the refresh until "Save assets" was called. But like you say, that seems to happen for every individual prefab creation now regardless. I'm searching for an answer as we speak, so if I find a solution I'll post back.
     
    Prodigga likes this.
  3. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    Thanks, I will keep you posted too, hopefully the devs can shed some light on this
     
  4. kiwipxl

    kiwipxl

    Joined:
    Jun 9, 2015
    Posts:
    11
    Any updates on this? I'm using Unity 2017.3.0f3, haven't tried on other versions though.
     
  5. kiwipxl

    kiwipxl

    Joined:
    Jun 9, 2015
    Posts:
    11
    Bump 2.0 so hopefully more people can see this.
    I've tried multiple workarounds to try and speed this up, but none work. I feel like creating prefabs is a pretty important part of tools within Unity, but it's slowed down significantly because of this. Not only that, but it makes batch creation of prefabs barely feasible.
    We have a pipeline in editor that performs multiple steps, blender interaction and exporting models to unity to then create prefabs for (since we cannot modify the model asset directly) and the batch prefab step is by far the slowest part.
    I mean it works as it is, it's just a bit annoying there isn't even a workaround to this (that I know of at least).
     
  6. Helllllllo

    Helllllllo

    Joined:
    Aug 2, 2015
    Posts:
    10
  7. LouisHong

    LouisHong

    Joined:
    Nov 11, 2014
    Posts:
    69