Browse Source

Merge pull request #454 from snozbot/5-0-compatibility

Unity 5.0 backwards compatibility fixes
master
Chris Gregan 9 years ago
parent
commit
1f3342c353
  1. 2
      Assets/Fungus/Narrative/Scripts/SayDialog.cs
  2. 6
      Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/MenuItems.cs
  3. 2
      Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaScript.cs
  4. 748
      Assets/Tests/StringSubstitution/StringSubstitutionTests.unity
  5. 9
      Assets/Tests/UI/Editor/TextTagParserTests.cs
  6. 8
      Assets/UnityTestTools/Assertions/Editor/AssertionComponentEditor.cs
  7. 4
      Assets/UnityTestTools/Assertions/Editor/AssertionExplorerWindow.cs
  8. 8
      Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Batch.cs
  9. 16
      Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerWindow.cs
  10. 4
      Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/NetworkResultsReceiver.cs
  11. 11
      Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerConfiguration.cs
  12. 19
      Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerSettingsWindow.cs
  13. 6
      Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/TestComponentEditor.cs
  14. 10
      Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/ResultDTO.cs
  15. 6
      Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestComponent.cs
  16. 19
      Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestRunner.cs

2
Assets/Fungus/Narrative/Scripts/SayDialog.cs

@ -161,7 +161,7 @@ namespace Fungus
soundEffectClip = speakingCharacter.soundEffect;
}
yield return writer.Write(text, clearPrevious, waitForInput, stopVoiceover, soundEffectClip, onComplete);
yield return StartCoroutine(writer.Write(text, clearPrevious, waitForInput, stopVoiceover, soundEffectClip, onComplete));
}
protected virtual void LateUpdate()

6
Assets/Fungus/Thirdparty/FungusLua/Scripts/Editor/MenuItems.cs vendored

@ -44,8 +44,12 @@ namespace Fungus
File.WriteAllText(path, "");
AssetDatabase.Refresh();
#if UNITY_5_3_OR_NEWER
Object asset = AssetDatabase.LoadAssetAtPath<Object>(path);
if (asset != null)
#else
Object asset = AssetDatabase.LoadAssetAtPath(path, typeof(Object));
#endif
if (asset != null)
{
EditorUtility.FocusProjectWindow();
EditorGUIUtility.PingObject(asset);

2
Assets/Fungus/Thirdparty/FungusLua/Scripts/LuaScript.cs vendored

@ -138,7 +138,7 @@ namespace Fungus
}
else
{
luaEnvironment.RunLuaCoroutine(luaFunction, friendlyName);
luaEnvironment.RunLuaCoroutine(luaFunction, luaScript);
}
}
}

748
Assets/Tests/StringSubstitution/StringSubstitutionTests.unity

File diff suppressed because it is too large Load Diff

9
Assets/Tests/UI/Editor/TextTagParserTests.cs

@ -1,10 +1,13 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using Fungus;
#if UNITY_5_3_OR_NEWER
using NUnit.Framework;
[TestFixture]
public class TextTagParserTests
{
@ -217,3 +220,5 @@ public class TextTagParserTests
}
}
#endif

8
Assets/UnityTestTools/Assertions/Editor/AssertionComponentEditor.cs

@ -4,7 +4,9 @@ using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
#if UNITY_5_3_OR_NEWER
using UnityEditor.SceneManagement;
#endif
namespace UnityTest
{
@ -83,7 +85,13 @@ namespace UnityTest
}
}
if(GUI.changed)
{
#if UNITY_5_3_OR_NEWER
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
#else
EditorApplication.MarkSceneDirty();
#endif
}
}
private void DrawOptionsForAfterPeriodOfTime(AssertionComponent script)

4
Assets/UnityTestTools/Assertions/Editor/AssertionExplorerWindow.cs

@ -32,7 +32,11 @@ namespace UnityTest
public AssertionExplorerWindow()
{
#if UNITY_5_3_OR_NEWER
titleContent = new GUIContent("Assertion Explorer");
#else
title = "Assertion Explorer";
#endif
}
public void OnDidOpenScene()

8
Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Batch.cs

@ -6,7 +6,10 @@ using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using UnityTest.IntegrationTests;
#if UNITY_5_3_OR_NEWER
using UnityEditor.SceneManagement;
#endif
namespace UnityTest
{
@ -99,7 +102,12 @@ namespace UnityTest
}
EditorBuildSettings.scenes = (testScenes.Concat(otherBuildScenes).ToList()).Select(s => new EditorBuildSettingsScene(s, true)).ToArray();
#if UNITY_5_3_OR_NEWER
EditorSceneManager.OpenScene(testScenes.First());
#else
EditorApplication.LoadLevelInPlayMode(testScenes.First());
#endif
GuiHelper.SetConsoleErrorPause(false);
var config = new PlatformRunnerConfiguration

