In my project, i have different scenes and I am encountering a problem with one of them.
I have a pathfind generator that builds a list of nodes and links (both ScriptableObject), serialized in a MonoBehaviour derived class. The generator works great : visual representation is correct.
When I start the level in the Editor, it’s OK.
When I start the default level and load this level in the Editor, it’s OK.
The problem occurs when i try to load this level from a standalone player. I looked at the output_log but there is no error or warning.
EDIT :
I have found what lines are causing the issue. But I can’t figure out why it is happening. In a script that is executed only in the Editor for the generation of my pathfind, I check if there is a wall between two nodes using a set of raycasts. This set is used to set the proper type of the link (normal, through window…) between the two nodes.
The error in the standalone players appears only when :
-
the link type is a window
-
the link is joining a left node to a right one (see code below)
PathNode.ENeighbor eInversedNeighbor = PathNode.GetInversedNeighbor(a_eNeighbor); // right if a_eNeighbor is left, back if it is front…
PathLink link = ScriptableObject.CreateInstance();
link.SetNodes(Me, Neighbor, nLinkType); // just setting some serialized attributes
Me.SetLink(a_eNeighbor, link); // just setting some serialized attribute
Neighbor.SetLink(eInversedNeighbor, link); // idem for the other node// add the link to the path holder
PathHolder path = (PathHolder)serializedObject.targetObject;
path.m_lLinks.Add(link);
if I comment the line " Me.SetLink(a_eNeighbor, link);", the level can be loaded.
The function SetLink :
public void SetLink(ENeighbor a_eNeighbor, PathLink a_Link)
{
Assertion.Assert(a_Link != null, "invalid link");
Assertion.Assert(GetLink(a_eNeighbor) == null, "link already set.");
switch(a_eNeighbor)
{
case ENeighbor.eLeft: m_LeftLink = a_Link; break;
case ENeighbor.eRight: m_RightLink = a_Link; break;
case ENeighbor.eFront: m_FrontLink = a_Link; break;
case ENeighbor.eBack: m_BackLink = a_Link; break;
default: Debug.LogError("Invalid Neighbor"); break;
}
}
it is crashing during the loading of the level by unity engine. - None of my level scripts get the Awake message. - None of my ScriptableObject get the Enable message.
– Tourist