Search Feedback

745
votes

Re-add local identifiers in scene file for prefab instances

Editor

-

-

In Unity 5.0, Prefab instances no longer have a unique identifier stored in the scene file. This seems to be intended, but it breaks multiple editor plugins that rely on those IDs, like "JumpTo" and "GitMerge for Unity".

Please supply some kind of persistent id to prefab instances.

Comments (6)

  1. 4356897a8ba93f63c91cef434ad96880?d=mm

    Krstn

    Sep 07, 2017 04:12

    Just wondering, is this something devs are looking at? It would be helpful.

  2. D7659f24bd1043f131d7cf9859e85f48?d=mm

    ofusion

    Nov 28, 2016 02:39

    I find that some prefab MonoBehaviours has ID when it is saved in scene like the following:

    --- !u!114 &1240749891 stripped
    MonoBehaviour:
    m_PrefabParentObject: {fileID: 11406218, guid: 49a863443a9eca647aefe3e0a5cfc92f,
    type: 2}
    m_PrefabInternal: {fileID: 1240749889}
    m_Script: {fileID: 11500000, guid: 29d79db2fc749004fbdce29578ec068e, type: 3}

    But I can not figure out under what circumstances it can be saved like this.

  3. 1cba440dca4f024142857e2dfbb05db2?d=mm

    pushxtonotdie

    Apr 12, 2016 17:02

    It is still required to use the misspelled name in order to get the local id. It seems that prefab instances are a LocalIDInFile in the scene file's YAML but this id is never propagated to the SerializedObject, most likely because that is only the local id for the GameObject (ie sub-objects like MonoBehaviours and sub-GameObjects do not have ids in the scene file). The instance is a link to a prefab and an array of PropertyModifications.

    So the question is how could this actually be implemented with the data missing as it is? The answer to me seems to be to give PropertyModifications a localIDInFile. Then this can be used to get the instance's sub-object the user is interested in.

    pseudo-code usage example:

    UnityEngine.Object myModifiedInstance = getSceneObject();
    PropertyModification[] pms = PrefabUtility.GetPropertyModifications(myModifiedInstance);
    persistSomeWhereTheID( pms[0].localID , scenePath );

    /** Close Unity....go to sleep...come back to work tomorrow **/

    PersistedData data = retrievePersistedDataFromYesterday();
    MySceneUtil.openScene(data.scene);
    /** scene's open! Get the instance object based on the property modification. **/
    PropertyModification pm = PrefabUtility.GetPropertyModificationForLocalID(data.localIDInFile);
    UnityEngine.Object obj = PrefabUtility.GetInstanceForModification(pm);
    //yay! I have the object. now select it or something.
    Selection.activeObject = obj;

    This would be really helpful for me, and it seems some other people would like it as well.

  4. 77e4b2e6207a8ca6524d783bb23eef48?d=mm

    gnat

    Jan 13, 2016 02:04

    +1

  5. Bff97b12e7d23a9ea9b65d9bd5cc2623?d=mm

    winxalex

    Jan 11, 2016 22:42

    Nuck, Nuck, Nuck its anybody home?

  6. 17ece92c5a5d836d4bdb19495551b405?d=mm

    excaliburHisSheath

    Mar 04, 2015 20:36

    At the same time, it would be a good idea to add some supported way to retrieve this value. In Unity 4 you had to retrieve the value by a (misspelled) name. On the other hand, if there was a good reason for removing this, some comparable functionality should at least be offered. It's pretty reasonable to want to be able to uniquely identify and reference objects within a serialized asset.

Your opinion counts

Help us make things better. Share your great idea for improving Unity or vote for other people’s.

Log in to post a new idea

Categories

All

(11030)

2D

(290)

Ads

(63)

AI & Navigation

(83)

Analytics

(130)

Animation

(413)

Asset Store

(370)

Asset Store Publisher

(21)

Assets

(557)

Audio

(185)

Cloud Build

(154)

Collaborate

(70)

Docs & Tutorials

(251)

Editor

(2579)

Everyplay

(17)

Game Performance Reporting

(22)

General

(1003)

Graphics

(903)

GUI

(447)

Input

(173)

Licensing

(93)

Networking

(192)

Physics

(392)

Platforms

(448)

Profiling & Optimization

(84)

Runtime

(188)

Scripting

(1154)

Terrain

(177)

WebGL

(145)