16
Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerWindow.cs

@ -6,7 +6,9 @@ using System.Text.RegularExpressions;
using UnityEditor;
using UnityEngine;
using UnityTest.IntegrationTestRunner;
#if UNITY_5_3_OR_NEWER
using UnityEngine.SceneManagement;
#endif
namespace UnityTest
{
@ -84,7 +86,11 @@ namespace UnityTest
private static void BackgroundSceneChangeWatch()
{
if (!s_Instance) return;
#if UNITY_5_3_OR_NEWER
var currentScene = SceneManager.GetActiveScene().path;
#else
var currentScene = Application.loadedLevelName;
#endif
if (s_Instance.m_CurrectSceneName != null && s_Instance.m_CurrectSceneName == currentScene) return;
if (EditorApplication.isPlayingOrWillChangePlaymode) return;
TestComponent.DestroyAllDynamicTests();
@ -95,7 +101,11 @@ namespace UnityTest
public void OnEnable()
{
titleContent = new GUIContent("Integration Tests");
#if UNITY_5_3_OR_NEWER
titleContent = new GUIContent("Integration Tests");
#else
title = "Integration Tests";
#endif
s_Instance = this;
m_Settings = ProjectSettingsBase.Load<IntegrationTestsRunnerSettings>();
@ -241,7 +251,11 @@ namespace UnityTest
if (!EditorApplication.isPlayingOrWillChangePlaymode)
{
var dynamicTestsOnScene = TestComponent.FindAllDynamicTestsOnScene();
#if UNITY_5_3_OR_NEWER
var dynamicTestTypes = TestComponent.GetTypesWithHelpAttribute(SceneManager.GetActiveScene().path);
#else
var dynamicTestTypes = TestComponent.GetTypesWithHelpAttribute(Application.loadedLevelName);
#endif
foreach (var dynamicTestType in dynamicTestTypes)
{

4
Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/NetworkResultsReceiver.cs

@ -177,7 +177,11 @@ namespace UnityTest
public void OnEnable()
{
minSize = new Vector2(300, 100);
#if UNITY_5_3_OR_NEWER
titleContent = new GUIContent("Test run monitor");
#else
title = "Test run monitor";
#endif
Instance = this;
m_StatusLabel = "Initializing...";
if (EditorApplication.isCompiling) return;

11
Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerConfiguration.cs

@ -6,7 +6,10 @@ using System.Net;
using System.Net.Sockets;
using UnityEditor;
using UnityEngine;
#if UNITY_5_3_OR_NEWER
using UnityEngine.SceneManagement;
#endif
[Serializable]
public class PlatformRunnerConfiguration
@ -15,7 +18,11 @@ public class PlatformRunnerConfiguration
public List<string> testScenes;
public BuildTarget buildTarget;
public bool runInEditor;
#if UNITY_5_3_OR_NEWER
public string projectName = SceneManager.GetActiveScene().path;
#else
public string projectName = Application.loadedLevelName;
#endif
public string resultsDir = null;
public bool sendResultsOverNetwork;
@ -25,7 +32,11 @@ public class PlatformRunnerConfiguration
public PlatformRunnerConfiguration(BuildTarget buildTarget)
{
this.buildTarget = buildTarget;
#if UNITY_5_3_OR_NEWER
projectName = SceneManager.GetActiveScene().path;
#else
projectName = Application.loadedLevelName;
#endif
}
public PlatformRunnerConfiguration()

19
Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerSettingsWindow.cs

@ -6,7 +6,9 @@ using System.Net;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
#if UNITY_5_3_OR_NEWER
using UnityEngine.SceneManagement;
#endif
namespace UnityTest.IntegrationTests
{
@ -43,12 +45,21 @@ namespace UnityTest.IntegrationTests
if (m_IntegrationTestScenes == null)
m_IntegrationTestScenes = new List<string> ();
titleContent = new GUIContent("Platform runner");
#if UNITY_5_3_OR_NEWER
titleContent = new GUIContent("Platform runner");
#else
title = "Platform runner";
#endif
m_BuildTarget = PlatformRunner.defaultBuildTarget;
position.Set(position.xMin, position.yMin, 200, position.height);
m_AllScenesInProject = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.unity", SearchOption.AllDirectories).ToList();
m_AllScenesInProject.Sort();
var currentScene = (Directory.GetCurrentDirectory() + SceneManager.GetActiveScene().path).Replace("\\", "").Replace("/", "");
#if UNITY_5_3_OR_NEWER
var currentScene = (Directory.GetCurrentDirectory() + SceneManager.GetActiveScene().path).Replace("\\", "").Replace("/", "");
#else
var currentScene = (Directory.GetCurrentDirectory() + Application.loadedLevelName).Replace("\\", "").Replace("/", "");
#endif
var currentScenePath = m_AllScenesInProject.Where(s => s.Replace("\\", "").Replace("/", "") == currentScene);
m_SelectedScenes.AddRange(currentScenePath);
@ -267,7 +278,11 @@ namespace UnityTest.IntegrationTests
buildTarget = m_BuildTarget,
buildScenes = m_OtherScenesToBuild,
testScenes = m_IntegrationTestScenes,
#if UNITY_5_3_OR_NEWER
projectName = m_IntegrationTestScenes.Count > 1 ? "IntegrationTests" : Path.GetFileNameWithoutExtension(SceneManager.GetActiveScene().path),
#else
projectName = m_IntegrationTestScenes.Count > 1 ? "IntegrationTests" : Path.GetFileNameWithoutExtension(Application.loadedLevelName),
#endif
resultsDir = m_Settings.resultsPath,
sendResultsOverNetwork = m_Settings.sendResultsOverNetwork,
ipList = m_Interfaces.Skip(1).ToList(),

6
Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/TestComponentEditor.cs

@ -4,7 +4,9 @@ using System.Linq;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
#if UNITY_5_3_OR_NEWER
using UnityEditor.SceneManagement;
#endif
namespace UnityTest
{
@ -103,7 +105,11 @@ namespace UnityTest
if (!component.dynamic)
serializedObject.ApplyModifiedProperties();
if (GUI.changed)
#if UNITY_5_3_OR_NEWER
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
#else
EditorApplication.MarkSceneDirty();
#endif
}
private string[] GetListOfIgnoredPlatforms(string[] enumList, int flags)

10
Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/ResultDTO.cs

@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_5_3_OR_NEWER
using UnityEngine.SceneManagement;
#endif
namespace UnityTest
{
@ -19,9 +21,15 @@ namespace UnityTest
private ResultDTO(MessageType messageType)
{
this.messageType = messageType;
levelCount = UnityEngine.SceneManagement.SceneManager.sceneCount;
#if UNITY_5_3_OR_NEWER
levelCount = UnityEngine.SceneManagement.SceneManager.sceneCount;
loadedLevel = UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex;
loadedLevelName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
#else
levelCount = Application.levelCount;
loadedLevel = Application.loadedLevel;
loadedLevelName = Application.loadedLevelName;
#endif
}
public enum MessageType : byte

6
Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestComponent.cs

@ -3,7 +3,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;
#if UNITY_5_3_OR_NEWER
using UnityEngine.SceneManagement;
#endif
#if UNITY_EDITOR
using UnityEditor;
@ -308,10 +310,10 @@ namespace UnityTest
public static bool AnyDynamicTestForCurrentScene()
{
#if UNITY_EDITOR
#if UNITY_5_3_OR_NEWER
return TestComponent.GetTypesWithHelpAttribute(SceneManager.GetActiveScene().name).Any();
#else
return TestComponent.GetTypesWithHelpAttribute(SceneManager.GetActiveScene().name).Any();
return TestComponent.GetTypesWithHelpAttribute(Application.loadedLevelName).Any();
#endif
}

19
Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestRunner.cs

@ -8,7 +8,9 @@ using System.Reflection;
using UnityEngine;
using UnityTest.IntegrationTestRunner;
using System.IO;
#if UNITY_5_3_OR_NEWER
using UnityEngine.SceneManagement;
#endif
namespace UnityTest
{
@ -75,7 +77,11 @@ namespace UnityTest
}
TestComponent.DestroyAllDynamicTests();
#if UNITY_5_3_OR_NEWER
var dynamicTestTypes = TestComponent.GetTypesWithHelpAttribute(SceneManager.GetActiveScene().name);
#else
var dynamicTestTypes = TestComponent.GetTypesWithHelpAttribute("");
#endif
foreach (var dynamicTestType in dynamicTestTypes)
TestComponent.CreateDynamicTest(dynamicTestType);
@ -310,7 +316,11 @@ namespace UnityTest
string testScene = m_Configurator.GetIntegrationTestScenes(TestSceneNumber);
if (testScene != null)
{
#if UNITY_5_3_OR_NEWER
SceneManager.LoadScene(Path.GetFileNameWithoutExtension(testScene));
#endif
}
else
{
TestRunnerCallback.AllScenesFinished();
@ -373,7 +383,14 @@ namespace UnityTest
currentTest = null;
if (!testResult.IsSuccess
&& testResult.Executed
&& !testResult.IsIgnored) k_ResultRenderer.AddResults(SceneManager.GetActiveScene().name, testResult);
&& !testResult.IsIgnored)
{
#if UNITY_5_3_OR_NEWER
k_ResultRenderer.AddResults(SceneManager.GetActiveScene().name, testResult);
#else
k_ResultRenderer.AddResults(Application.loadedLevelName, testResult);
#endif
}
}
#region Test Runner Helpers

Loading…
Cancel
Save