Skip to content

Seanba/ScriptedImporter_PrefabOrder

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

ScriptedImporter_PrefabOrder

Prefab Order Bug with Unity Scripted Importers

This project contains a simple Scripted Importer (MyScriptedImporter.cs) with these two game objects:

  1. An empty main game object (this is the parent)
  2. An instantiated prefab object (this is the child)

The referenced prefab, TestPrefab, itself has 3 child objects with the following order:

  1. bbbBackPanel
  2. aaaFrontPanel
  3. _ThisShouldComeLast

We would like this order of child objects to be preserved when we instantiate the TestPrefab and attach it to the main object through our scripted importer. However, the child objects are ordered alphabetically.

  1. _ThisShouldComeLast
  2. aaaFrontPanel
  3. bbbBackPanel

Some Unity components, like UI elements, are rendered in the order they appear in the scene hierarchy so the re-ordered children can be the source of bugs.

To Reproduce

In order to reprodcue the bug you'll want to run the scripted importer and view the resulting asset in the scene.

  1. Reimport Assets/MyImportedObject. This uses the scripted importer that attaches a prefab instance.
  2. Drag Assets/MyImportedObject in the scene hierarchy
  3. Expand MyImportedObject in the scene hierarchy to see the TestPrefab children are out of order.

This depot is currently using Unity 2019.2.8f1. This behavior was first noticed with 2018.3.0f2.

About

Prefab Order Bug with Unity Scripted Importers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages