Really frustrating problem where Inspector doesn't seem to lock properly

Also running into the same problem at the moment.
The biggest problem is that unlike pictures, it doesn’t have the little arrow to open it up from the icon so I am forced to double click to open the prefab but it changes the inspector view (even though it was locked) to the prefab for Path(0)

I am not sure if it is just a difference in versions, or a setting I can change, but a lot of things are popping up in different places, but it hasn’t really been an issue until now.

Hi,

The course was created using Unity 2018.2, you are using Unity 2018.3, the workflow for prefabs was dramatically changed.

Hope this helps :slight_smile:


See also;

Thanks, Rob! I will check this out!

1 Like

You’re very welcome :slight_smile:

I’m still having trouble with the Prefab workflow in 2018.3
Is there a way to link from one prefab to another?
Not sure how to get the pathing into the enemy prefab.

Hi Barrie,

I’ve cobbled a quick video together for you to demonstrate how to write up prefabs to prefabs using Unity 2018.3.

In the above I’ve created a new scene called Prefabs. I then;

  • create a Cube and drag it into the Assets folder, thus creating a Cube prefab
  • open the prefab in order to edit it, you can do this using the button in the Inspector, or, clicking on the arrow next to the prefab instance in the Hierarchy

Whilst editing the prefab I;

  • add a new script component
  • give it a single private field of type GameObject which I then apply the [SerializeField] attribute to in order to expose it in the Inspector

Closing the prefab editor I;

  • remove the prefab instance from the Hierarchy (just to make it a little clearer as to what we’re doing)
  • create a sphere and drag that to the Assets folder to create another prefab
  • again, I remove the instance from the Hierarchy

Dragging the Cube prefab back to the Hierarchy I;

  • create a prefab instance
  • open it to edit it
  • drag the Sphere prefab into the exposed field in the Example.cs script component attached to the Cube prefab

Exiting the prefab edit mode I;

  • delete the prefab instance in the Hierarchy

Finally, I drag the Cube prefab to the Hierarchy and, as you can see, it has the reference to the Sphere prefab in the Inspector.

Hope this helps :slight_smile:

Hey Rob,

unfortunately not. Because the Sphere doen’t have childrens like the waypoints in the Path prefab!
There is just no way I found to “open” the Path prefab in the Assets to show the Waypoints and drag them over into the inspector…

Unfortunately it also doensn’t work if one tries to drag the waypoints from the Prefab-Mode into the inspector…

Hi Chris,

Currently, no, in 2018.3 there isn’t a way to reference the child GameObjects of a prefab to another prefab, primarily I believe because of the new interface, e.g. it doesn’t matter which tabs you lock, selecting a different prefab requires you to open it and then that changes the prefab you are editing

What you could do however is this;

  • Update the script which you were dragging the waypoint GameObjects into, in your case, EnemyWaypoints.cs to take a single GameObject instead of a list of Transforms.
  • Prefab your Paths
  • Drag the Path (0) prefab from Assets to the exposed field within EnemyWaypoints.cs
  • Instead of then iterating through the List<Transform>, iterate through the child Transforms of the GameObject you’ve referenced, for example;
    [SerializedField]
    private GameObject waypoints;    // this replaces the list
    
    private void Example()
    {
        foreach(Transform child in waypoints.transform)
        {
            // do stuff
            Debug.Log(child.position);
        }
    }
    

Hope this helps :slight_smile:

I’m currently in hospital and away from my PC but if I recall correctly the simplest workaround was to create an instance of the enemy game object from the prefab (by dragging the prefab onto the scene).

I was then able to apply the pathing prefab to the enemy game object in the Inspector and then applied those changes back to the enemy prefab (or maybe I simply saved it as a new prefab, can’t remember for sure)

Seemed to work fine and required no scripting changes.

That said, it’s a really odd UI change by Unity. The ability to keep separate inspector windows open for two different prefabs is pretty much an obvious feature to preserve.

1 Like

I’ve also ran into this problem.
I’ve fixed it by serializing path game object, not individual waypoints (wich is more logical, in my opinion). Then, I add it’s childs to a list in for().
Code:
code
Then just drag the prefab and apply overrides

Hi,

Take a look at the AddRange method of List, you can save your iteration, for example;

private void AddPath()
{
    pathWaypoints.AddRange(path.GetComponentsInChildren<Transform>());
}

Please note, it’s better to copy/paste your code and apply the code fencing characters, rather than using screenshots. Screenshots are ideal for displaying specific details from within a game engine editor or even error messages, but for code, they tend to be less readable, especially on mobile devices which can require extensive zooming and scrolling.

You also prevent those that may offer to help you the ability to copy/paste part of your code back to you with suggestions and/or corrections, meaning that they would need to type a potentially lengthy response. You will often find that people are more likely to respond to your questions if you make it as easy as possible for them to do so.

Hope this helps :slight_smile:


See also;

Just as a further follow up on this, I received the following response from one of the programmers at Unity;

For child levels beyond the immediate children of the root, this was never possible, but of course specifically for immediate children of the root this used to be possible. There’s no way to do this via UI now - it’s the same as it used to be for deeper children before.

We’re considering changing the Object Selector to show children of Prefabs in order to address this.

In the mean time, it’s possible to achieve it using a script, like you could also previously use to access children in a Prefab Asset beyond the immediate children of the root.

If they do add this functionality via the Object Selector, and assuming it drills down to any level, this will invariably resolve this in a tidy fashion.

Hi,

Here is my WorkArround

Take all the Waypoint (0-2) out of the Path Prefab. Making then sand alone. If it does not work, just delete the Path Prefab and them move these 3 game object out.

Take the 3 Waypoint and add them into the Path Folder Prefab, and then add them back in the Path Prefab game object.

From there, when you will select the other Prefab, you will have all the Waypoint shows instead of just the main container.

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms