Browse Source

Fixed memory leak and null exception errors

master
chrisgregan 11 years ago
parent
commit
a25b61fc0d
  1. 4
      Assets/Fungus/Dialog/Editor/ChooseEditor.cs
  2. 4
      Assets/Fungus/Dialog/Editor/SayEditor.cs
  3. 1
      Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs
  4. 5
      Assets/Fungus/FungusScript/Editor/FungusScriptWindow.cs

4
Assets/Fungus/Dialog/Editor/ChooseEditor.cs

@ -58,10 +58,8 @@ namespace Fungus
float aspect = (float)characterTexture.width / (float)characterTexture.height; float aspect = (float)characterTexture.width / (float)characterTexture.height;
Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(50), GUILayout.ExpandWidth(false)); Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(50), GUILayout.ExpandWidth(false));
CharacterEditor characterEditor = Editor.CreateEditor(t.character) as CharacterEditor; CharacterEditor characterEditor = Editor.CreateEditor(t.character) as CharacterEditor;
if (characterEditor != null)
{
characterEditor.DrawPreview(previewRect, characterTexture); characterEditor.DrawPreview(previewRect, characterTexture);
} DestroyImmediate(characterEditor);
} }
EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal();

4
Assets/Fungus/Dialog/Editor/SayEditor.cs

@ -75,10 +75,8 @@ namespace Fungus
float aspect = (float)characterTexture.width / (float)characterTexture.height; float aspect = (float)characterTexture.width / (float)characterTexture.height;
Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(50), GUILayout.ExpandWidth(false)); Rect previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(50), GUILayout.ExpandWidth(false));
CharacterEditor characterEditor = Editor.CreateEditor(t.character) as CharacterEditor; CharacterEditor characterEditor = Editor.CreateEditor(t.character) as CharacterEditor;
if (characterEditor != null)
{
characterEditor.DrawPreview(previewRect, characterTexture); characterEditor.DrawPreview(previewRect, characterTexture);
} DestroyImmediate(characterEditor);
} }
EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal();

1
Assets/Fungus/FungusScript/Editor/FungusScriptEditor.cs

@ -89,6 +89,7 @@ namespace Fungus
{ {
CommandEditor commandEditor = Editor.CreateEditor(t.selectedCommand) as CommandEditor; CommandEditor commandEditor = Editor.CreateEditor(t.selectedCommand) as CommandEditor;
commandEditor.DrawCommandInspectorGUI(); commandEditor.DrawCommandInspectorGUI();
DestroyImmediate(commandEditor);
} }
EditorGUILayout.Separator(); EditorGUILayout.Separator();

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

@ -269,8 +269,9 @@ namespace Fungus
{ {
EditorGUILayout.Separator(); EditorGUILayout.Separator();
SequenceEditor editor = Editor.CreateEditor(fungusScript.selectedSequence) as SequenceEditor; SequenceEditor sequenceEditor = Editor.CreateEditor(fungusScript.selectedSequence) as SequenceEditor;
editor.DrawSequenceGUI(fungusScript); sequenceEditor.DrawSequenceGUI(fungusScript);
DestroyImmediate(sequenceEditor);
GUILayout.FlexibleSpace(); GUILayout.FlexibleSpace();
} }

Loading…
Cancel
Save