Browse Source

Added null pointer checks and fixed sequence name picking

master
chrisgregan 11 years ago
parent
commit
2b6fe13072
  1. BIN
      Assets/Example/Scenes/Example.unity
  2. 4
      Assets/Fungus/FungusScript/Editor/CommandEditor.cs
  3. 9
      Assets/Fungus/FungusScript/Editor/CommandListAdaptor.cs
  4. 8
      Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs
  5. 4
      Assets/Fungus/FungusScript/Editor/SequenceEditor.cs
  6. 5
      Assets/Fungus/FungusScript/Editor/VariableListAdaptor.cs

BIN
Assets/Example/Scenes/Example.unity

Binary file not shown.

4
Assets/Fungus/FungusScript/Editor/CommandEditor.cs

@ -45,6 +45,10 @@ namespace Fungus
} }
FungusScript fungusScript = t.GetFungusScript(); FungusScript fungusScript = t.GetFungusScript();
if (fungusScript == null)
{
return;
}
CommandInfoAttribute commandInfoAttr = CommandEditor.GetCommandInfo(t.GetType()); CommandInfoAttribute commandInfoAttr = CommandEditor.GetCommandInfo(t.GetType());
if (commandInfoAttr == null) if (commandInfoAttr == null)

9
Assets/Fungus/FungusScript/Editor/CommandListAdaptor.cs

@ -127,6 +127,11 @@ namespace Fungus
{ {
Command command = this[index].objectReferenceValue as Command; Command command = this[index].objectReferenceValue as Command;
if (command == null)
{
return;
}
CommandInfoAttribute commandInfoAttr = CommandEditor.GetCommandInfo(command.GetType()); CommandInfoAttribute commandInfoAttr = CommandEditor.GetCommandInfo(command.GetType());
if (commandInfoAttr == null) if (commandInfoAttr == null)
{ {
@ -134,6 +139,10 @@ namespace Fungus
} }
FungusScript fungusScript = command.GetFungusScript(); FungusScript fungusScript = command.GetFungusScript();
if (fungusScript == null)
{
return;
}
bool error = false; bool error = false;
string summary = command.GetSummary().Replace("\n", "").Replace("\r", ""); string summary = command.GetSummary().Replace("\n", "").Replace("\r", "");

8
Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs

@ -62,7 +62,13 @@ namespace Fungus
FungusScript fungusScript = GetFungusScript(); FungusScript fungusScript = GetFungusScript();
if (fungusScript == null) if (fungusScript == null)
{ {
GUILayout.Label("No Fungus Script object selected"); GUILayout.Label("No Fungus Script scene object selected");
return;
}
if (PrefabUtility.GetPrefabType(fungusScript) == PrefabType.Prefab)
{
GUILayout.Label("No Fungus Script scene object selected (selected object is a prefab)");
return; return;
} }

4
Assets/Fungus/FungusScript/Editor/SequenceEditor.cs

@ -183,7 +183,7 @@ namespace Fungus
Sequence[] sequences = fungusScript.GetComponentsInChildren<Sequence>(); Sequence[] sequences = fungusScript.GetComponentsInChildren<Sequence>();
for (int i = 0; i < sequences.Length; ++i) for (int i = 0; i < sequences.Length; ++i)
{ {
sequenceNames.Add(new GUIContent(sequences[i].name)); sequenceNames.Add(new GUIContent(sequences[i].sequenceName));
if (sequence == sequences[i]) if (sequence == sequences[i])
{ {
@ -221,7 +221,7 @@ namespace Fungus
Sequence[] sequences = fungusScript.GetComponentsInChildren<Sequence>(); Sequence[] sequences = fungusScript.GetComponentsInChildren<Sequence>();
for (int i = 0; i < sequences.Length; ++i) for (int i = 0; i < sequences.Length; ++i)
{ {
sequenceNames.Add(new GUIContent(sequences[i].name)); sequenceNames.Add(new GUIContent(sequences[i].sequenceName));
if (sequence == sequences[i]) if (sequence == sequences[i])
{ {

5
Assets/Fungus/FungusScript/Editor/VariableListAdaptor.cs

@ -86,6 +86,11 @@ namespace Fungus
{ {
Variable variable = this[index].objectReferenceValue as Variable; Variable variable = this[index].objectReferenceValue as Variable;
if (variable == null)
{
return;
}
float width1 = 100; float width1 = 100;
float width3 = 50; float width3 = 50;
float width2 = Mathf.Max(position.width - width1 - width3, 60); float width2 = Mathf.Max(position.width - width1 - width3, 60);

Loading…
Cancel
Save