Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine the name of a previously referenced, now missing, MonoBehaviour script?

Tags:

unity3d

I have a Unity project with warnings:

The referenced script on this Behaviour is missing! 

I've identified which game objects have these bad references, and I have a collection of scripts (cs files) which I know include the intended scripts, but which component instances (and their saved state) map to which scripts I cannot discern obviously.

Is there a way to know which scripts the components with missing references were originally pointing to, so I can manually reassign the correct scripts back onto the components and preserve component state?

like image 400
DuckMaestro Avatar asked Aug 14 '15 20:08

DuckMaestro


People also ask

How do I fix a missing script in Unity?

Click Regenerate project files In the Unity Project window, double-click one of your scripts. Unity automatically regenerates the solution file along with all project files.

What is a MonoBehaviour script?

Description. MonoBehaviour is the base class from which every Unity script derives. When you use C#, you must explicitly derive from MonoBehaviour.


1 Answers

Make sure in the Editor Settings the Asset Serialization Mode is on “Force Text”.

You could open up your scene (or prefab) file in a text editor and search for the GameObject name with the missing script reference e.g. “TheGameObjectWithTheMissingBehaviour”

you should see something like this (i just copied down the important lines)

--- !u!1 &298606752
GameObject:
  m_Component:
  - 54: {fileID: 1199074165}
  - 114: {fileID: 1199074166}
  m_Name: TheGameObjectWithTheMissingBehaviour
---

below the GameObject there should be a list with at least one MonoBehaviour, which looks like this

--- !u!114 &1199074166
MonoBehaviour:
  m_Enabled: 1
  _myCustomVariableA: 1
  _myCustomVariableB: 2
  _myCustomVariableC: 2
---

you can see in the last lines there are the custom variable i.e. [SerializedField] or public members.

then you could search your project for a script with those custom variable name.

like image 162
JeanLuc Avatar answered Nov 09 '22 03:11

JeanLuc