diff --git a/Assets/LINQtoGameObject/Examples/SampleScene.unity b/Assets/LINQtoGameObject/Examples/SampleScene.unity index 89cdac9..f2140b7 100644 Binary files a/Assets/LINQtoGameObject/Examples/SampleScene.unity and b/Assets/LINQtoGameObject/Examples/SampleScene.unity differ diff --git a/Assets/Sandbox/uGUI.unity b/Assets/Sandbox/uGUI.unity new file mode 100644 index 0000000..8de705d Binary files /dev/null and b/Assets/Sandbox/uGUI.unity differ diff --git a/Assets/Sandbox/uGUIScene.cs b/Assets/Sandbox/uGUIScene.cs new file mode 100644 index 0000000..d3c6f62 --- /dev/null +++ b/Assets/Sandbox/uGUIScene.cs @@ -0,0 +1,41 @@ +using UnityEngine; +using Unity.Linq; +using System.Collections; +using UnityEngine.UI; +using UnityEngine.EventSystems; + +public class uGUIScene : MonoBehaviour +{ + public GameObject Panel; + public GameObject CloneFrom; + public Button Button; + public int HogeHoge; + + public void OnEnable() + { + var clone = GameObject.Instantiate(CloneFrom); + Panel.MoveToLast(clone); + } + + + + + // Use this for initialization + void Start() + { + + Button.onClick.AddListener(() => + { + var clone = GameObject.Instantiate(CloneFrom); + + Panel.MoveToLast(clone); + }); + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/Assets/UnityTestTools/Assertions/AssertionComponent.cs b/Assets/UnityTestTools/Assertions/AssertionComponent.cs index 4d81ede..4a3dc48 100644 --- a/Assets/UnityTestTools/Assertions/AssertionComponent.cs +++ b/Assets/UnityTestTools/Assertions/AssertionComponent.cs @@ -42,10 +42,12 @@ public ActionBase Action public Object GetFailureReferenceObject() { + #if UNITY_EDITOR if (!string.IsNullOrEmpty(m_CreatedInFilePath)) { return Resources.LoadAssetAtPath(m_CreatedInFilePath, typeof(Object)); } + #endif return this; } diff --git a/Assets/UnityTestTools/Assertions/Editor/AssertionExplorerWindow.cs b/Assets/UnityTestTools/Assertions/Editor/AssertionExplorerWindow.cs index bb4ed30..293d524 100644 --- a/Assets/UnityTestTools/Assertions/Editor/AssertionExplorerWindow.cs +++ b/Assets/UnityTestTools/Assertions/Editor/AssertionExplorerWindow.cs @@ -136,18 +136,18 @@ private IListRenderer GetResultRendere() private void DrawMenuPanel() { - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.LabelField("Group by", GUILayout.MaxWidth(60)); - m_GroupBy = (GroupByType)EditorGUILayout.EnumPopup(m_GroupBy, GUILayout.MaxWidth(150)); + EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); + EditorGUILayout.LabelField("Group by:", Styles.toolbarLabel, GUILayout.MaxWidth(60)); + m_GroupBy = (GroupByType)EditorGUILayout.EnumPopup(m_GroupBy, EditorStyles.toolbarPopup, GUILayout.MaxWidth(150)); GUILayout.FlexibleSpace(); - m_ShowType = (ShowType)EditorGUILayout.EnumPopup(m_ShowType, GUILayout.MaxWidth(100)); + m_ShowType = (ShowType)EditorGUILayout.EnumPopup(m_ShowType, EditorStyles.toolbarPopup, GUILayout.MaxWidth(100)); - EditorGUILayout.LabelField("Filter by", GUILayout.MaxWidth(50)); - m_FilterType = (FilterType)EditorGUILayout.EnumPopup(m_FilterType, GUILayout.MaxWidth(100)); - m_FilterText = EditorGUILayout.TextField(m_FilterText, GUILayout.MaxWidth(100)); - if (GUILayout.Button("Clear", GUILayout.ExpandWidth(false))) + EditorGUILayout.LabelField("Filter by:", Styles.toolbarLabel, GUILayout.MaxWidth(50)); + m_FilterType = (FilterType)EditorGUILayout.EnumPopup(m_FilterType, EditorStyles.toolbarPopup, GUILayout.MaxWidth(100)); + m_FilterText = GUILayout.TextField(m_FilterText, "ToolbarSeachTextField", GUILayout.MaxWidth(100)); + if (GUILayout.Button(GUIContent.none, string.IsNullOrEmpty(m_FilterText) ? "ToolbarSeachCancelButtonEmpty" : "ToolbarSeachCancelButton", GUILayout.ExpandWidth(false))) m_FilterText = ""; EditorGUILayout.EndHorizontal(); } diff --git a/Assets/UnityTestTools/Assertions/MemberResolver.cs b/Assets/UnityTestTools/Assertions/MemberResolver.cs index aa97e50..65f7351 100644 --- a/Assets/UnityTestTools/Assertions/MemberResolver.cs +++ b/Assets/UnityTestTools/Assertions/MemberResolver.cs @@ -42,8 +42,11 @@ public object GetValue(bool useCache) var member = fullCallStack[i]; result = GetValueFromMember(result, member); tempCallstack.Add(member); - if (result == null) return null; - if (!IsValueType(result.GetType())) + if (result == null) return null; + var type = result.GetType(); + + //String is not a value type but we don't want to cache it + if (!IsValueType(type) && type != typeof(System.String)) { tempCallstack.Clear(); m_CallingObjectRef = result; diff --git a/Assets/UnityTestTools/Common/Editor/Icons.cs b/Assets/UnityTestTools/Common/Editor/Icons.cs index 085339c..e85d20f 100644 --- a/Assets/UnityTestTools/Common/Editor/Icons.cs +++ b/Assets/UnityTestTools/Common/Editor/Icons.cs @@ -16,15 +16,10 @@ public static class Icons public static readonly Texture2D FailImg; public static readonly Texture2D IgnoreImg; - public static readonly Texture2D RunImg; - public static readonly Texture2D RunFailedImg; - public static readonly Texture2D RunAllImg; public static readonly Texture2D SuccessImg; public static readonly Texture2D UnknownImg; public static readonly Texture2D InconclusiveImg; public static readonly Texture2D StopwatchImg; - public static readonly Texture2D PlusImg; - public static readonly Texture2D GearImg; public static readonly GUIContent GUIUnknownImg; public static readonly GUIContent GUIInconclusiveImg; @@ -47,23 +42,6 @@ static Icons() InconclusiveImg = LoadTexture("inconclusive.png"); StopwatchImg = LoadTexture("stopwatch.png"); - if (EditorGUIUtility.isProSkin) - { - RunAllImg = LoadTexture("play-darktheme.png"); - RunImg = LoadTexture("play_selected-darktheme.png"); - RunFailedImg = LoadTexture("rerun-darktheme.png"); - PlusImg = LoadTexture("create-darktheme.png"); - GearImg = LoadTexture("options-darktheme.png"); - } - else - { - RunAllImg = LoadTexture("play-lighttheme.png"); - RunImg = LoadTexture("play_selected-lighttheme.png"); - RunFailedImg = LoadTexture("rerun-lighttheme.png"); - PlusImg = LoadTexture("create-lighttheme.png"); - GearImg = LoadTexture("options-lighttheme.png"); - } - GUIUnknownImg = new GUIContent(UnknownImg); GUIInconclusiveImg = new GUIContent(InconclusiveImg); GUIIgnoreImg = new GUIContent(IgnoreImg); diff --git a/Assets/UnityTestTools/Common/Editor/ProjectSettingsBase.cs b/Assets/UnityTestTools/Common/Editor/ProjectSettingsBase.cs index 0639a4f..99cafad 100644 --- a/Assets/UnityTestTools/Common/Editor/ProjectSettingsBase.cs +++ b/Assets/UnityTestTools/Common/Editor/ProjectSettingsBase.cs @@ -12,7 +12,7 @@ public abstract class ProjectSettingsBase : ScriptableObject private static readonly string k_SettingsPath = Path.Combine("UnityTestTools", "Common"); const string k_SettingsFolder = "Settings"; - public void Save() + public virtual void Save() { EditorUtility.SetDirty(this); } diff --git a/Assets/UnityTestTools/Common/Editor/ResultWriter/ResultSummarizer.cs b/Assets/UnityTestTools/Common/Editor/ResultWriter/ResultSummarizer.cs index a695036..cfd39ca 100644 --- a/Assets/UnityTestTools/Common/Editor/ResultWriter/ResultSummarizer.cs +++ b/Assets/UnityTestTools/Common/Editor/ResultWriter/ResultSummarizer.cs @@ -25,7 +25,7 @@ public class ResultSummarizer private TimeSpan m_Duration; - public ResultSummarizer(ITestResult[] results) + public ResultSummarizer(IEnumerable results) { foreach (var result in results) Summarize(result); @@ -125,7 +125,19 @@ public void Summarize(ITestResult result) { m_Duration += TimeSpan.FromSeconds(result.Duration); m_ResultCount++; - + + if(!result.Executed) + { + if(result.IsIgnored) + { + m_IgnoreCount++; + return; + } + + m_SkipCount++; + return; + } + switch (result.ResultState) { case TestResultState.Success: diff --git a/Assets/UnityTestTools/Common/Editor/Styles.cs b/Assets/UnityTestTools/Common/Editor/Styles.cs index e7cd8f1..0caf6e1 100644 --- a/Assets/UnityTestTools/Common/Editor/Styles.cs +++ b/Assets/UnityTestTools/Common/Editor/Styles.cs @@ -7,43 +7,41 @@ namespace UnityTest { public static class Styles { - public static GUIStyle buttonLeft; - public static GUIStyle buttonMid; - public static GUIStyle buttonRight; public static GUIStyle info; public static GUIStyle testList; - public static GUIStyle selectedLabel; - public static GUIStyle label; public static GUIStyle selectedFoldout; public static GUIStyle foldout; + public static GUIStyle toolbarLabel; + + public static GUIStyle testName; private static readonly Color k_SelectedColor = new Color(0.3f, 0.5f, 0.85f); static Styles() { - buttonLeft = GUI.skin.FindStyle(GUI.skin.button.name + "left"); - buttonMid = GUI.skin.FindStyle(GUI.skin.button.name + "mid"); - buttonRight = GUI.skin.FindStyle(GUI.skin.button.name + "right"); - info = new GUIStyle(EditorStyles.wordWrappedLabel); info.wordWrap = false; info.stretchHeight = true; info.margin.right = 15; testList = new GUIStyle("CN Box"); - testList.margin.top = 3; + testList.margin.top = 0; testList.padding.left = 3; - label = new GUIStyle(EditorStyles.label); - selectedLabel = new GUIStyle(EditorStyles.label); - selectedLabel.active.textColor = selectedLabel.normal.textColor = selectedLabel.onActive.textColor = k_SelectedColor; - foldout = new GUIStyle(EditorStyles.foldout); selectedFoldout = new GUIStyle(EditorStyles.foldout); selectedFoldout.onFocused.textColor = selectedFoldout.focused.textColor = selectedFoldout.onActive.textColor = selectedFoldout.active.textColor = selectedFoldout.onNormal.textColor = selectedFoldout.normal.textColor = k_SelectedColor; + + toolbarLabel = new GUIStyle(EditorStyles.toolbarButton); + toolbarLabel.normal.background = null; + toolbarLabel.contentOffset = new Vector2(0, -2); + + testName = new GUIStyle(EditorStyles.label); + testName.padding.left += 12; + testName.focused.textColor = testName.onFocused.textColor = k_SelectedColor; } } } diff --git a/Assets/UnityTestTools/Common/Editor/TestFilterSettings.cs b/Assets/UnityTestTools/Common/Editor/TestFilterSettings.cs new file mode 100644 index 0000000..cef016a --- /dev/null +++ b/Assets/UnityTestTools/Common/Editor/TestFilterSettings.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using System.Linq; + +namespace UnityTest +{ + public class TestFilterSettings + { + public bool ShowSucceeded; + public bool ShowFailed; + public bool ShowIgnored; + public bool ShowNotRun; + + public string FilterByName; + public int FilterByCategory; + + private GUIContent _succeededBtn; + private GUIContent _failedBtn; + private GUIContent _ignoredBtn; + private GUIContent _notRunBtn; + + public string[] AvailableCategories; + + private readonly string _prefsKey; + + public TestFilterSettings(string prefsKey) + { + _prefsKey = prefsKey; + Load(); + UpdateCounters(Enumerable.Empty()); + } + + public void Load() + { + ShowSucceeded = EditorPrefs.GetBool(_prefsKey + ".ShowSucceeded", true); + ShowFailed = EditorPrefs.GetBool(_prefsKey + ".ShowFailed", true); + ShowIgnored = EditorPrefs.GetBool(_prefsKey + ".ShowIgnored", true); + ShowNotRun = EditorPrefs.GetBool(_prefsKey + ".ShowNotRun", true); + FilterByName = EditorPrefs.GetString(_prefsKey + ".FilterByName", string.Empty); + FilterByCategory = EditorPrefs.GetInt(_prefsKey + ".FilterByCategory", 0); + } + + public void Save() + { + EditorPrefs.SetBool(_prefsKey + ".ShowSucceeded", ShowSucceeded); + EditorPrefs.SetBool(_prefsKey + ".ShowFailed", ShowFailed); + EditorPrefs.SetBool(_prefsKey + ".ShowIgnored", ShowIgnored); + EditorPrefs.SetBool(_prefsKey + ".ShowNotRun", ShowNotRun); + EditorPrefs.SetString(_prefsKey + ".FilterByName", FilterByName); + EditorPrefs.SetInt(_prefsKey + ".FilterByCategory", FilterByCategory); + } + + public void UpdateCounters(IEnumerable results) + { + var summary = new ResultSummarizer(results); + + _succeededBtn = new GUIContent(summary.Passed.ToString(), Icons.SuccessImg, "Show tests that succeeded"); + _failedBtn = new GUIContent((summary.Errors + summary.Failures + summary.Inconclusive).ToString(), Icons.FailImg, "Show tests that failed"); + _ignoredBtn = new GUIContent((summary.Ignored + summary.NotRunnable).ToString(), Icons.IgnoreImg, "Show tests that are ignored"); + _notRunBtn = new GUIContent((summary.TestsNotRun - summary.Ignored - summary.NotRunnable).ToString(), Icons.UnknownImg, "Show tests that didn't run"); + } + + public string[] GetSelectedCategories() + { + if(AvailableCategories == null) return new string[0]; + + return AvailableCategories.Where ((c, i) => (FilterByCategory & (1 << i)) != 0).ToArray(); + } + + public void OnGUI() + { + EditorGUI.BeginChangeCheck(); + + FilterByName = GUILayout.TextField(FilterByName, "ToolbarSeachTextField", GUILayout.MinWidth(100), GUILayout.MaxWidth(250), GUILayout.ExpandWidth(true)); + if(GUILayout.Button (GUIContent.none, string.IsNullOrEmpty(FilterByName) ? "ToolbarSeachCancelButtonEmpty" : "ToolbarSeachCancelButton")) + FilterByName = string.Empty; + + if (AvailableCategories != null && AvailableCategories.Length > 0) + FilterByCategory = EditorGUILayout.MaskField(FilterByCategory, AvailableCategories, EditorStyles.toolbarDropDown, GUILayout.MaxWidth(90)); + + ShowSucceeded = GUILayout.Toggle(ShowSucceeded, _succeededBtn, EditorStyles.toolbarButton); + ShowFailed = GUILayout.Toggle(ShowFailed, _failedBtn, EditorStyles.toolbarButton); + ShowIgnored = GUILayout.Toggle(ShowIgnored, _ignoredBtn, EditorStyles.toolbarButton); + ShowNotRun = GUILayout.Toggle(ShowNotRun, _notRunBtn, EditorStyles.toolbarButton); + + if(EditorGUI.EndChangeCheck()) Save (); + } + + public RenderingOptions BuildRenderingOptions() + { + var options = new RenderingOptions(); + options.showSucceeded = ShowSucceeded; + options.showFailed = ShowFailed; + options.showIgnored = ShowIgnored; + options.showNotRunned = ShowNotRun; + options.nameFilter = FilterByName; + options.categories = GetSelectedCategories(); + return options; + } + } + +} diff --git a/Assets/UnityTestTools/Common/Editor/icons/create-darktheme.png b/Assets/UnityTestTools/Common/Editor/icons/create-darktheme.png deleted file mode 100644 index 2200e30..0000000 Binary files a/Assets/UnityTestTools/Common/Editor/icons/create-darktheme.png and /dev/null differ diff --git a/Assets/UnityTestTools/Common/Editor/icons/create-lighttheme.png b/Assets/UnityTestTools/Common/Editor/icons/create-lighttheme.png deleted file mode 100644 index faf4d72..0000000 Binary files a/Assets/UnityTestTools/Common/Editor/icons/create-lighttheme.png and /dev/null differ diff --git a/Assets/UnityTestTools/Common/Editor/icons/options-darktheme.png b/Assets/UnityTestTools/Common/Editor/icons/options-darktheme.png deleted file mode 100644 index 8710af2..0000000 Binary files a/Assets/UnityTestTools/Common/Editor/icons/options-darktheme.png and /dev/null differ diff --git a/Assets/UnityTestTools/Common/Editor/icons/options-lighttheme.png b/Assets/UnityTestTools/Common/Editor/icons/options-lighttheme.png deleted file mode 100644 index e33c43f..0000000 Binary files a/Assets/UnityTestTools/Common/Editor/icons/options-lighttheme.png and /dev/null differ diff --git a/Assets/UnityTestTools/Common/Editor/icons/play-darktheme.png b/Assets/UnityTestTools/Common/Editor/icons/play-darktheme.png deleted file mode 100644 index c522086..0000000 Binary files a/Assets/UnityTestTools/Common/Editor/icons/play-darktheme.png and /dev/null differ diff --git a/Assets/UnityTestTools/Common/Editor/icons/play-lighttheme.png b/Assets/UnityTestTools/Common/Editor/icons/play-lighttheme.png deleted file mode 100644 index 30207ad..0000000 Binary files a/Assets/UnityTestTools/Common/Editor/icons/play-lighttheme.png and /dev/null differ diff --git a/Assets/UnityTestTools/Common/Editor/icons/play_selected-darktheme.png b/Assets/UnityTestTools/Common/Editor/icons/play_selected-darktheme.png deleted file mode 100644 index a2471e8..0000000 Binary files a/Assets/UnityTestTools/Common/Editor/icons/play_selected-darktheme.png and /dev/null differ diff --git a/Assets/UnityTestTools/Common/Editor/icons/play_selected-lighttheme.png b/Assets/UnityTestTools/Common/Editor/icons/play_selected-lighttheme.png deleted file mode 100644 index dad2385..0000000 Binary files a/Assets/UnityTestTools/Common/Editor/icons/play_selected-lighttheme.png and /dev/null differ diff --git a/Assets/UnityTestTools/Common/Editor/icons/rerun-darktheme.png b/Assets/UnityTestTools/Common/Editor/icons/rerun-darktheme.png deleted file mode 100644 index 07f10b9..0000000 Binary files a/Assets/UnityTestTools/Common/Editor/icons/rerun-darktheme.png and /dev/null differ diff --git a/Assets/UnityTestTools/Common/Editor/icons/rerun-lighttheme.png b/Assets/UnityTestTools/Common/Editor/icons/rerun-lighttheme.png deleted file mode 100644 index bc2172c..0000000 Binary files a/Assets/UnityTestTools/Common/Editor/icons/rerun-lighttheme.png and /dev/null differ diff --git a/Assets/UnityTestTools/Common/ITestResult.cs b/Assets/UnityTestTools/Common/ITestResult.cs index 20acab2..13f5fc3 100644 --- a/Assets/UnityTestTools/Common/ITestResult.cs +++ b/Assets/UnityTestTools/Common/ITestResult.cs @@ -6,12 +6,24 @@ public interface ITestResult { TestResultState ResultState { get; } + string Message { get; } + + string Logs { get; } + bool Executed { get; } + string Name { get; } + string FullName { get; } + string Id { get; } + bool IsSuccess { get; } + double Duration { get; } + string StackTrace { get; } + + bool IsIgnored { get; } } diff --git a/Assets/UnityTestTools/Examples/AssertionExample/AssertionsExample.unity b/Assets/UnityTestTools/Examples/AssertionExample/AssertionsExample.unity new file mode 100644 index 0000000..5ad1f67 Binary files /dev/null and b/Assets/UnityTestTools/Examples/AssertionExample/AssertionsExample.unity differ diff --git a/Assets/UnityTestTools/Common/Settings/UnitTestsRunnerSettings.asset b/Assets/UnityTestTools/Examples/AssertionExample/Ball.physicMaterial similarity index 54% rename from Assets/UnityTestTools/Common/Settings/UnitTestsRunnerSettings.asset rename to Assets/UnityTestTools/Examples/AssertionExample/Ball.physicMaterial index eb6e8c0..e40833d 100644 Binary files a/Assets/UnityTestTools/Common/Settings/UnitTestsRunnerSettings.asset and b/Assets/UnityTestTools/Examples/AssertionExample/Ball.physicMaterial differ diff --git a/Assets/UnityTestTools/Examples/AssertionExample/BouncingPlane.physicMaterial b/Assets/UnityTestTools/Examples/AssertionExample/BouncingPlane.physicMaterial new file mode 100644 index 0000000..8d7d30d Binary files /dev/null and b/Assets/UnityTestTools/Examples/AssertionExample/BouncingPlane.physicMaterial differ diff --git a/Assets/UnityTestTools/Examples/AssertionExample/BouncingSphere.prefab b/Assets/UnityTestTools/Examples/AssertionExample/BouncingSphere.prefab new file mode 100644 index 0000000..a0bf936 Binary files /dev/null and b/Assets/UnityTestTools/Examples/AssertionExample/BouncingSphere.prefab differ diff --git a/Assets/UnityTestTools/Examples/AssertionExample/Materials/checkerTexture.mat b/Assets/UnityTestTools/Examples/AssertionExample/Materials/checkerTexture.mat new file mode 100644 index 0000000..3279d91 Binary files /dev/null and b/Assets/UnityTestTools/Examples/AssertionExample/Materials/checkerTexture.mat differ diff --git a/Assets/UnityTestTools/Examples/AssertionExample/NotBouncingPlane.physicMaterial b/Assets/UnityTestTools/Examples/AssertionExample/NotBouncingPlane.physicMaterial new file mode 100644 index 0000000..e043ab1 Binary files /dev/null and b/Assets/UnityTestTools/Examples/AssertionExample/NotBouncingPlane.physicMaterial differ diff --git a/Assets/UnityTestTools/Examples/AssertionExample/checkerTexture.png b/Assets/UnityTestTools/Examples/AssertionExample/checkerTexture.png new file mode 100644 index 0000000..bc0b8fb Binary files /dev/null and b/Assets/UnityTestTools/Examples/AssertionExample/checkerTexture.png differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Animations/ShootAdditive.anim b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Animations/ShootAdditive.anim new file mode 100644 index 0000000..645640e Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Animations/ShootAdditive.anim differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/ExampleABTests.unity b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/ExampleABTests.unity new file mode 100644 index 0000000..c0c08ac Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/ExampleABTests.unity differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/Blob_Storm.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/Blob_Storm.mat new file mode 100644 index 0000000..28406b0 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/Blob_Storm.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/BloodA.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/BloodA.mat new file mode 100644 index 0000000..e6cc25d Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/BloodA.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/ElectricShockwave.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/ElectricShockwave.mat new file mode 100644 index 0000000..bf8933a Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/ElectricShockwave.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/EleeectricSparksHitA.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/EleeectricSparksHitA.mat new file mode 100644 index 0000000..c2e3c74 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/EleeectricSparksHitA.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/FireBall_Blue.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/FireBall_Blue.mat new file mode 100644 index 0000000..df24284 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/FireBall_Blue.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/FireballA.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/FireballA.mat new file mode 100644 index 0000000..e8c87d4 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/FireballA.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/ShockWave_Simple.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/ShockWave_Simple.mat new file mode 100644 index 0000000..b2450bd Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/ShockWave_Simple.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/SmokeA.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/SmokeA.mat new file mode 100644 index 0000000..1ef8e7d Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/SmokeA.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/scorchMarkSpider.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/scorchMarkSpider.mat new file mode 100644 index 0000000..cb47aec Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Materials/scorchMarkSpider.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Scripts/EffectSequencer.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Scripts/EffectSequencer.js new file mode 100644 index 0000000..83b0542 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Scripts/EffectSequencer.js @@ -0,0 +1,56 @@ +#pragma strict + +class ExplosionPart { + var gameObject : GameObject = null; + var delay : float = 0.0; + var hqOnly : boolean = false; + var yOffset : float = 0.0; +} + +public var ambientEmitters : ExplosionPart[]; +public var explosionEmitters : ExplosionPart[]; +public var smokeEmitters : ExplosionPart[]; + +public var miscSpecialEffects : ExplosionPart[]; + +function Start () { + var go : ExplosionPart; + var maxTime : float = 0; + + for (go in ambientEmitters) { + InstantiateDelayed(go); + if (go.gameObject.GetComponent.()) + maxTime = Mathf.Max (maxTime, go.delay + go.gameObject.GetComponent.().maxEnergy); + } + for (go in explosionEmitters) { + InstantiateDelayed(go); + if (go.gameObject.GetComponent.()) + maxTime = Mathf.Max (maxTime, go.delay + go.gameObject.GetComponent.().maxEnergy); + } + for (go in smokeEmitters) { + InstantiateDelayed(go); + if (go.gameObject.GetComponent.()) + maxTime = Mathf.Max (maxTime, go.delay + go.gameObject.GetComponent.().maxEnergy); + } + + if (GetComponent.() && GetComponent.().clip) + maxTime = Mathf.Max (maxTime, GetComponent.().clip.length); + + yield; + + for (go in miscSpecialEffects) { + InstantiateDelayed(go); + if (go.gameObject.GetComponent.()) + maxTime = Mathf.Max (maxTime, go.delay + go.gameObject.GetComponent.().maxEnergy); + } + + Destroy (gameObject, maxTime + 0.5); +} + +function InstantiateDelayed (go : ExplosionPart) { + //if (go.hqOnly && QualityManager.quality < Quality.High) + // return; + + yield WaitForSeconds (go.delay); + Instantiate (go.gameObject, transform.position + Vector3.up * go.yOffset, transform.rotation); +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Scripts/MuzzleFlashAnimate.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Scripts/MuzzleFlashAnimate.js new file mode 100644 index 0000000..38d12f4 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Scripts/MuzzleFlashAnimate.js @@ -0,0 +1,7 @@ + +#pragma strict + +function Update () { + transform.localScale = Vector3.one * Random.Range(0.5,1.5); + transform.localEulerAngles.z = Random.Range(0,90.0); +} \ No newline at end of file diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/ElectricSparksA.prefab b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/ElectricSparksA.prefab new file mode 100644 index 0000000..522a62c Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/ElectricSparksA.prefab differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/ElectricSparksC.prefab b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/ElectricSparksC.prefab new file mode 100644 index 0000000..4494ca8 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/ElectricSparksC.prefab differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/ElectricSparksHitA.prefab b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/ElectricSparksHitA.prefab new file mode 100644 index 0000000..8befb27 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/ElectricSparksHitA.prefab differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/Fire_Spider.prefab b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/Fire_Spider.prefab new file mode 100644 index 0000000..5027649 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/Fire_Spider.prefab differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/Fire_Spider_Detonate.prefab b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/Fire_Spider_Detonate.prefab new file mode 100644 index 0000000..99008ff Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/Fire_Spider_Detonate.prefab differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/ShockwaveA.prefab b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/ShockwaveA.prefab new file mode 100644 index 0000000..2a0b491 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/ShockwaveA.prefab differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/Smoke_Spider_Missile.prefab b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/Smoke_Spider_Missile.prefab new file mode 100644 index 0000000..431a4d1 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/SequenceParts/Smoke_Spider_Missile.prefab differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Sequences/ExplosionSequenceSpider.prefab b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Sequences/ExplosionSequenceSpider.prefab new file mode 100644 index 0000000..8ea37f0 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Sequences/ExplosionSequenceSpider.prefab differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Sequences/ExplosionSequenceSpiderDetonate.prefab b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Sequences/ExplosionSequenceSpiderDetonate.prefab new file mode 100644 index 0000000..54319df Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Sequences/ExplosionSequenceSpiderDetonate.prefab differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Standalone/Blood_Splatter.prefab b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Standalone/Blood_Splatter.prefab new file mode 100644 index 0000000..f1160a0 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Standalone/Blood_Splatter.prefab differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/AfterExplosion_B.psd b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/AfterExplosion_B.psd new file mode 100644 index 0000000..c6ed407 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/AfterExplosion_B.psd differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/BloodA_test.psd b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/BloodA_test.psd new file mode 100644 index 0000000..7dbe42a Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/BloodA_test.psd differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/ElectricShockwave1.psd b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/ElectricShockwave1.psd new file mode 100644 index 0000000..a26f41b Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/ElectricShockwave1.psd differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/Fireball_Blue_UVA.psd b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/Fireball_Blue_UVA.psd new file mode 100644 index 0000000..5b634df Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/Fireball_Blue_UVA.psd differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/Fireball_Storm_UVA_01_test.psd b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/Fireball_Storm_UVA_01_test.psd new file mode 100644 index 0000000..23e33ea Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/Fireball_Storm_UVA_01_test.psd differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/Muzzle_Flash_Front_A.psd b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/Muzzle_Flash_Front_A.psd new file mode 100644 index 0000000..bc6227a Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/Muzzle_Flash_Front_A.psd differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/Shockwave.psd b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/Shockwave.psd new file mode 100644 index 0000000..5d076be Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/Shockwave.psd differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/Smoke.psd b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/Smoke.psd new file mode 100644 index 0000000..2da4422 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/Smoke.psd differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/Smoke_Storm_UVA_02_test.psd b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/Smoke_Storm_UVA_02_test.psd new file mode 100644 index 0000000..4ff0dd3 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/Smoke_Storm_UVA_02_test.psd differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/blob.psd b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/blob.psd new file mode 100644 index 0000000..5f0787b Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/blob.psd differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/whiteBlob.psd b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/whiteBlob.psd new file mode 100644 index 0000000..debefd7 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Explosions/Textures/whiteBlob.psd differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/Cursor.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/Cursor.mat new file mode 100644 index 0000000..e7df346 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/Cursor.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/Decal.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/Decal.mat new file mode 100644 index 0000000..f06da80 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/Decal.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/GlowPlane.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/GlowPlane.mat new file mode 100644 index 0000000..6c30a02 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/GlowPlane.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/LaserDot.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/LaserDot.mat new file mode 100644 index 0000000..15c16f5 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/LaserDot.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/LaserMaterial.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/LaserMaterial.mat new file mode 100644 index 0000000..dad1cda Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/LaserMaterial.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/Reflection.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/Reflection.mat new file mode 100644 index 0000000..5fadf7b Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/Reflection.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/Trail.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/Trail.mat new file mode 100644 index 0000000..a7d71c2 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/Trail.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/healthbar_player.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/healthbar_player.mat new file mode 100644 index 0000000..004f43f Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/healthbar_player.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/minebot_diffuse.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/minebot_diffuse.mat new file mode 100644 index 0000000..a3e4163 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/minebot_diffuse.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/weapon.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/weapon.mat new file mode 100644 index 0000000..ee6c054 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Materials/weapon.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Enemies/mine_bot.FBX b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Enemies/mine_bot.FBX new file mode 100644 index 0000000..6c1483c Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Enemies/mine_bot.FBX differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Enemies/mine_bot@awake.FBX b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Enemies/mine_bot@awake.FBX new file mode 100644 index 0000000..6c1483c Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Enemies/mine_bot@awake.FBX differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Enemies/mine_bot@back.FBX b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Enemies/mine_bot@back.FBX new file mode 100644 index 0000000..6c20f33 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Enemies/mine_bot@back.FBX differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Enemies/mine_bot@forward.FBX b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Enemies/mine_bot@forward.FBX new file mode 100644 index 0000000..534e64a Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Enemies/mine_bot@forward.FBX differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Enemies/mine_bot@left.FBX b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Enemies/mine_bot@left.FBX new file mode 100644 index 0000000..8fed363 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Enemies/mine_bot@left.FBX differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Enemies/mine_bot@right.FBX b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Enemies/mine_bot@right.FBX new file mode 100644 index 0000000..e9d23f8 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Enemies/mine_bot@right.FBX differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Misc/Bullet.FBX b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Misc/Bullet.FBX new file mode 100644 index 0000000..b395d6b Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Misc/Bullet.FBX differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Misc/Materials/Bullet-bullet.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Misc/Materials/Bullet-bullet.mat new file mode 100644 index 0000000..7b97035 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Misc/Materials/Bullet-bullet.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Misc/Materials/PlaneSmall-lambert2.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Misc/Materials/PlaneSmall-lambert2.mat new file mode 100644 index 0000000..594d82f Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Misc/Materials/PlaneSmall-lambert2.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Misc/Materials/plane-lambert2.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Misc/Materials/plane-lambert2.mat new file mode 100644 index 0000000..438285e Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Misc/Materials/plane-lambert2.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Misc/Plane.fbx b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Misc/Plane.fbx new file mode 100644 index 0000000..d51783b Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Misc/Plane.fbx differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Misc/PlaneSmall.fbx b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Misc/PlaneSmall.fbx new file mode 100644 index 0000000..d51783b Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Misc/PlaneSmall.fbx differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Player/Materials/muzzleFlash-lambert21.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Player/Materials/muzzleFlash-lambert21.mat new file mode 100644 index 0000000..28d6896 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Player/Materials/muzzleFlash-lambert21.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Player/Materials/player-01 - default.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Player/Materials/player-01 - default.mat new file mode 100644 index 0000000..fe47304 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Player/Materials/player-01 - default.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Player/Materials/player-healthglow.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Player/Materials/player-healthglow.mat new file mode 100644 index 0000000..fdc6537 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Player/Materials/player-healthglow.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Player/MuzzleFlash.fbx b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Player/MuzzleFlash.fbx new file mode 100644 index 0000000..379638b Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Player/MuzzleFlash.fbx differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Player/Player.FBX b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Player/Player.FBX new file mode 100644 index 0000000..6773b56 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Objects/Player/Player.FBX differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/PhysicMaterials/Enemy.physicMaterial b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/PhysicMaterials/Enemy.physicMaterial new file mode 100644 index 0000000..7a0cffd Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/PhysicMaterials/Enemy.physicMaterial differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/PhysicMaterials/Frictionless.physicMaterial b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/PhysicMaterials/Frictionless.physicMaterial new file mode 100644 index 0000000..cca3cf9 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/PhysicMaterials/Frictionless.physicMaterial differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Prefabs/Enemies/EnemySpider.prefab b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Prefabs/Enemies/EnemySpider.prefab new file mode 100644 index 0000000..782c93a Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Prefabs/Enemies/EnemySpider.prefab differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Prefabs/Enemies/spiderScorchMark.prefab b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Prefabs/Enemies/spiderScorchMark.prefab new file mode 100644 index 0000000..bd38c86 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Prefabs/Enemies/spiderScorchMark.prefab differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Prefabs/Misc/Joystick.prefab b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Prefabs/Misc/Joystick.prefab new file mode 100644 index 0000000..2f4b47b Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Prefabs/Misc/Joystick.prefab differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Prefabs/Player/Cursor.prefab b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Prefabs/Player/Cursor.prefab new file mode 100644 index 0000000..2207c1c Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Prefabs/Player/Cursor.prefab differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Prefabs/Player/PlayerPrefab.prefab b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Prefabs/Player/PlayerPrefab.prefab new file mode 100644 index 0000000..c6680d3 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Prefabs/Player/PlayerPrefab.prefab differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Prefabs/Weapons/InstantBullet.prefab b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Prefabs/Weapons/InstantBullet.prefab new file mode 100644 index 0000000..df2f8a7 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Prefabs/Weapons/InstantBullet.prefab differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/AI/AI.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/AI/AI.js new file mode 100644 index 0000000..a61d9ad --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/AI/AI.js @@ -0,0 +1,67 @@ +#pragma strict + +// Public member data +public var behaviourOnSpotted : MonoBehaviour; +public var soundOnSpotted : AudioClip; +public var behaviourOnLostTrack : MonoBehaviour; + +// Private memeber data +private var character : Transform; +private var player : Transform; +private var insideInterestArea : boolean = true; + +function Awake () { + character = transform; + player = GameObject.FindWithTag ("Player").transform; +} + +function OnEnable () { + behaviourOnLostTrack.enabled = true; + behaviourOnSpotted.enabled = false; +} + +function OnTriggerEnter (other : Collider) { + if (other.transform == player && CanSeePlayer ()) { + OnSpotted (); + } +} + +function OnEnterInterestArea () { + insideInterestArea = true; +} + +function OnExitInterestArea () { + insideInterestArea = false; + OnLostTrack (); +} + +function OnSpotted () { + if (!insideInterestArea) + return; + if (!behaviourOnSpotted.enabled) { + behaviourOnSpotted.enabled = true; + behaviourOnLostTrack.enabled = false; + + if (GetComponent.() && soundOnSpotted) { + GetComponent.().clip = soundOnSpotted; + GetComponent.().Play (); + } + } +} + +function OnLostTrack () { + if (!behaviourOnLostTrack.enabled) { + behaviourOnLostTrack.enabled = true; + behaviourOnSpotted.enabled = false; + } +} + +function CanSeePlayer () : boolean { + var playerDirection : Vector3 = (player.position - character.position); + var hit : RaycastHit; + Physics.Raycast (character.position, playerDirection, hit, playerDirection.magnitude); + if (hit.collider && hit.collider.transform == player) { + return true; + } + return false; +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/AI/DisableOutsideRadius.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/AI/DisableOutsideRadius.js new file mode 100644 index 0000000..ab55a88 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/AI/DisableOutsideRadius.js @@ -0,0 +1,41 @@ +#pragma strict + +@script RequireComponent (SphereCollider) + +private var target : GameObject; +private var sphereCollider : SphereCollider; +private var activeRadius : float; + +function Awake () { + target = transform.parent.gameObject; + sphereCollider = GetComponent. (); + activeRadius = sphereCollider.radius; + + Disable (); +} + +function OnTriggerEnter (other : Collider) { + if (other.tag == "Player" && target.transform.parent == transform) { + Enable (); + } +} + +function OnTriggerExit (other : Collider) { + if (other.tag == "Player") { + Disable (); + } +} + +function Disable () { + transform.parent = target.transform.parent; + target.transform.parent = transform; + target.SetActive (false); + sphereCollider.radius = activeRadius; +} + +function Enable () { + target.transform.parent = transform.parent; + target.SetActive (true); + transform.parent = target.transform; + sphereCollider.radius = activeRadius * 1.1; +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/AI/PatrolPoint.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/AI/PatrolPoint.js new file mode 100644 index 0000000..36649b6 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/AI/PatrolPoint.js @@ -0,0 +1,7 @@ +#pragma strict + +var position : Vector3; + +function Awake () { + position = transform.position; +} \ No newline at end of file diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/AI/SpiderAttackMoveController.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/AI/SpiderAttackMoveController.js new file mode 100644 index 0000000..63e6856 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/AI/SpiderAttackMoveController.js @@ -0,0 +1,142 @@ +#pragma strict + +// Public member data +public var motor : MovementMotor; + +public var targetDistanceMin : float = 2.0; +public var targetDistanceMax : float = 3.0; +public var proximityDistance : float = 4.0; +public var damageRadius : float = 5.0; +public var proximityBuildupTime : float = 2.0; +public var proximityOfNoReturn : float = 0.6; +public var damageAmount : float = 30.0; +public var proximityRenderer : Renderer; +public var audioSource : AudioSource; +public var blinkComponents : SelfIlluminationBlink[]; +public var blinkPlane : GlowPlane; + +public var intentionalExplosion : GameObject; +public var animationBehaviour : MonoBehaviour; + +// Private memeber data +private var ai : AI; + +private var character : Transform; + +private var player : Transform; + +private var inRange : boolean = false; +private var nextRaycastTime : float = 0; +private var lastRaycastSuccessfulTime : float = 0; +private var proximityLevel : float = 0; +private var lastBlinkTime : float = 0; +private var noticeTime : float = 0; + +function Awake () { + character = motor.transform; + player = GameObject.FindWithTag ("Player").transform; + ai = transform.parent.GetComponentInChildren. (); + if (!blinkComponents.Length) + blinkComponents = transform.parent.GetComponentsInChildren. (); +} + +function OnEnable () { + inRange = false; + nextRaycastTime = Time.time; + lastRaycastSuccessfulTime = Time.time; + noticeTime = Time.time; + animationBehaviour.enabled = true; + if (blinkPlane) + blinkPlane.GetComponent.().enabled = false; +} + +function OnDisable () { + if (proximityRenderer == null) + Debug.LogError ("proximityRenderer is null", this); + else if (proximityRenderer.material == null) + Debug.LogError ("proximityRenderer.material is null", this); + else + proximityRenderer.material.color = Color.white; + if (blinkPlane) + blinkPlane.GetComponent.().enabled = false; +} + +function Update () { + if (Time.time < noticeTime + 0.7) { + motor.movementDirection = Vector3.zero; + return; + } + + // Calculate the direction from the player to this character + var playerDirection : Vector3 = (player.position - character.position); + playerDirection.y = 0; + var playerDist : float = playerDirection.magnitude; + playerDirection /= playerDist; + + // Set this character to face the player, + // that is, to face the direction from this character to the player + //motor.facingDirection = playerDirection; + + if (inRange && playerDist > targetDistanceMax) + inRange = false; + if (!inRange && playerDist < targetDistanceMin) + inRange = true; + + if (inRange) + motor.movementDirection = Vector3.zero; + else + motor.movementDirection = playerDirection; + + if ((playerDist < proximityDistance && Time.time < lastRaycastSuccessfulTime + 1) || proximityLevel > proximityOfNoReturn) + proximityLevel += Time.deltaTime / proximityBuildupTime; + else + proximityLevel -= Time.deltaTime / proximityBuildupTime; + + proximityLevel = Mathf.Clamp01 (proximityLevel); + //proximityRenderer.material.color = Color.Lerp (Color.blue, Color.red, proximityLevel); + if (proximityLevel == 1) + Explode (); + + if (Time.time > nextRaycastTime) { + nextRaycastTime = Time.time + 1; + if (ai.CanSeePlayer ()) { + lastRaycastSuccessfulTime = Time.time; + } + else { + if (Time.time > lastRaycastSuccessfulTime + 2) { + ai.OnLostTrack (); + } + } + } + + var deltaBlink = 1 / Mathf.Lerp (2, 15, proximityLevel); + if (Time.time > lastBlinkTime + deltaBlink) { + lastBlinkTime = Time.time; + proximityRenderer.material.color = Color.red; + if (audioSource.enabled) + { + audioSource.Play (); + } + for (var comp : SelfIlluminationBlink in blinkComponents) { + comp.Blink (); + } + if (blinkPlane) + blinkPlane.GetComponent.().enabled = !blinkPlane.GetComponent.().enabled; + } + if (Time.time > lastBlinkTime + 0.04) { + proximityRenderer.material.color = Color.white; + } +} + +function Explode () { + var damageFraction : float = 1 - (Vector3.Distance (player.position, character.position) / damageRadius); + + var targetHealth : Health = player.GetComponent. (); + if (targetHealth) { + // Apply damage + targetHealth.OnDamage (damageAmount * damageFraction, character.position - player.position); + } + player.GetComponent.().AddExplosionForce (10, character.position, damageRadius, 0.0, ForceMode.Impulse); + Spawner.Spawn (intentionalExplosion, transform.position, Quaternion.identity); + Spawner.Destroy (character.gameObject); +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/AI/SpiderReturnMoveController.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/AI/SpiderReturnMoveController.js new file mode 100644 index 0000000..7e827b7 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/AI/SpiderReturnMoveController.js @@ -0,0 +1,33 @@ +#pragma strict + +// Public member data +public var motor : MovementMotor; + +// Private memeber data +private var ai : AI; + +private var character : Transform; +private var spawnPos : Vector3; +public var animationBehaviour : MonoBehaviour; + +function Awake () { + character = motor.transform; + ai = transform.parent.GetComponentInChildren. (); + spawnPos = character.position; +} + +function Update () { + motor.movementDirection = spawnPos - character.position; + motor.movementDirection.y = 0; + if (motor.movementDirection.sqrMagnitude > 1) + motor.movementDirection = motor.movementDirection.normalized; + + if (motor.movementDirection.sqrMagnitude < 0.01) { + character.position = new Vector3 (spawnPos.x, character.position.y, spawnPos.z); + motor.GetComponent.().velocity = Vector3.zero; + motor.GetComponent.().angularVelocity = Vector3.zero; + motor.movementDirection = Vector3.zero; + enabled = false; + animationBehaviour.enabled = false; + } +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/FanRotate.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/FanRotate.js new file mode 100644 index 0000000..a8e86d2 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/FanRotate.js @@ -0,0 +1,25 @@ + +#pragma strict + +var thisMesh : Mesh; +var uvs : Vector2[]; + +#if !UNITY_IPHONE && !UNITY_ANDROID && !UNITY_WP8 && !UNITY_BLACKBERRY + +function Start () +{ + thisMesh = GetComponent(MeshFilter).mesh; + uvs = thisMesh.uv; +} + +function Update() +{ + for (var i : int = 0; i < uvs.length; i++) + { + uvs[i].y = (uvs[i].y + 0.25); + } + + thisMesh.uv = uvs; +} + +#endif \ No newline at end of file diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/FootstepHandler.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/FootstepHandler.js new file mode 100644 index 0000000..f21972c --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/FootstepHandler.js @@ -0,0 +1,38 @@ +#pragma strict + +enum FootType { + Player, + Mech, + Spider +} + +var audioSource : AudioSource; +var footType : FootType; + +private var physicMaterial : PhysicMaterial; + +function OnCollisionEnter (collisionInfo : Collision) { + physicMaterial = collisionInfo.collider.sharedMaterial; +} + +function OnFootstep () { + if (!audioSource.enabled) + { + return; + } + + var sound : AudioClip; + switch (footType) { + case FootType.Player: + //sound = MaterialImpactManager.GetPlayerFootstepSound (physicMaterial); + break; + case FootType.Mech: + //sound = MaterialImpactManager.GetMechFootstepSound (physicMaterial); + break; + case FootType.Spider: + //sound = MaterialImpactManager.GetSpiderFootstepSound (physicMaterial); + break; + } + audioSource.pitch = Random.Range (0.98, 1.02); + audioSource.PlayOneShot (sound, Random.Range (0.8, 1.2)); +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/MechAnimation.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/MechAnimation.js new file mode 100644 index 0000000..197b6aa --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/MechAnimation.js @@ -0,0 +1,60 @@ +#pragma strict + +var rigid : Rigidbody; +var idle : AnimationClip; +var walk : AnimationClip; +var turnLeft : AnimationClip; +var turnRight : AnimationClip; +var footstepSignals : SignalSender; + +private var tr : Transform; +private var lastFootstepTime : float = 0; +private var lastAnimTime : float = 0; + +function OnEnable () { + tr = rigid.transform; + + GetComponent.()[idle.name].layer = 0; + GetComponent.()[idle.name].weight = 1; + GetComponent.()[idle.name].enabled = true; + + GetComponent.()[walk.name].layer = 1; + GetComponent.()[turnLeft.name].layer = 1; + GetComponent.()[turnRight.name].layer = 1; + + GetComponent.()[walk.name].weight = 1; + GetComponent.()[turnLeft.name].weight = 0; + GetComponent.()[turnRight.name].weight = 0; + + GetComponent.()[walk.name].enabled = true; + GetComponent.()[turnLeft.name].enabled = true; + GetComponent.()[turnRight.name].enabled = true; + + //animation.SyncLayer (1); +} + +function FixedUpdate () { + var turningWeight : float = Mathf.Abs (rigid.angularVelocity.y) * Mathf.Rad2Deg / 100.0; + var forwardWeight : float = rigid.velocity.magnitude / 2.5; + var turningDir : float = Mathf.Sign (rigid.angularVelocity.y); + + // Temp, until we get the animations fixed + GetComponent.()[walk.name].speed = Mathf.Lerp (1.0, GetComponent.()[walk.name].length / GetComponent.()[turnLeft.name].length * 1.33, turningWeight); + GetComponent.()[turnLeft.name].time = GetComponent.()[walk.name].time; + GetComponent.()[turnRight.name].time = GetComponent.()[walk.name].time; + + GetComponent.()[turnLeft.name].weight = Mathf.Clamp01 (-turningWeight * turningDir); + GetComponent.()[turnRight.name].weight = Mathf.Clamp01 (turningWeight * turningDir); + GetComponent.()[walk.name].weight = Mathf.Clamp01 (forwardWeight); + + if (forwardWeight + turningWeight > 0.1) { + var newAnimTime = Mathf.Repeat (GetComponent.()[walk.name].normalizedTime * 2 + 0.1, 1); + if (newAnimTime < lastAnimTime) { + if (Time.time > lastFootstepTime + 0.1) { + footstepSignals.SendSignals (this); + lastFootstepTime = Time.time; + } + } + lastAnimTime = newAnimTime; + } +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/MechAnimationTest.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/MechAnimationTest.js new file mode 100644 index 0000000..d521bce --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/MechAnimationTest.js @@ -0,0 +1,78 @@ +#pragma strict + +#if !UNITY_FLASH + +var turning : float = 0; +var walking : float = 0; +var turnOffset : float = 0.0; + +var rigid : Rigidbody; +var idle : AnimationClip; +var walk : AnimationClip; +var turnLeft : AnimationClip; +var turnRight : AnimationClip; +var footstepSignals : SignalSender; + +function OnEnable () { + + GetComponent.()[idle.name].layer = 0; + GetComponent.()[idle.name].weight = 1; + GetComponent.()[idle.name].enabled = true; + + GetComponent.()[walk.name].layer = 1; + GetComponent.()[turnLeft.name].layer = 1; + GetComponent.()[turnRight.name].layer = 1; + + GetComponent.()[walk.name].weight = 1; + GetComponent.()[turnLeft.name].weight = 0; + GetComponent.()[turnRight.name].weight = 0; + + GetComponent.()[walk.name].enabled = true; + GetComponent.()[turnLeft.name].enabled = true; + GetComponent.()[turnRight.name].enabled = true; + + //animation[walk.name].speed = 0.93; + + //animation.Play (); +} + +function FixedUpdate () { + GetComponent.()[walk.name].speed = Mathf.Lerp (1, GetComponent.()[walk.name].length / GetComponent.()[turnLeft.name].length, Mathf.Abs (turning)); + + GetComponent.()[turnLeft.name].time = GetComponent.()[walk.name].time + turnOffset; + GetComponent.()[turnRight.name].time = GetComponent.()[walk.name].time + turnOffset; + + rigid.velocity = rigid.transform.forward * 2.5 * walking; + rigid.angularVelocity = Vector3.up * turning * 100 * Mathf.Deg2Rad; + + var turningWeight : float = rigid.angularVelocity.y * Mathf.Rad2Deg / 100.0; + var forwardWeight : float = rigid.velocity.magnitude / 2.5; + + GetComponent.()[turnLeft.name].weight = Mathf.Clamp01 (-turningWeight); + GetComponent.()[turnRight.name].weight = Mathf.Clamp01 (turningWeight); + GetComponent.()[walk.name].weight = Mathf.Clamp01 (forwardWeight); +} + +function OnGUI () { + GUILayout.Label ("Walking (0 to 1): "+walking.ToString("0.00")); + walking = GUILayout.HorizontalSlider (walking, 0, 1, GUILayout.Width (100)); + if (GUI.changed) { + turning = Mathf.Clamp (Mathf.Abs (turning), 0, 1 - walking) * Mathf.Sign (turning); + GUI.changed = false; + } + + GUILayout.Label ("Turning (-1 to 1): "+turning.ToString("0.00")); + turning = GUILayout.HorizontalSlider (turning, -1, 1, GUILayout.Width (100)); + if (Mathf.Abs (turning) < 0.1) + turning = 0; + if (GUI.changed) { + walking = Mathf.Clamp (walking, 0, 1 - Mathf.Abs (turning)); + GUI.changed = false; + } + + GUILayout.Label ("Offset to turning anims (-0.5 to 0.5): "+turnOffset.ToString("0.00")); + turnOffset = GUILayout.HorizontalSlider (turnOffset, -0.5, 0.5, GUILayout.Width (100)); + if (Mathf.Abs (turnOffset) < 0.05) + turnOffset = 0; +} +#endif \ No newline at end of file diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/PlayerAnimation.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/PlayerAnimation.js new file mode 100644 index 0000000..b242da7 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/PlayerAnimation.js @@ -0,0 +1,206 @@ +#pragma strict + +class MoveAnimation { + // The animation clip + var clip : AnimationClip; + + // The velocity of the walk or run cycle in this clip + var velocity : Vector3; + + // Store the current weight of this animation + @HideInInspector + public var weight : float; + + // Keep track of whether this animation is currently the best match + @HideInInspector + public var currentBest : boolean = false; + + // The speed and angle is directly derived from the velocity, + // but since it's slightly expensive to calculate them + // we do it once in the beginning instead of in every frame. + @HideInInspector + public var speed : float; + @HideInInspector + public var angle : float; + + public function Init () { + velocity.y = 0; + speed = velocity.magnitude; + angle = PlayerAnimation.HorizontalAngle (velocity); + } +} + +var rigid : Rigidbody; +var rootBone : Transform; +var upperBodyBone : Transform; +var maxIdleSpeed : float = 0.5; +var minWalkSpeed : float = 2.0; +var idle : AnimationClip; +var turn : AnimationClip; +var shootAdditive : AnimationClip; +var moveAnimations : MoveAnimation[]; +var footstepSignals : SignalSender; + +private var tr : Transform; +private var lastPosition : Vector3 = Vector3.zero; +private var velocity : Vector3 = Vector3.zero; +private var localVelocity : Vector3 = Vector3.zero; +private var speed : float = 0; +private var angle : float = 0; +private var lowerBodyDeltaAngle : float = 0; +private var idleWeight : float = 0; +private var lowerBodyForwardTarget : Vector3 = Vector3.forward; +private var lowerBodyForward : Vector3 = Vector3.forward; +private var bestAnimation : MoveAnimation = null; +private var lastFootstepTime : float = 0; +private var lastAnimTime : float = 0; + +public var animationComponent : Animation; + +function Awake () { + tr = rigid.transform; + lastPosition = tr.position; + + for (var moveAnimation : MoveAnimation in moveAnimations) { + moveAnimation.Init (); + animationComponent[moveAnimation.clip.name].layer = 1; + animationComponent[moveAnimation.clip.name].enabled = true; + } + animationComponent.SyncLayer (1); + + animationComponent[idle.name].layer = 2; + animationComponent[turn.name].layer = 3; + animationComponent[idle.name].enabled = true; + + animationComponent[shootAdditive.name].layer = 4; + animationComponent[shootAdditive.name].weight = 1; + animationComponent[shootAdditive.name].speed = 0.6; + animationComponent[shootAdditive.name].blendMode = AnimationBlendMode.Additive; + + //animation[turn.name].enabled = true; +} + +function OnStartFire () { + if (Time.timeScale == 0) + return; + + animationComponent[shootAdditive.name].enabled = true; +} + +function OnStopFire () { + animationComponent[shootAdditive.name].enabled = false; +} + +function FixedUpdate () { + velocity = (tr.position - lastPosition) / Time.deltaTime; + localVelocity = tr.InverseTransformDirection (velocity); + localVelocity.y = 0; + speed = localVelocity.magnitude; + angle = HorizontalAngle (localVelocity); + + lastPosition = tr.position; +} + +function Update () { + idleWeight = Mathf.Lerp (idleWeight, Mathf.InverseLerp (minWalkSpeed, maxIdleSpeed, speed), Time.deltaTime * 10); + animationComponent[idle.name].weight = idleWeight; + + if (speed > 0) { + var smallestDiff : float = Mathf.Infinity; + for (var moveAnimation : MoveAnimation in moveAnimations) { + var angleDiff : float = Mathf.Abs(Mathf.DeltaAngle (angle, moveAnimation.angle)); + var speedDiff : float = Mathf.Abs (speed - moveAnimation.speed); + var diff : float = angleDiff + speedDiff; + if (moveAnimation == bestAnimation) + diff *= 0.9; + + if (diff < smallestDiff) { + bestAnimation = moveAnimation; + smallestDiff = diff; + } + } + + animationComponent.CrossFade (bestAnimation.clip.name); + } + else { + bestAnimation = null; + } + + if (lowerBodyForward != lowerBodyForwardTarget && idleWeight >= 0.9) + animationComponent.CrossFade (turn.name, 0.05); + + if (bestAnimation && idleWeight < 0.9) { + var newAnimTime = Mathf.Repeat (animationComponent[bestAnimation.clip.name].normalizedTime * 2 + 0.1, 1); + if (newAnimTime < lastAnimTime) { + if (Time.time > lastFootstepTime + 0.1) { + footstepSignals.SendSignals (this); + lastFootstepTime = Time.time; + } + } + lastAnimTime = newAnimTime; + } +} + +function LateUpdate () { + var idle : float = Mathf.InverseLerp (minWalkSpeed, maxIdleSpeed, speed); + + if (idle < 1) { + // Calculate a weighted average of the animation velocities that are currently used + var animatedLocalVelocity : Vector3 = Vector3.zero; + for (var moveAnimation : MoveAnimation in moveAnimations) { + // Ignore this animation if its weight is 0 + if (animationComponent[moveAnimation.clip.name].weight == 0) + continue; + + // Ignore this animation if its velocity is more than 90 degrees away from current velocity + if (Vector3.Dot (moveAnimation.velocity, localVelocity) <= 0) + continue; + + // Add velocity of this animation to the weighted average + animatedLocalVelocity += moveAnimation.velocity * animationComponent[moveAnimation.clip.name].weight; + } + + // Calculate target angle to rotate lower body by in order + // to make feet run in the direction of the velocity + var lowerBodyDeltaAngleTarget : float = Mathf.DeltaAngle ( + HorizontalAngle (tr.rotation * animatedLocalVelocity), + HorizontalAngle (velocity) + ); + + // Lerp the angle to smooth it a bit + lowerBodyDeltaAngle = Mathf.LerpAngle (lowerBodyDeltaAngle, lowerBodyDeltaAngleTarget, Time.deltaTime * 10); + + // Update these so they're ready for when we go into idle + lowerBodyForwardTarget = tr.forward; + lowerBodyForward = Quaternion.Euler (0, lowerBodyDeltaAngle, 0) * lowerBodyForwardTarget; + } + else { + // Turn the lower body towards it's target direction + lowerBodyForward = Vector3.RotateTowards (lowerBodyForward, lowerBodyForwardTarget, Time.deltaTime * 520 * Mathf.Deg2Rad, 1); + + // Calculate delta angle to make the lower body stay in place + lowerBodyDeltaAngle = Mathf.DeltaAngle ( + HorizontalAngle (tr.forward), + HorizontalAngle (lowerBodyForward) + ); + + // If the body is twisted more than 80 degrees, + // set a new target direction for the lower body, so it begins turning + if (Mathf.Abs(lowerBodyDeltaAngle) > 80) + lowerBodyForwardTarget = tr.forward; + } + + // Create a Quaternion rotation from the rotation angle + var lowerBodyDeltaRotation : Quaternion = Quaternion.Euler (0, lowerBodyDeltaAngle, 0); + + // Rotate the whole body by the angle + rootBone.rotation = lowerBodyDeltaRotation * rootBone.rotation; + + // Counter-rotate the upper body so it won't be affected + upperBodyBone.rotation = Quaternion.Inverse (lowerBodyDeltaRotation) * upperBodyBone.rotation; + +} + +static function HorizontalAngle (direction : Vector3) { + return Mathf.Atan2 (direction.x, direction.z) * Mathf.Rad2Deg; +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/SpiderAnimation.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/SpiderAnimation.js new file mode 100644 index 0000000..9b6198f --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/SpiderAnimation.js @@ -0,0 +1,118 @@ +#pragma strict + +var motor : MovementMotor; +var activateAnim : AnimationClip; +var forwardAnim : AnimationClip; +var backAnim : AnimationClip; +var leftAnim : AnimationClip; +var rightAnim : AnimationClip; +var audioSource : AudioSource; +var footstepSignals : SignalSender; +var skiddingSounds : boolean; +var footstepSounds : boolean; + +private var tr : Transform; +private var lastFootstepTime : float = 0; +private var lastAnimTime : float = 0; + +function OnEnable () { + tr = motor.transform; + + GetComponent.()[activateAnim.name].enabled = true; + GetComponent.()[activateAnim.name].weight = 1; + GetComponent.()[activateAnim.name].time = 0; + GetComponent.()[activateAnim.name].speed = 1; + + GetComponent.()[forwardAnim.name].layer = 1; + GetComponent.()[forwardAnim.name].enabled = true; + GetComponent.()[forwardAnim.name].weight = 0; + GetComponent.()[backAnim.name].layer = 1; + GetComponent.()[backAnim.name].enabled = true; + GetComponent.()[backAnim.name].weight = 0; + GetComponent.()[leftAnim.name].layer = 1; + GetComponent.()[leftAnim.name].enabled = true; + GetComponent.()[leftAnim.name].weight = 0; + GetComponent.()[rightAnim.name].layer = 1; + GetComponent.()[rightAnim.name].enabled = true; + GetComponent.()[rightAnim.name].weight = 0; + +} + +function OnDisable () { + GetComponent.()[activateAnim.name].enabled = true; + GetComponent.()[activateAnim.name].weight = 1; + GetComponent.()[activateAnim.name].normalizedTime = 1; + GetComponent.()[activateAnim.name].speed = -1; + GetComponent.().CrossFade (activateAnim.name, 0.3, PlayMode.StopAll); +} + +function Update () { + var direction : Vector3 = motor.movementDirection; + direction.y = 0; + + var walkWeight : float = direction.magnitude; + + GetComponent.()[forwardAnim.name].speed = walkWeight; + GetComponent.()[rightAnim.name].speed = walkWeight; + GetComponent.()[backAnim.name].speed = walkWeight; + GetComponent.()[leftAnim.name].speed = walkWeight; + + var angle : float = Mathf.DeltaAngle ( + HorizontalAngle (tr.forward), + HorizontalAngle (direction) + ); + + if (walkWeight > 0.01) { + var w : float; + if (angle < -90) { + w = Mathf.InverseLerp (-180, -90, angle); + GetComponent.()[forwardAnim.name].weight = 0; + GetComponent.()[rightAnim.name].weight = 0; + GetComponent.()[backAnim.name].weight = 1 - w; + GetComponent.()[leftAnim.name].weight = 1; + } + else if (angle < 0) { + w = Mathf.InverseLerp (-90, 0, angle); + GetComponent.()[forwardAnim.name].weight = w; + GetComponent.()[rightAnim.name].weight = 0; + GetComponent.()[backAnim.name].weight = 0; + GetComponent.()[leftAnim.name].weight = 1 - w; + } + else if (angle < 90) { + w = Mathf.InverseLerp (0, 90, angle); + GetComponent.()[forwardAnim.name].weight = 1 - w; + GetComponent.()[rightAnim.name].weight = w; + GetComponent.()[backAnim.name].weight = 0; + GetComponent.()[leftAnim.name].weight = 0; + } + else { + w = Mathf.InverseLerp (90, 180, angle); + GetComponent.()[forwardAnim.name].weight = 0; + GetComponent.()[rightAnim.name].weight = 1 - w; + GetComponent.()[backAnim.name].weight = w; + GetComponent.()[leftAnim.name].weight = 0; + } + } + + if (skiddingSounds) { + if (walkWeight > 0.2 && !audioSource.isPlaying) + audioSource.Play (); + else if (walkWeight < 0.2 && audioSource.isPlaying) + audioSource.Pause (); + } + + if (footstepSounds && walkWeight > 0.2) { + var newAnimTime = Mathf.Repeat (GetComponent.()[forwardAnim.name].normalizedTime * 4 + 0.1, 1); + if (newAnimTime < lastAnimTime) { + if (Time.time > lastFootstepTime + 0.1) { + footstepSignals.SendSignals (this); + lastFootstepTime = Time.time; + } + } + lastAnimTime = newAnimTime; + } +} + +static function HorizontalAngle (direction : Vector3) { + return Mathf.Atan2 (direction.x, direction.z) * Mathf.Rad2Deg; +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/SpiderAnimationTest.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/SpiderAnimationTest.js new file mode 100644 index 0000000..33e309f --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/SpiderAnimationTest.js @@ -0,0 +1,98 @@ +#pragma strict + +#if !UNITY_FLASH + +var rigid : Rigidbody; +var forwardAnim : AnimationClip; +var backAnim : AnimationClip; +var leftAnim : AnimationClip; +var rightAnim : AnimationClip; + +var walking : float; +var angle : float; + +private var tr : Transform; + +function OnEnable () { + tr = rigid.transform; + + GetComponent.()[forwardAnim.name].layer = 1; + GetComponent.()[forwardAnim.name].enabled = true; + GetComponent.()[backAnim.name].layer = 1; + GetComponent.()[backAnim.name].enabled = true; + GetComponent.()[leftAnim.name].layer = 1; + GetComponent.()[leftAnim.name].enabled = true; + GetComponent.()[rightAnim.name].layer = 1; + GetComponent.()[rightAnim.name].enabled = true; + GetComponent.().SyncLayer (1); +} + +function Update () { + rigid.velocity = Quaternion.Euler(0, angle, 0) * rigid.transform.forward * 2.4 * walking; + + var velocity : Vector3 = rigid.velocity; + velocity.y = 0; + + var walkWeight : float = velocity.magnitude / 2.4; + + GetComponent.()[forwardAnim.name].speed = walkWeight; + GetComponent.()[rightAnim.name].speed = walkWeight; + GetComponent.()[backAnim.name].speed = walkWeight; + GetComponent.()[leftAnim.name].speed = walkWeight; + + if (velocity == Vector3.zero) { + return; + } + + var angle : float = Mathf.DeltaAngle ( + HorizontalAngle (tr.forward), + HorizontalAngle (rigid.velocity) + ); + + var w : float; + if (angle < -90) { + w = Mathf.InverseLerp (-180, -90, angle); + GetComponent.()[forwardAnim.name].weight = 0; + GetComponent.()[rightAnim.name].weight = 0; + GetComponent.()[backAnim.name].weight = 1 - w; + GetComponent.()[leftAnim.name].weight = 1; + } + else if (angle < 0) { + w = Mathf.InverseLerp (-90, 0, angle); + GetComponent.()[forwardAnim.name].weight = w; + GetComponent.()[rightAnim.name].weight = 0; + GetComponent.()[backAnim.name].weight = 0; + GetComponent.()[leftAnim.name].weight = 1 - w; + } + else if (angle < 90) { + w = Mathf.InverseLerp (0, 90, angle); + GetComponent.()[forwardAnim.name].weight = 1 - w; + GetComponent.()[rightAnim.name].weight = w; + GetComponent.()[backAnim.name].weight = 0; + GetComponent.()[leftAnim.name].weight = 0; + } + else { + w = Mathf.InverseLerp (90, 180, angle); + GetComponent.()[forwardAnim.name].weight = 0; + GetComponent.()[rightAnim.name].weight = 1 - w; + GetComponent.()[backAnim.name].weight = w; + GetComponent.()[leftAnim.name].weight = 0; + } +} + +static function HorizontalAngle (direction : Vector3) { + return Mathf.Atan2 (direction.x, direction.z) * Mathf.Rad2Deg; +} + +function OnGUI () { + GUILayout.Label ("Angle (0 to 360): "+angle.ToString("0.00")); + angle = GUILayout.HorizontalSlider (angle, 0, 360, GUILayout.Width (200)); + for (var i : int = 0; i<=360; i+=45) { + if (Mathf.Abs (angle - i) < 10) + angle = i; + } + + GUILayout.Label ("Walking (0 to 1): "+walking.ToString("0.00")); + walking = GUILayout.HorizontalSlider (walking, 0, 1, GUILayout.Width (100)); +} +#endif \ No newline at end of file diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/conveyorBelt.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/conveyorBelt.js new file mode 100644 index 0000000..6d3da02 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Animation/conveyorBelt.js @@ -0,0 +1,24 @@ + +#pragma strict + +var scrollSpeed : float = 0.1; +var mat : Material; + +function Start () { + enabled = false; +} + +function OnBecameVisible () { + enabled = true; +} + +function OnBecameInvisible () { + enabled = false; +} + +function Update () { + var offset : float = (Time.time * scrollSpeed) % 1.0; + + mat.SetTextureOffset ("_MainTex", Vector2(0, -offset)); + mat.SetTextureOffset ("_BumpMap", Vector2(0, -offset)); +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Fx/GlowPlane.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Fx/GlowPlane.js new file mode 100644 index 0000000..cec44c2 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Fx/GlowPlane.js @@ -0,0 +1,54 @@ + +#pragma strict + +var playerTransform : Transform; +private var pos : Vector3; +private var scale : Vector3; +var minGlow : float = 0.2f; +var maxGlow : float = 0.5f; +var glowColor : Color = Color.white; + +private var mat : Material; + +function Start () { + if (!playerTransform) + playerTransform = GameObject.FindWithTag ("Player").transform; + pos = transform.position; + scale = transform.localScale; + mat = GetComponent.().material; + enabled = false; +} + +function OnDrawGizmos () { + Gizmos.color = glowColor; + Gizmos.color.a = maxGlow * 0.25f; + Gizmos.matrix = transform.localToWorldMatrix; + var scale : Vector3 = 5.0f * Vector3.Scale (Vector3.one, Vector3(1,0,1)); + Gizmos.DrawCube (Vector3.zero, scale); + Gizmos.matrix = Matrix4x4.identity; +} + +function OnDrawGizmosSelected () { + Gizmos.color = glowColor; + Gizmos.color.a = maxGlow; + Gizmos.matrix = transform.localToWorldMatrix; + var scale : Vector3 = 5.0f * Vector3.Scale (Vector3.one, Vector3(1,0,1)); + Gizmos.DrawCube (Vector3.zero, scale); + Gizmos.matrix = Matrix4x4.identity; +} + +function OnBecameVisible () { + enabled = true; +} + +function OnBecameInvisible () { + enabled = false; +} + +function Update () { + var vec : Vector3 = (pos - playerTransform.position); + vec.y = 0.0f; + var distance = vec.magnitude; + transform.localScale = Vector3.Lerp (Vector3.one * minGlow, scale, Mathf.Clamp01 (distance * 0.35f)); + mat.SetColor ("_TintColor", glowColor * Mathf.Clamp (distance * 0.1f, minGlow, maxGlow)); +} \ No newline at end of file diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Fx/GlowPlaneAngleFade.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Fx/GlowPlaneAngleFade.js new file mode 100644 index 0000000..c1e4000 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Fx/GlowPlaneAngleFade.js @@ -0,0 +1,19 @@ + +#pragma strict + +var cameraTransform : Transform; +var glowColor : Color = Color.grey; +private var dot : float = 0.5f; + +function Start () { + if (!cameraTransform) + cameraTransform = Camera.main.transform; +} + +function Update () { + dot = 1.5f * Mathf.Clamp01 (Vector3.Dot (cameraTransform.forward, -transform.up) - 0.25f); +} + +function OnWillRenderObject () { + GetComponent.().sharedMaterial.SetColor ("_TintColor", glowColor * dot); +} \ No newline at end of file diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Fx/LaserScope.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Fx/LaserScope.js new file mode 100644 index 0000000..9dd3206 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Fx/LaserScope.js @@ -0,0 +1,71 @@ +#pragma strict + +@script RequireComponent (PerFrameRaycast) + +public var scrollSpeed : float = 0.5; +public var pulseSpeed : float = 1.5; + +public var noiseSize : float = 1.0; + +public var maxWidth : float = 0.5; +public var minWidth : float = 0.2; + +public var pointer : GameObject = null; + +private var lRenderer : LineRenderer; +private var aniTime : float = 0.0; +private var aniDir : float = 1.0; + +private var raycast : PerFrameRaycast; + +function Start() { + lRenderer = gameObject.GetComponent (LineRenderer) as LineRenderer; + aniTime = 0.0; + + // Change some animation values here and there + ChoseNewAnimationTargetCoroutine(); + + raycast = GetComponent. (); +} + +function ChoseNewAnimationTargetCoroutine () { + while (true) { + aniDir = aniDir * 0.9 + Random.Range (0.5, 1.5) * 0.1; + yield; + minWidth = minWidth * 0.8 + Random.Range (0.1, 1.0) * 0.2; + yield WaitForSeconds (1.0 + Random.value * 2.0 - 1.0); + } +} + +function Update () { + GetComponent.().material.mainTextureOffset.x += Time.deltaTime * aniDir * scrollSpeed; + GetComponent.().material.SetTextureOffset ("_NoiseTex", Vector2 (-Time.time * aniDir * scrollSpeed, 0.0)); + + var aniFactor : float = Mathf.PingPong (Time.time * pulseSpeed, 1.0); + aniFactor = Mathf.Max (minWidth, aniFactor) * maxWidth; + lRenderer.SetWidth (aniFactor, aniFactor); + + // Cast a ray to find out the end point of the laser + var hitInfo : RaycastHit = raycast.GetHitInfo (); + if (hitInfo.transform) { + lRenderer.SetPosition (1, (hitInfo.distance * Vector3.forward)); + GetComponent.().material.mainTextureScale.x = 0.1 * (hitInfo.distance); + GetComponent.().material.SetTextureScale ("_NoiseTex", Vector2 (0.1 * hitInfo.distance * noiseSize, noiseSize)); + + // Use point and normal to align a nice & rough hit plane + if (pointer) { + pointer.GetComponent.().enabled = true; + pointer.transform.position = hitInfo.point + (transform.position - hitInfo.point) * 0.01; + pointer.transform.rotation = Quaternion.LookRotation (hitInfo.normal, transform.up); + pointer.transform.eulerAngles.x = 90.0; + } + } + else { + if (pointer) + pointer.GetComponent.().enabled = false; + var maxDist : float = 200.0; + lRenderer.SetPosition (1, (maxDist * Vector3.forward)); + GetComponent.().material.mainTextureScale.x = 0.1 * (maxDist); + GetComponent.().material.SetTextureScale ("_NoiseTex", Vector2 (0.1 * (maxDist) * noiseSize, noiseSize)); + } +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Fx/SelfIlluminationBlink.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Fx/SelfIlluminationBlink.js new file mode 100644 index 0000000..8ef2889 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Fx/SelfIlluminationBlink.js @@ -0,0 +1,12 @@ + +#pragma strict + +public var blink : float = 0.0f; + +function OnWillRenderObject () { + GetComponent.().sharedMaterial.SetFloat ("_SelfIllumStrength", blink); +} + +function Blink () { + blink = 1.0f - blink; +} \ No newline at end of file diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/GameScore.cs b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/GameScore.cs new file mode 100644 index 0000000..5020ff4 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/GameScore.cs @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +public class GameScore : MonoBehaviour +{ + static GameScore s_Instance; + + + static GameScore Instance + { + get + { + if (s_Instance == null) + { + s_Instance = (GameScore)FindObjectOfType(typeof(GameScore)); + } + + return s_Instance; + } + } + + + public void OnApplicationQuit() + { + s_Instance = null; + } + + + public string playerLayerName = "Player", enemyLayerName = "Enemies"; + + + int m_Deaths; + readonly Dictionary m_Kills = new Dictionary(); + float m_StartTime; + + + public static int Deaths + { + get + { + if (Instance == null) + { + return 0; + } + + return Instance.m_Deaths; + } + } + + + #if !UNITY_FLASH + public static ICollection KillTypes + { + get + { + if (Instance == null) + { + return new string[0]; + } + + return Instance.m_Kills.Keys; + } + } + #endif // if !UNITY_FLASH + + + public static int GetKills(string type) + { + if (Instance == null || !Instance.m_Kills.ContainsKey(type)) + { + return 0; + } + + return Instance.m_Kills[type]; + } + + + public static float GameTime + { + get + { + if (Instance == null) + { + return 0.0f; + } + + return Time.time - Instance.m_StartTime; + } + } + + + public static void RegisterDeath(GameObject deadObject) + { + if (Instance == null) + { + Debug.Log("Game score not loaded"); + return; + } + + int + playerLayer = LayerMask.NameToLayer(Instance.playerLayerName), + enemyLayer = LayerMask.NameToLayer(Instance.enemyLayerName); + + if (deadObject.layer == playerLayer) + { + Instance.m_Deaths++; + } + else if (deadObject.layer == enemyLayer) + { + Instance.m_Kills[deadObject.name] = Instance.m_Kills.ContainsKey(deadObject.name) ? Instance.m_Kills[deadObject.name] + 1 : 1; + } + } + + + public void OnLevelWasLoaded(int level) + { + if (m_StartTime == 0.0f) + { + m_StartTime = Time.time; + } + } +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Managers/Spawner.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Managers/Spawner.js new file mode 100644 index 0000000..b4f8d49 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Managers/Spawner.js @@ -0,0 +1,125 @@ +#pragma strict + +static var spawner : Spawner; + +var caches : ObjectCache[]; + +var activeCachedObjects : Hashtable; + + +class ObjectCache { + var prefab : GameObject; + var cacheSize : int = 10; + + private var objects : GameObject[]; + private var cacheIndex : int = 0; + + function Initialize () + { + objects = new GameObject[cacheSize]; + + // Instantiate the objects in the array and set them to be inactive + for (var i = 0; i < cacheSize; i++) + { + objects[i] = MonoBehaviour.Instantiate (prefab) as GameObject; + objects[i].SetActive (false); + objects[i].name = objects[i].name + i; + } + } + + function GetNextObjectInCache () : GameObject { + var obj : GameObject = null; + + // The cacheIndex starts out at the position of the object created + // the longest time ago, so that one is usually free, + // but in case not, loop through the cache until we find a free one. + for (var i : int = 0; i < cacheSize; i++) { + obj = objects[cacheIndex]; + + // If we found an inactive object in the cache, use that. + if (!obj.activeSelf) + break; + + // If not, increment index and make it loop around + // if it exceeds the size of the cache + cacheIndex = (cacheIndex + 1) % cacheSize; + } + + // The object should be inactive. If it's not, log a warning and use + // the object created the longest ago even though it's still active. + if (obj.activeSelf) { + Debug.LogWarning ( + "Spawn of " + prefab.name + + " exceeds cache size of " + cacheSize + + "! Reusing already active object.", obj); + Spawner.Destroy (obj); + } + + // Increment index and make it loop around + // if it exceeds the size of the cache + cacheIndex = (cacheIndex + 1) % cacheSize; + + return obj; + } +} + +function Awake () { + // Set the global variable + spawner = this; + + // Total number of cached objects + var amount : int = 0; + + // Loop through the caches + for (var i = 0; i < caches.length; i++) { + // Initialize each cache + caches[i].Initialize (); + + // Count + amount += caches[i].cacheSize; + } + + // Create a hashtable with the capacity set to the amount of cached objects specified + activeCachedObjects = new Hashtable (amount); +} + +static function Spawn (prefab : GameObject, position : Vector3, rotation : Quaternion) : GameObject { + var cache : ObjectCache = null; + + // Find the cache for the specified prefab + if (spawner) { + for (var i = 0; i < spawner.caches.length; i++) { + if (spawner.caches[i].prefab == prefab) { + cache = spawner.caches[i]; + } + } + } + + // If there's no cache for this prefab type, just instantiate normally + if (cache == null) { + return Instantiate (prefab, position, rotation) as GameObject; + } + + // Find the next object in the cache + var obj : GameObject = cache.GetNextObjectInCache (); + + // Set the position and rotation of the object + obj.transform.position = position; + obj.transform.rotation = rotation; + + // Set the object to be active + obj.SetActive (true); + spawner.activeCachedObjects[obj] = true; + + return obj; +} + +static function Destroy (objectToDestroy : GameObject) { + if (spawner && spawner.activeCachedObjects.ContainsKey (objectToDestroy)) { + objectToDestroy.SetActive (false); + spawner.activeCachedObjects[objectToDestroy] = false; + } + else { + objectToDestroy.Destroy (objectToDestroy); + } +} \ No newline at end of file diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Modules/DestroyObject.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Modules/DestroyObject.js new file mode 100644 index 0000000..92bfaf4 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Modules/DestroyObject.js @@ -0,0 +1,7 @@ +#pragma strict + +var objectToDestroy : GameObject; + +function OnSignal () { + Spawner.Destroy (objectToDestroy); +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Modules/PlaySound.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Modules/PlaySound.js new file mode 100644 index 0000000..4bc5855 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Modules/PlaySound.js @@ -0,0 +1,15 @@ +#pragma strict + +var audioSource : AudioSource; +var sound : AudioClip; + +function Awake () { + if (!audioSource && GetComponent.()) + audioSource = GetComponent.(); +} + +function OnSignal () { + if (sound) + audioSource.clip = sound; + audioSource.Play (); +} \ No newline at end of file diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Modules/SignalSender.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Modules/SignalSender.js new file mode 100644 index 0000000..831c0d0 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Modules/SignalSender.js @@ -0,0 +1,32 @@ + +#pragma strict + +class ReceiverItem { + public var receiver : GameObject; + public var action : String = "OnSignal"; + public var delay : float; + + public function SendWithDelay (sender : MonoBehaviour) { + yield WaitForSeconds (delay); + if (receiver) + receiver.SendMessage (action); + else + Debug.LogWarning ("No receiver of signal \""+action+"\" on object "+sender.name+" ("+sender.GetType().Name+")", sender); + } +} + +class SignalSender { + public var onlyOnce : boolean; + public var receivers : ReceiverItem[]; + + private var hasFired : boolean = false; + + public function SendSignals (sender : MonoBehaviour) { + if (hasFired == false || onlyOnce == false) { + for (var i = 0; i < receivers.length; i++) { + sender.StartCoroutine (receivers[i].SendWithDelay(sender)); + } + hasFired = true; + } + } +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Modules/SpawnAtCheckpoint.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Modules/SpawnAtCheckpoint.js new file mode 100644 index 0000000..2f46503 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Modules/SpawnAtCheckpoint.js @@ -0,0 +1,19 @@ +#pragma strict +#pragma downcast + +var checkpoint : Transform; + +function OnSignal () { + transform.position = checkpoint.position; + transform.rotation = checkpoint.rotation; + + ResetHealthOnAll (); +} + +static function ResetHealthOnAll () { + var healthObjects : Health[] = FindObjectsOfType (Health); + for (var health : Health in healthObjects) { + health.dead = false; + health.health = health.maxHealth; + } +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Modules/SpawnObject.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Modules/SpawnObject.js new file mode 100644 index 0000000..a1a8be7 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Modules/SpawnObject.js @@ -0,0 +1,27 @@ +#pragma strict + +var objectToSpawn : GameObject; +var onDestroyedSignals : SignalSender; + +private var spawned : GameObject; + +// Keep disabled from the beginning +enabled = false; + +// When we get a signal, spawn the objectToSpawn and store the spawned object. +// Also enable this behaviour so the Update function will be run. +function OnSignal () { + spawned = Spawner.Spawn (objectToSpawn, transform.position, transform.rotation); + if (onDestroyedSignals.receivers.Length > 0) + enabled = true; +} + +// After the object is spawned, check each frame if it's still there. +// Once it's not, activate the onDestroyedSignals and disable again. +function Update () { + if (spawned == null || spawned.activeInHierarchy == false) + { + onDestroyedSignals.SendSignals (this); + enabled = false; + } +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Modules/TriggerOnMouseOrJoystick.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Modules/TriggerOnMouseOrJoystick.js new file mode 100644 index 0000000..78fff42 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Modules/TriggerOnMouseOrJoystick.js @@ -0,0 +1,50 @@ +#pragma strict + +public var mouseDownSignals : SignalSender; +public var mouseUpSignals : SignalSender; + +private var state : boolean = false; + +#if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_BLACKBERRY +private var joysticks : Joystick[]; + +function Start () { + joysticks = FindObjectsOfType (Joystick) as Joystick[]; +} +#endif + +function Update () { +#if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_BLACKBERRY + if (state == false && joysticks[0].tapCount > 0) { + mouseDownSignals.SendSignals (this); + state = true; + } + else if (joysticks[0].tapCount <= 0) { + mouseUpSignals.SendSignals (this); + state = false; + } +#else + #if !UNITY_EDITOR && (UNITY_XBOX360 || UNITY_PS3) + // On consoles use the right trigger to fire + var fireAxis : float = Input.GetAxis("TriggerFire"); + if (state == false && fireAxis >= 0.2) { + mouseDownSignals.SendSignals (this); + state = true; + } + else if (state == true && fireAxis < 0.2) { + mouseUpSignals.SendSignals (this); + state = false; + } + #else + if (state == false && Input.GetMouseButtonDown (0)) { + mouseDownSignals.SendSignals (this); + state = true; + } + + else if (state == true && Input.GetMouseButtonUp (0)) { + mouseUpSignals.SendSignals (this); + state = false; + } + #endif +#endif +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Movement/FreeMovementMotor.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Movement/FreeMovementMotor.js new file mode 100644 index 0000000..457a7d4 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Movement/FreeMovementMotor.js @@ -0,0 +1,48 @@ +#pragma strict + +@script RequireComponent (Rigidbody) + +class FreeMovementMotor extends MovementMotor { + + //public var movement : MoveController; + public var walkingSpeed : float = 5.0; + public var walkingSnappyness : float = 50; + public var turningSmoothing : float = 0.3; + + function FixedUpdate () { + // Handle the movement of the character + var targetVelocity : Vector3 = movementDirection * walkingSpeed; + var deltaVelocity : Vector3 = targetVelocity - GetComponent.().velocity; + if (GetComponent.().useGravity) + deltaVelocity.y = 0; + GetComponent.().AddForce (deltaVelocity * walkingSnappyness, ForceMode.Acceleration); + + // Setup player to face facingDirection, or if that is zero, then the movementDirection + var faceDir : Vector3 = facingDirection; + if (faceDir == Vector3.zero) + faceDir = movementDirection; + + // Make the character rotate towards the target rotation + if (faceDir == Vector3.zero) { + GetComponent.().angularVelocity = Vector3.zero; + } + else { + var rotationAngle : float = AngleAroundAxis (transform.forward, faceDir, Vector3.up); + GetComponent.().angularVelocity = (Vector3.up * rotationAngle * turningSmoothing); + } + } + + // The angle between dirA and dirB around axis + static function AngleAroundAxis (dirA : Vector3, dirB : Vector3, axis : Vector3) { + // Project A and B onto the plane orthogonal target axis + dirA = dirA - Vector3.Project (dirA, axis); + dirB = dirB - Vector3.Project (dirB, axis); + + // Find (positive) angle between A and B + var angle : float = Vector3.Angle (dirA, dirB); + + // Return angle multiplied with 1 or -1 + return angle * (Vector3.Dot (axis, Vector3.Cross (dirA, dirB)) < 0 ? -1 : 1); + } + +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Movement/Joystick.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Movement/Joystick.js new file mode 100644 index 0000000..7cb165a --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Movement/Joystick.js @@ -0,0 +1,220 @@ +#pragma strict + +@script RequireComponent (GUITexture) + +class Boundary { + var min : Vector2 = Vector2.zero; + var max : Vector2 = Vector2.zero; +} + +static private var joysticks : Joystick[]; // A static collection of all joysticks +static private var enumeratedJoysticks : boolean = false; +static private var tapTimeDelta : float = 0.3; // Time allowed between taps + +var touchPad : boolean; // Is this a TouchPad? +var touchZone : Rect; +var deadZone : float = 0; // Control when position is output +var normalize : boolean = false; // Normalize output after the dead-zone? +var position : Vector2; // [-1, 1] in x,y +var tapCount : int; // Current tap count + +private var lastFingerId = -1; // Finger last used for this joystick +private var tapTimeWindow : float; // How much time there is left for a tap to occur +private var fingerDownPos : Vector2; +private var fingerDownTime : float; +private var firstDeltaTime : float = 0.5; + +private var gui : GUITexture; // Joystick graphic +private var defaultRect : Rect; // Default position / extents of the joystick graphic +private var guiBoundary : Boundary = Boundary (); // Boundary for joystick graphic +private var guiTouchOffset : Vector2; // Offset to apply to touch input +private var guiCenter : Vector2; // Center of joystick + +#if !UNITY_IPHONE && !UNITY_ANDROID && !UNITY_WP8 && !UNITY_BLACKBERRY + +function Awake () { + gameObject.SetActive (false); +} + +#else + +function Start () { + // Cache this component at startup instead of looking up every frame + gui = GetComponent. (); + + // Store the default rect for the gui, so we can snap back to it + defaultRect = gui.pixelInset; + + defaultRect.x += transform.position.x * Screen.width;// + gui.pixelInset.x; // - Screen.width * 0.5; + defaultRect.y += transform.position.y * Screen.height;// - Screen.height * 0.5; + + transform.position.x = 0.0; + transform.position.y = 0.0; + + if (touchPad) { + // If a texture has been assigned, then use the rect ferom the gui as our touchZone + if (gui.texture) + touchZone = defaultRect; + } + else { + // This is an offset for touch input to match with the top left + // corner of the GUI + guiTouchOffset.x = defaultRect.width * 0.5; + guiTouchOffset.y = defaultRect.height * 0.5; + + // Cache the center of the GUI, since it doesn't change + guiCenter.x = defaultRect.x + guiTouchOffset.x; + guiCenter.y = defaultRect.y + guiTouchOffset.y; + + // Let's build the GUI boundary, so we can clamp joystick movement + guiBoundary.min.x = defaultRect.x - guiTouchOffset.x; + guiBoundary.max.x = defaultRect.x + guiTouchOffset.x; + guiBoundary.min.y = defaultRect.y - guiTouchOffset.y; + guiBoundary.max.y = defaultRect.y + guiTouchOffset.y; + } +} + +function Disable () { + gameObject.SetActive (false); + enumeratedJoysticks = false; +} + +function ResetJoystick () { + // Release the finger control and set the joystick back to the default position + gui.pixelInset = defaultRect; + lastFingerId = -1; + position = Vector2.zero; + fingerDownPos = Vector2.zero; + + if (touchPad) + gui.color.a = 0.025; +} + +function IsFingerDown () : boolean { + return (lastFingerId != -1); +} + +function LatchedFinger (fingerId : int) { + // If another joystick has latched this finger, then we must release it + if (lastFingerId == fingerId) + ResetJoystick (); +} + +function Update () { + if (!enumeratedJoysticks) { + // Collect all joysticks in the game, so we can relay finger latching messages + joysticks = FindObjectsOfType (Joystick) as Joystick[]; + enumeratedJoysticks = true; + } + + var count = Input.touchCount; + + // Adjust the tap time window while it still available + if (tapTimeWindow > 0) + tapTimeWindow -= Time.deltaTime; + else + tapCount = 0; + + if (count == 0) { + ResetJoystick (); + } + else { + for (var i : int = 0; i < count; i++) { + var touch : Touch = Input.GetTouch (i); + var guiTouchPos : Vector2 = touch.position - guiTouchOffset; + + var shouldLatchFinger = false; + if (touchPad) { + if (touchZone.Contains (touch.position)) + shouldLatchFinger = true; + } + else if (gui.HitTest (touch.position)) { + shouldLatchFinger = true; + } + + // Latch the finger if this is a new touch + if (shouldLatchFinger && (lastFingerId == -1 || lastFingerId != touch.fingerId)) { + + if (touchPad) { + gui.color.a = 0.15; + + lastFingerId = touch.fingerId; + fingerDownPos = touch.position; + fingerDownTime = Time.time; + } + + lastFingerId = touch.fingerId; + + // Accumulate taps if it is within the time window + if (tapTimeWindow > 0) { + tapCount++; + } + else { + tapCount = 1; + tapTimeWindow = tapTimeDelta; + } + + // Tell other joysticks we've latched this finger + for (var j : Joystick in joysticks) { + if (j != null && j != this) + j.LatchedFinger (touch.fingerId); + } + } + + if (lastFingerId == touch.fingerId) { + // Override the tap count with what the iPhone SDK reports if it is greater + // This is a workaround, since the iPhone SDK does not currently track taps + // for multiple touches + if (touch.tapCount > tapCount) + tapCount = touch.tapCount; + + if (touchPad) { + // For a touchpad, let's just set the position directly based on distance from initial touchdown + position.x = Mathf.Clamp ((touch.position.x - fingerDownPos.x) / (touchZone.width / 2), -1, 1); + position.y = Mathf.Clamp ((touch.position.y - fingerDownPos.y) / (touchZone.height / 2), -1, 1); + } + else { + // Change the location of the joystick graphic to match where the touch is + position.x = (touch.position.x - guiCenter.x) / guiTouchOffset.x; + position.y = (touch.position.y - guiCenter.y) / guiTouchOffset.y; + } + + if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled) + ResetJoystick (); + } + } + } + + // Calculate the length. This involves a squareroot operation, + // so it's slightly expensive. We re-use this length for multiple + // things below to avoid doing the square-root more than one. + var length : float = position.magnitude; + + + if (length < deadZone) { + // If the length of the vector is smaller than the deadZone radius, + // set the position to the origin. + position = Vector2.zero; + } + else { + if (length > 1) { + // Normalize the vector if its length was greater than 1. + // Use the already calculated length instead of using Normalize(). + position = position / length; + } + else if (normalize) { + // Normalize the vector and multiply it with the length adjusted + // to compensate for the deadZone radius. + // This prevents the position from snapping from zero to the deadZone radius. + position = position / length * Mathf.InverseLerp (length, deadZone, 1); + } + } + + if (!touchPad) { + // Change the location of the joystick graphic to match the position + gui.pixelInset.x = (position.x - 1) * guiTouchOffset.x + guiCenter.x; + gui.pixelInset.y = (position.y - 1) * guiTouchOffset.y + guiCenter.y; + } +} + +#endif diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Movement/MovementMotor.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Movement/MovementMotor.js new file mode 100644 index 0000000..3c5e58f --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Movement/MovementMotor.js @@ -0,0 +1,20 @@ +#pragma strict + +/* +This class can be used like an interface. +Inherit from it to define your own movement motor that can control +the movement of characters, enemies, or other entities. +*/ + +// The direction the character wants to move in, in world space. +// The vector should have a length between 0 and 1. +@HideInInspector +public var movementDirection : Vector3; + +// Simpler motors might want to drive movement based on a target purely +@HideInInspector +public var movementTarget : Vector3; + +// The direction the character wants to face towards, in world space. +@HideInInspector +public var facingDirection : Vector3; diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Movement/PlayerMoveController.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Movement/PlayerMoveController.js new file mode 100644 index 0000000..fbfafda --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Movement/PlayerMoveController.js @@ -0,0 +1,272 @@ +#pragma strict + +// Objects to drag in +public var motor : MovementMotor; +public var character : Transform; +public var cursorPrefab : GameObject; +public var joystickPrefab : GameObject; + +// Settings +public var cameraSmoothing : float = 0.01; +public var cameraPreview : float = 2.0f; + +// Cursor settings +public var cursorPlaneHeight : float = 0; +public var cursorFacingCamera : float = 0; +public var cursorSmallerWithDistance : float = 0; +public var cursorSmallerWhenClose : float = 1; + +// Private memeber data +private var mainCamera : Camera; + +private var cursorObject : Transform; +private var joystickLeft : Joystick; +private var joystickRight : Joystick; + +private var mainCameraTransform : Transform; +private var cameraVelocity : Vector3 = Vector3.zero; +private var cameraOffset : Vector3 = Vector3.zero; +private var initOffsetToPlayer : Vector3; + +// Prepare a cursor point varibale. This is the mouse position on PC and controlled by the thumbstick on mobiles. +private var cursorScreenPosition : Vector3; + +private var playerMovementPlane : Plane; + +private var joystickRightGO : GameObject; + +private var screenMovementSpace : Quaternion; +private var screenMovementForward : Vector3; +private var screenMovementRight : Vector3; + +function Awake () { + motor.movementDirection = Vector2.zero; + motor.facingDirection = Vector2.zero; + + // Set main camera + mainCamera = Camera.main; + mainCameraTransform = mainCamera.transform; + + // Ensure we have character set + // Default to using the transform this component is on + if (!character) + character = transform; + + initOffsetToPlayer = mainCameraTransform.position - character.position; + + #if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_BLACKBERRY + if (joystickPrefab) { + // Create left joystick + var joystickLeftGO : GameObject = Instantiate (joystickPrefab) as GameObject; + joystickLeftGO.name = "Joystick Left"; + joystickLeft = joystickLeftGO.GetComponent. (); + + // Create right joystick + joystickRightGO = Instantiate (joystickPrefab) as GameObject; + joystickRightGO.name = "Joystick Right"; + joystickRight = joystickRightGO.GetComponent. (); + } + #elif !UNITY_FLASH + if (cursorPrefab) { + cursorObject = (Instantiate (cursorPrefab) as GameObject).transform; + } + #endif + + // Save camera offset so we can use it in the first frame + cameraOffset = mainCameraTransform.position - character.position; + + // Set the initial cursor position to the center of the screen + cursorScreenPosition = Vector3 (0.5 * Screen.width, 0.5 * Screen.height, 0); + + // caching movement plane + playerMovementPlane = new Plane (character.up, character.position + character.up * cursorPlaneHeight); +} + +function Start () { + #if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_BLACKBERRY + // Move to right side of screen + var guiTex : GUITexture = joystickRightGO.GetComponent. (); + guiTex.pixelInset.x = Screen.width - guiTex.pixelInset.x - guiTex.pixelInset.width; + #endif + + // it's fine to calculate this on Start () as the camera is static in rotation + + screenMovementSpace = Quaternion.Euler (0, mainCameraTransform.eulerAngles.y, 0); + screenMovementForward = screenMovementSpace * Vector3.forward; + screenMovementRight = screenMovementSpace * Vector3.right; +} + +function OnDisable () { + if (joystickLeft) + joystickLeft.enabled = false; + + if (joystickRight) + joystickRight.enabled = false; +} + +function OnEnable () { + if (joystickLeft) + joystickLeft.enabled = true; + + if (joystickRight) + joystickRight.enabled = true; +} + +function Update () { + // HANDLE CHARACTER MOVEMENT DIRECTION + #if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_BLACKBERRY + motor.movementDirection = joystickLeft.position.x * screenMovementRight + joystickLeft.position.y * screenMovementForward; + #else + motor.movementDirection = Input.GetAxis ("Horizontal") * screenMovementRight + Input.GetAxis ("Vertical") * screenMovementForward; + #endif + + // Make sure the direction vector doesn't exceed a length of 1 + // so the character can't move faster diagonally than horizontally or vertically + if (motor.movementDirection.sqrMagnitude > 1) + motor.movementDirection.Normalize(); + + + // HANDLE CHARACTER FACING DIRECTION AND SCREEN FOCUS POINT + + // First update the camera position to take into account how much the character moved since last frame + //mainCameraTransform.position = Vector3.Lerp (mainCameraTransform.position, character.position + cameraOffset, Time.deltaTime * 45.0f * deathSmoothoutMultiplier); + + // Set up the movement plane of the character, so screenpositions + // can be converted into world positions on this plane + //playerMovementPlane = new Plane (Vector3.up, character.position + character.up * cursorPlaneHeight); + + // optimization (instead of newing Plane): + + playerMovementPlane.normal = character.up; + playerMovementPlane.distance = -character.position.y + cursorPlaneHeight; + + // used to adjust the camera based on cursor or joystick position + + var cameraAdjustmentVector : Vector3 = Vector3.zero; + + #if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_BLACKBERRY + + // On mobiles, use the thumb stick and convert it into screen movement space + motor.facingDirection = joystickRight.position.x * screenMovementRight + joystickRight.position.y * screenMovementForward; + + cameraAdjustmentVector = motor.facingDirection; + + #else + + #if !UNITY_EDITOR && (UNITY_XBOX360 || UNITY_PS3) + + // On consoles use the analog sticks + var axisX : float = Input.GetAxis("LookHorizontal"); + var axisY : float = Input.GetAxis("LookVertical"); + motor.facingDirection = axisX * screenMovementRight + axisY * screenMovementForward; + + cameraAdjustmentVector = motor.facingDirection; + + #else + + // On PC, the cursor point is the mouse position + var cursorScreenPosition : Vector3 = Input.mousePosition; + + // Find out where the mouse ray intersects with the movement plane of the player + var cursorWorldPosition : Vector3 = ScreenPointToWorldPointOnPlane (cursorScreenPosition, playerMovementPlane, mainCamera); + + var halfWidth : float = Screen.width / 2.0f; + var halfHeight : float = Screen.height / 2.0f; + var maxHalf : float = Mathf.Max (halfWidth, halfHeight); + + // Acquire the relative screen position + var posRel : Vector3 = cursorScreenPosition - Vector3 (halfWidth, halfHeight, cursorScreenPosition.z); + posRel.x /= maxHalf; + posRel.y /= maxHalf; + + cameraAdjustmentVector = posRel.x * screenMovementRight + posRel.y * screenMovementForward; + cameraAdjustmentVector.y = 0.0; + + // The facing direction is the direction from the character to the cursor world position + motor.facingDirection = (cursorWorldPosition - character.position); + motor.facingDirection.y = 0; + + // Draw the cursor nicely + HandleCursorAlignment (cursorWorldPosition); + + #endif + + #endif + + // HANDLE CAMERA POSITION + + // Set the target position of the camera to point at the focus point + var cameraTargetPosition : Vector3 = character.position + initOffsetToPlayer + cameraAdjustmentVector * cameraPreview; + + // Apply some smoothing to the camera movement + mainCameraTransform.position = Vector3.SmoothDamp (mainCameraTransform.position, cameraTargetPosition, cameraVelocity, cameraSmoothing); + + // Save camera offset so we can use it in the next frame + cameraOffset = mainCameraTransform.position - character.position; +} + +public static function PlaneRayIntersection (plane : Plane, ray : Ray) : Vector3 { + var dist : float; + plane.Raycast (ray, dist); + return ray.GetPoint (dist); +} + +public static function ScreenPointToWorldPointOnPlane (screenPoint : Vector3, plane : Plane, camera : Camera) : Vector3 { + // Set up a ray corresponding to the screen position + var ray : Ray = camera.ScreenPointToRay (screenPoint); + + // Find out where the ray intersects with the plane + return PlaneRayIntersection (plane, ray); +} + +function HandleCursorAlignment (cursorWorldPosition : Vector3) { + if (!cursorObject) + return; + + // HANDLE CURSOR POSITION + + // Set the position of the cursor object + cursorObject.position = cursorWorldPosition; + + #if !UNITY_FLASH + // Hide mouse cursor when within screen area, since we're showing game cursor instead + Cursor.visible = (Input.mousePosition.x < 0 || Input.mousePosition.x > Screen.width || Input.mousePosition.y < 0 || Input.mousePosition.y > Screen.height); + #endif + + + // HANDLE CURSOR ROTATION + + var cursorWorldRotation : Quaternion = cursorObject.rotation; + if (motor.facingDirection != Vector3.zero) + cursorWorldRotation = Quaternion.LookRotation (motor.facingDirection); + + // Calculate cursor billboard rotation + var cursorScreenspaceDirection : Vector3 = Input.mousePosition - mainCamera.WorldToScreenPoint (transform.position + character.up * cursorPlaneHeight); + cursorScreenspaceDirection.z = 0; + var cursorBillboardRotation : Quaternion = mainCameraTransform.rotation * Quaternion.LookRotation (cursorScreenspaceDirection, -Vector3.forward); + + // Set cursor rotation + cursorObject.rotation = Quaternion.Slerp (cursorWorldRotation, cursorBillboardRotation, cursorFacingCamera); + + + // HANDLE CURSOR SCALING + + // The cursor is placed in the world so it gets smaller with perspective. + // Scale it by the inverse of the distance to the camera plane to compensate for that. + var compensatedScale : float = 0.1 * Vector3.Dot (cursorWorldPosition - mainCameraTransform.position, mainCameraTransform.forward); + + // Make the cursor smaller when close to character + var cursorScaleMultiplier : float = Mathf.Lerp (0.7, 1.0, Mathf.InverseLerp (0.5, 4.0, motor.facingDirection.magnitude)); + + // Set the scale of the cursor + cursorObject.localScale = Vector3.one * Mathf.Lerp (compensatedScale, 1, cursorSmallerWithDistance) * cursorScaleMultiplier; + + // DEBUG - REMOVE LATER + if (Input.GetKey(KeyCode.O)) cursorFacingCamera += Time.deltaTime * 0.5; + if (Input.GetKey(KeyCode.P)) cursorFacingCamera -= Time.deltaTime * 0.5; + cursorFacingCamera = Mathf.Clamp01(cursorFacingCamera); + + if (Input.GetKey(KeyCode.K)) cursorSmallerWithDistance += Time.deltaTime * 0.5; + if (Input.GetKey(KeyCode.L)) cursorSmallerWithDistance -= Time.deltaTime * 0.5; + cursorSmallerWithDistance = Mathf.Clamp01(cursorSmallerWithDistance); +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Weapons/AutoFire.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Weapons/AutoFire.js new file mode 100644 index 0000000..585a8e6 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Weapons/AutoFire.js @@ -0,0 +1,87 @@ +#pragma strict + +@script RequireComponent (PerFrameRaycast) + +var bulletPrefab : GameObject; +var spawnPoint : Transform; +var frequency : float = 10; +var coneAngle : float = 1.5; +var firing : boolean = false; +var damagePerSecond : float = 20.0; +var forcePerSecond : float = 20.0; +var hitSoundVolume : float = 0.5; + +var muzzleFlashFront : GameObject; + +private var lastFireTime : float = -1; +private var raycast : PerFrameRaycast; + +function Awake () { + muzzleFlashFront.SetActive (false); + + raycast = GetComponent. (); + if (spawnPoint == null) + spawnPoint = transform; +} + +function Update () { + if (firing) { + + if (Time.time > lastFireTime + 1 / frequency) { + // Spawn visual bullet + var coneRandomRotation = Quaternion.Euler (Random.Range (-coneAngle, coneAngle), Random.Range (-coneAngle, coneAngle), 0); + var go : GameObject = Spawner.Spawn (bulletPrefab, spawnPoint.position, spawnPoint.rotation * coneRandomRotation) as GameObject; + var bullet : SimpleBullet = go.GetComponent. (); + + lastFireTime = Time.time; + + // Find the object hit by the raycast + var hitInfo : RaycastHit = raycast.GetHitInfo (); + if (hitInfo.transform) { + // Get the health component of the target if any + var targetHealth : Health = hitInfo.transform.GetComponent. (); + if (targetHealth) { + // Apply damage + targetHealth.OnDamage (damagePerSecond / frequency, -spawnPoint.forward); + } + + // Get the rigidbody if any + if (hitInfo.rigidbody) { + // Apply force to the target object at the position of the hit point + var force : Vector3 = transform.forward * (forcePerSecond / frequency); + hitInfo.rigidbody.AddForceAtPosition (force, hitInfo.point, ForceMode.Impulse); + } + + // Ricochet sound + //var sound : AudioClip = MaterialImpactManager.GetBulletHitSound (hitInfo.collider.sharedMaterial); + //AudioSource.PlayClipAtPoint (sound, hitInfo.point, hitSoundVolume); + + bullet.dist = hitInfo.distance; + } + else { + bullet.dist = 1000; + } + } + } +} + +function OnStartFire () { + if (Time.timeScale == 0) + return; + + firing = true; + + muzzleFlashFront.SetActive (true); + + if (GetComponent.()) + GetComponent.().Play (); +} + +function OnStopFire () { + firing = false; + + muzzleFlashFront.SetActive (false); + + if (GetComponent.()) + GetComponent.().Stop (); +} \ No newline at end of file diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Weapons/Health.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Weapons/Health.js new file mode 100644 index 0000000..649f132 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Weapons/Health.js @@ -0,0 +1,138 @@ +#pragma strict + +public var maxHealth : float = 100.0; +public var health : float = 100.0; +public var regenerateSpeed : float = 0.0; +public var invincible : boolean = false; +public var dead : boolean = false; + +public var damagePrefab : GameObject; +public var damageEffectTransform : Transform; +public var damageEffectMultiplier : float = 1.0; +public var damageEffectCentered : boolean = true; + +public var scorchMarkPrefab : GameObject = null; +private var scorchMark : GameObject = null; + +public var damageSignals : SignalSender; +public var dieSignals : SignalSender; + +private var lastDamageTime : float = 0; +private var damageEffect : ParticleEmitter; +private var damageEffectCenterYOffset : float; + +private var colliderRadiusHeuristic : float = 1.0; + + +function Awake () { + enabled = false; + if (damagePrefab) { + if (damageEffectTransform == null) + damageEffectTransform = transform; + var effect : GameObject = Spawner.Spawn (damagePrefab, Vector3.zero, Quaternion.identity); + effect.transform.parent = damageEffectTransform; + effect.transform.localPosition = Vector3.zero; + damageEffect = effect.GetComponent.(); + var tempSize : Vector2 = Vector2(GetComponent.().bounds.extents.x,GetComponent.().bounds.extents.z); + colliderRadiusHeuristic = tempSize.magnitude * 0.5; + damageEffectCenterYOffset = GetComponent.().bounds.extents.y; + + } + if (scorchMarkPrefab) { + scorchMark = GameObject.Instantiate(scorchMarkPrefab, Vector3.zero, Quaternion.identity); + scorchMark.SetActive (false); + } +} + +function OnDamage (amount : float, fromDirection : Vector3) { + // Take no damage if invincible, dead, or if the damage is zero + if(invincible) + return; + if (dead) + return; + if (amount <= 0) + return; + + // Decrease health by damage and send damage signals + + // @HACK: this hack will be removed for the final game + // but makes playing and showing certain areas in the + // game a lot easier + /* + #if !UNITY_IPHONE && !UNITY_ANDROID && !UNITY_WP8 + if(gameObject.tag != "Player") + amount *= 10.0; + #endif + */ + + health -= amount; + damageSignals.SendSignals (this); + lastDamageTime = Time.time; + + // Enable so the Update function will be called + // if regeneration is enabled + if (regenerateSpeed > 0) + enabled = true; + + // Show damage effect if there is one + if (damageEffect) { + damageEffect.transform.rotation = Quaternion.LookRotation (fromDirection, Vector3.up); + if(!damageEffectCentered) { + var dir : Vector3 = fromDirection; + dir.y = 0.0; + damageEffect.transform.position = (transform.position + Vector3.up * damageEffectCenterYOffset) + colliderRadiusHeuristic * dir; + } + // @NOTE: due to popular demand (ethan, storm) we decided + // to make the amount damage independent ... + //var particleAmount = Random.Range (damageEffect.minEmission, damageEffect.maxEmission + 1); + //particleAmount = particleAmount * amount * damageEffectMultiplier; + damageEffect.Emit();// (particleAmount); + } + + // Die if no health left + if (health <= 0) + { +// GameScore.RegisterDeath (gameObject); + + health = 0; + dead = true; + dieSignals.SendSignals (this); + enabled = false; + + // scorch marks + if (scorchMark) { + scorchMark.SetActive (true); + // @NOTE: maybe we can justify a raycast here so we can place the mark + // on slopes with proper normal alignments + // @TODO: spawn a yield Sub() to handle placement, as we can + // spread calculations over several frames => cheap in total + var scorchPosition : Vector3 = GetComponent.().ClosestPointOnBounds (transform.position - Vector3.up * 100); + scorchMark.transform.position = scorchPosition + Vector3.up * 0.1; + scorchMark.transform.eulerAngles.y = Random.Range (0.0, 90.0); + } + } +} + +function OnEnable () { + Regenerate (); +} + +// Regenerate health + +function Regenerate () { + if (regenerateSpeed > 0.0f) { + while (enabled) { + if (Time.time > lastDamageTime + 3) { + health += regenerateSpeed; + + yield; + + if (health >= maxHealth) { + health = maxHealth; + enabled = false; + } + } + yield WaitForSeconds (1.0f); + } + } +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Weapons/HealthFlash.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Weapons/HealthFlash.js new file mode 100644 index 0000000..906e2ce --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Weapons/HealthFlash.js @@ -0,0 +1,22 @@ + +#pragma strict + +public var playerHealth : Health; +public var healthMaterial : Material; + +private var healthBlink : float = 1.0f; +private var oneOverMaxHealth : float = 0.5f; + +function Start () { + oneOverMaxHealth = 1.0f / playerHealth.maxHealth; +} + +function Update () { + var relativeHealth : float = playerHealth.health * oneOverMaxHealth; + healthMaterial.SetFloat ("_SelfIllumination", relativeHealth * 2.0f * healthBlink); + + if (relativeHealth < 0.45f) + healthBlink = Mathf.PingPong (Time.time * 6.0f, 2.0f); + else + healthBlink = 1.0f; +} \ No newline at end of file diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Weapons/PerFrameRaycast.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Weapons/PerFrameRaycast.js new file mode 100644 index 0000000..4d8f7b6 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Weapons/PerFrameRaycast.js @@ -0,0 +1,18 @@ +#pragma strict + +private var hitInfo : RaycastHit; +private var tr : Transform; + +function Awake () { + tr = transform; +} + +function Update () { + // Cast a ray to find out the end point of the laser + hitInfo = RaycastHit (); + Physics.Raycast (tr.position, tr.forward, hitInfo); +} + +function GetHitInfo () : RaycastHit { + return hitInfo; +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Weapons/SimpleBullet.js b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Weapons/SimpleBullet.js new file mode 100644 index 0000000..c8ea115 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Scripts/Weapons/SimpleBullet.js @@ -0,0 +1,21 @@ +#pragma strict + +var speed : float = 10; +var lifeTime : float = 0.5; +var dist : float = 10000; + +private var spawnTime : float = 0.0; +private var tr : Transform; + +function OnEnable () { + tr = transform; + spawnTime = Time.time; +} + +function Update () { + tr.position += tr.forward * speed * Time.deltaTime; + dist -= speed * Time.deltaTime; + if (Time.time > spawnTime + lifeTime || dist < 0) { + Spawner.Destroy (gameObject); + } +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/AngryInclude.cginc b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/AngryInclude.cginc new file mode 100644 index 0000000..e122b39 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/AngryInclude.cginc @@ -0,0 +1,22 @@ +// Upgrade NOTE: unity_Scale shader variable was removed; replaced 'unity_Scale.w' with '1.0' + + +#ifndef ANGRY_CG_INCLUDED +#define ANGRY_CG_INCLUDED + +#include "UnityCG.cginc" + +void WriteTangentSpaceData (appdata_full v, out half3 ts0, out half3 ts1, out half3 ts2) { + TANGENT_SPACE_ROTATION; + ts0 = mul(rotation, _Object2World[0].xyz * 1.0); + ts1 = mul(rotation, _Object2World[1].xyz * 1.0); + ts2 = mul(rotation, _Object2World[2].xyz * 1.0); +} + +half2 EthansFakeReflection (half4 vtx) { + half3 worldSpace = mul(_Object2World, vtx).xyz; + worldSpace = (-_WorldSpaceCameraPos * 0.6 + worldSpace) * 0.07; + return worldSpace.xz; +} + +#endif \ No newline at end of file diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/CharacterSelfIlluminationReflective.shader b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/CharacterSelfIlluminationReflective.shader new file mode 100644 index 0000000..b1e73bf --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/CharacterSelfIlluminationReflective.shader @@ -0,0 +1,174 @@ + +/* + +the + +CharacterSelfIlluminationReflective + +performs optimized custom character lighting (self illumination enabled and + reflective (with a simple heuristic for the reflection mask)) + +*/ + +Shader "AngryBots/Character/CharacterSelfIlluminationReflective" { + + Properties { + _MainTex ("Base (RGB) Gloss (A)", 2D) = "grey" {} + _BumpMap ("Normalmap", 2D) = "bump" {} + _Cube ("Cube", CUBE) = "black" {} + _SelfIllumStrength ("_SelfIllumStrength", Range(0.0, 1.5)) = 1.0 + _RoomReflectionAmount ("RoomReflectionAmount", Range(0.0, 3.5)) = 3.0 + } + + CGINCLUDE + + #include "UnityCG.cginc" + #include "AngryInclude.cginc" + + uniform float4x4 _CameraToWorld; + uniform half4 _MainTex_ST; + uniform sampler2D _MainTex; + uniform sampler2D _BumpMap; + uniform samplerCUBE _Cube; + + uniform fixed _RoomReflectionAmount; + uniform fixed _SelfIllumStrength; + + half3 VertexLightsWorldSpace (half3 WP, half3 WN) + { + half3 lightColor = half3(0.0,0.0,0.0); + + // preface & optimization + half3 toLight0 = mul(_CameraToWorld, unity_LightPosition[0] * half4(1,1,-1,1)).xyz - WP; + half3 toLight1 = mul(_CameraToWorld, unity_LightPosition[1] * half4(1,1,-1,1)).xyz - WP; + half2 lengthSq2 = half2(dot(toLight0, toLight0), dot(toLight1, toLight1)); + + half2 atten2 = half2(1.0,1.0) + lengthSq2 * half2(unity_LightAtten[0].z, unity_LightAtten[1].z); + atten2 = 1.0 / atten2; + + // light #0 + half diff = saturate (dot (WN, normalize(toLight0))); + lightColor += unity_LightColor[0].rgb * (diff * atten2.x); + + // light #1 + diff = saturate (dot (WN, normalize(toLight1))); + lightColor += unity_LightColor[1].rgb * (diff * atten2.y); + + return lightColor * 1.75 + 0.2; + } + + ENDCG + + SubShader { + LOD 300 + Lighting on + Tags { "RenderType"="Opaque" "Reflection" = "RenderReflectionOpaque" "Queue"="Geometry" } + + Pass { + + CGPROGRAM + + #pragma vertex vert + #pragma fragment frag + #pragma fragmentoption ARB_precision_hint_fastest + + struct v2f_full + { + half4 pos : POSITION; + half3 color : TEXCOORD0; + half2 uv : TEXCOORD1; + half3 viewDir : TEXCOORD2; + half3 tsBase0 : TEXCOORD3; + half3 tsBase1 : TEXCOORD4; + half3 tsBase2 : TEXCOORD5; + }; + + v2f_full vert (appdata_full v) + { + v2f_full o; + + o.pos = mul(UNITY_MATRIX_MVP, v.vertex); + + half3 worldPos = mul(_Object2World, v.vertex).xyz; + half3 worldNormal = mul((half3x3)_Object2World, v.normal.xyz); + + o.color = VertexLightsWorldSpace(worldPos, worldNormal); + + o.uv.xy = TRANSFORM_TEX(v.texcoord, _MainTex); + o.viewDir = (_WorldSpaceCameraPos.xyz - worldPos); + + WriteTangentSpaceData(v, o.tsBase0,o.tsBase1,o.tsBase2); + + return o; + } + + fixed4 frag (v2f_full i) : COLOR + { + fixed4 tex = tex2D(_MainTex, i.uv.xy); + half3 nrml = UnpackNormal(tex2D(_BumpMap, i.uv.xy)); + half3 bumpedNormal = half3(dot(i.tsBase0,nrml), dot(i.tsBase1,nrml), dot(i.tsBase2,nrml)); + + half3 reflDir = reflect(i.viewDir, bumpedNormal); + fixed4 refl = texCUBE (_Cube, reflDir); + half4 outColor = tex; + outColor.rgb *= i.color + tex.a * _SelfIllumStrength; + outColor += refl * _RoomReflectionAmount * saturate(tex.b - 0.225); + return outColor; + } + + ENDCG + } + } + + SubShader { + LOD 190 + Lighting on + Tags { "RenderType"="Opaque" "Reflection" = "RenderReflectionOpaque" "Queue"="Geometry" } + + Pass { + + CGPROGRAM + + #pragma vertex vert + #pragma fragment frag + #pragma fragmentoption ARB_precision_hint_fastest + + struct v2f + { + half4 pos : POSITION; + half3 color : TEXCOORD0; + half2 uv : TEXCOORD1; + half3 reflDir : TEXCOORD2; + }; + + v2f vert (appdata_base v) + { + v2f o; + o.pos = mul(UNITY_MATRIX_MVP, v.vertex); + + half3 worldPos = mul(_Object2World, v.vertex).xyz; + half3 worldNormal = mul((half3x3)_Object2World, v.normal.xyz); + + o.color = VertexLightsWorldSpace(worldPos, worldNormal); + + o.uv.xy = TRANSFORM_TEX(v.texcoord,_MainTex); + o.reflDir = (_WorldSpaceCameraPos.xyz - worldPos); + o.reflDir = reflect (o.reflDir, worldNormal); + + return o; + } + + fixed4 frag (v2f i) : COLOR + { + fixed4 tex = tex2D(_MainTex, i.uv.xy); + fixed4 refl = texCUBE (_Cube, i.reflDir); + half4 outColor = tex; + outColor.rgb *= i.color + tex.a * _SelfIllumStrength; + outColor += refl * _RoomReflectionAmount * saturate(tex.b - 0.225); + return outColor; + } + + ENDCG + } + } +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/EnemySelfIlluminationReflective.shader b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/EnemySelfIlluminationReflective.shader new file mode 100644 index 0000000..4e40f09 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/EnemySelfIlluminationReflective.shader @@ -0,0 +1,163 @@ + +/* + +the + +EnemySelfIlluminationReflective + +is a cheaper and less accurate version of the +CharacterSelfIlluminationReflective shader but pretty +much the same on highest quality setting + +*/ + +Shader "AngryBots/Character/EnemySelfIlluminationReflective" { + + Properties { + _MainTex ("Base (RGB) Gloss (A)", 2D) = "grey" {} + _BumpMap ("Normalmap", 2D) = "bump" {} + _Cube ("Cube", CUBE) = "black" {} + _SelfIllumStrength ("_SelfIllumStrength", Range(0.0, 1.5)) = 1.0 + } + + CGINCLUDE + + #include "UnityCG.cginc" + #include "AngryInclude.cginc" + + uniform half4 _MainTex_ST; + uniform sampler2D _MainTex; + uniform samplerCUBE _Cube; + uniform fixed _SelfIllumStrength; + uniform sampler2D _BumpMap; + uniform float4x4 _CameraToWorld; + + half3 VertexLightsWorldSpace (half3 WP, half3 WN) + { + half3 lightColor = half3(0.0,0.0,0.0); + + // preface & optimization + half3 toLight0 = mul(_CameraToWorld, unity_LightPosition[0] * half4(1,1,-1,1)).xyz - WP; + half3 toLight1 = mul(_CameraToWorld, unity_LightPosition[1] * half4(1,1,-1,1)).xyz - WP; + half2 lengthSq2 = half2(dot(toLight0, toLight0), dot(toLight1, toLight1)); + + half2 atten2 = half2(1.0,1.0) + lengthSq2 * half2(unity_LightAtten[0].z, unity_LightAtten[1].z); + atten2 = 1.0 / atten2; + + // light #0 + half diff = saturate (dot (WN, normalize(toLight0))); + lightColor += unity_LightColor[0].rgb * (diff * atten2.x); + + // light #1 + diff = saturate (dot (WN, normalize(toLight1))); + lightColor += unity_LightColor[1].rgb * (diff * atten2.y); + + return lightColor * 1.75 + 0.2; + } + + ENDCG + + SubShader { + LOD 300 + Lighting on + Tags { "RenderType"="Opaque" "Reflection" = "RenderReflectionOpaque" "Queue"="Geometry" } + + Pass { + + CGPROGRAM + + #pragma vertex vert + #pragma fragment frag + #pragma fragmentoption ARB_precision_hint_fastest + + struct v2f_full + { + half4 pos : POSITION; + half3 color : TEXCOORD0; + half2 uv : TEXCOORD1; + half3 viewDir : TEXCOORD2; + half3 tsBase0 : TEXCOORD3; + half3 tsBase1 : TEXCOORD4; + half3 tsBase2 : TEXCOORD5; + }; + + v2f_full vert (appdata_full v) + { + v2f_full o; + + o.pos = mul(UNITY_MATRIX_MVP, v.vertex); + + half3 worldPos = mul(_Object2World, v.vertex).xyz; + half3 worldNormal = mul((half3x3)_Object2World, v.normal.xyz); + + o.color = VertexLightsWorldSpace(worldPos, worldNormal); + + o.uv.xy = TRANSFORM_TEX(v.texcoord, _MainTex); + o.viewDir = (_WorldSpaceCameraPos.xyz - worldPos); + + WriteTangentSpaceData(v, o.tsBase0,o.tsBase1,o.tsBase2); + + return o; + } + + fixed4 frag (v2f_full i) : COLOR + { + fixed4 tex = tex2D(_MainTex, i.uv.xy); + half3 nrml = UnpackNormal(tex2D(_BumpMap, i.uv.xy)); + half3 bumpedNormal = half3(dot(i.tsBase0,nrml), dot(i.tsBase1,nrml), dot(i.tsBase2,nrml)); + half3 reflDir = reflect(i.viewDir, bumpedNormal); + fixed4 refl = texCUBE (_Cube, reflDir); + fixed4 outColor = half4((i.color + tex.a * _SelfIllumStrength) * tex, 1.0); + outColor += refl * 3.0 * saturate(tex.g - 0.25) * (1.0 - tex.a); + return outColor; + } + + ENDCG + } + } + + SubShader { + LOD 190 + Lighting on + Tags { "RenderType"="Opaque" "Reflection" = "RenderReflectionOpaque" "Queue"="Geometry" } + + Pass { + + CGPROGRAM + + #pragma vertex vert + #pragma fragment frag + #pragma fragmentoption ARB_precision_hint_fastest + + struct v2f + { + half4 pos : POSITION; + half4 color : TEXCOORD0; + half2 uv : TEXCOORD1; + half3 reflDir : TEXCOORD2; + }; + + v2f vert (appdata_base v) + { + v2f o; + o.color = (unity_LightColor[0] + unity_LightColor[1]) * 0.2; // heuristic for the lighting, works 'ok' in AngryBots, but is not a general solution + o.pos = mul(UNITY_MATRIX_MVP, v.vertex); + o.uv.xy = TRANSFORM_TEX(v.texcoord, _MainTex); + o.reflDir = WorldSpaceViewDir (v.vertex); + o.reflDir = reflect (o.reflDir, mul((half3x3)_Object2World, v.normal.xyz)); + return o; + } + + fixed4 frag (v2f i) : COLOR + { + fixed4 tex = tex2D(_MainTex, i.uv.xy); + fixed4 refl = texCUBE (_Cube, i.reflDir); + fixed4 outColor = (i.color + tex.a * _SelfIllumStrength) * tex; + outColor += refl * 3.0 * saturate(tex.g - 0.25) * (1.0 - tex.a); + return outColor; + } + + ENDCG + } + } +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/Fallback.shader b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/Fallback.shader new file mode 100644 index 0000000..124ca9c --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/Fallback.shader @@ -0,0 +1,72 @@ +// Upgrade NOTE: commented out 'half4 unity_LightmapST', a built-in variable +// Upgrade NOTE: commented out 'sampler2D unity_Lightmap', a built-in variable +// Upgrade NOTE: replaced tex2D unity_Lightmap with UNITY_SAMPLE_TEX2D + + + +Shader "AngryBots/Fallback" { + +Properties { + _MainTex ("Base", 2D) = "white" {} +} + + +CGINCLUDE + +struct v2f +{ + half4 pos : SV_POSITION; + half2 uv : TEXCOORD0; + half2 uv2 : TEXCOORD1; +}; + +#include "AngryInclude.cginc" + +sampler2D _MainTex; + +ENDCG + +SubShader { + Tags { "RenderType"="Opaque" } + LOD 140 + + Pass { + CGPROGRAM + + // half4 unity_LightmapST; + // sampler2D unity_Lightmap; + half4 _MainTex_ST; + + v2f vert (appdata_full v) + { + v2f o; + o.pos = mul (UNITY_MATRIX_MVP, v.vertex); + o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); + o.uv2 = v.texcoord1 * unity_LightmapST.xy + unity_LightmapST.zw; + return o; + } + + fixed4 frag (v2f i) : COLOR0 + { + fixed4 tex = tex2D (_MainTex, i.uv); + #ifdef LIGHTMAP_ON + fixed3 lm = DecodeLightmap (UNITY_SAMPLE_TEX2D(unity_Lightmap, i.uv2)); + tex.rgb *= lm; + #else + tex.rgb *= 0.65; + #endif + return tex; + } + + #pragma vertex vert + #pragma fragment frag + #pragma fragmentoption ARB_precision_hint_fastest + #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON + + ENDCG + } +} + +FallBack Off +} + diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/PlanarRealtimeReflection.shader b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/PlanarRealtimeReflection.shader new file mode 100644 index 0000000..5439d3b --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/PlanarRealtimeReflection.shader @@ -0,0 +1,161 @@ +// Upgrade NOTE: commented out 'half4 unity_LightmapST', a built-in variable +// Upgrade NOTE: commented out 'sampler2D unity_Lightmap', a built-in variable +// Upgrade NOTE: replaced tex2D unity_Lightmap with UNITY_SAMPLE_TEX2D + + +/* + +(realtime & planar) reflection shader. + +handles simple planar (y is up) bump displacement of planar reflections. + +*/ + +Shader "AngryBots/PlanarRealtimeReflection" { + Properties { + _MainTex ("Base", 2D) = "white" {} + _ReflectionTex ("Internal reflection", 2D) = "black" {} + _CubeReflTex ("Cube", CUBE) = "black" {} + _Normals ("Normal", 2D) = "bump" {} + } + + CGINCLUDE + + #include "UnityCG.cginc" + + sampler2D _MainTex; + sampler2D _ReflectionTex; + sampler2D _Normals; + samplerCUBE _CubeReflTex; + + struct v2f { + half4 pos : SV_POSITION; + half2 uv : TEXCOORD0; + half4 scr : TEXCOORD1; + half2 uvLM : TEXCOORD2; + }; + + struct v2f_full { + half4 pos : SV_POSITION; + half2 uv : TEXCOORD0; + half4 scr : TEXCOORD1; + half3 tsBase0 : TEXCOORD2; + half3 tsBase1 : TEXCOORD3; + half3 tsBase2 : TEXCOORD4; + half3 viewDir : TEXCOORD5; + half2 uvLM : TEXCOORD6; + }; + + ENDCG + + SubShader { + LOD 400 + + Tags { "RenderType"="Opaque" } + Fog { Mode Off } + + Pass { + + CGPROGRAM + + #include "AngryInclude.cginc" + + uniform half4 _MainTex_ST; + // half4 unity_LightmapST; + // sampler2D unity_Lightmap; + + v2f_full vert(appdata_full v) + { + v2f_full o; + + o.pos = mul (UNITY_MATRIX_MVP, v.vertex); + + o.uv.xy = TRANSFORM_TEX(v.texcoord.xy, _MainTex); + + o.scr = ComputeScreenPos(o.pos); + + o.uvLM = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw; + + WriteTangentSpaceData(v, o.tsBase0,o.tsBase1,o.tsBase2); + o.viewDir = normalize(WorldSpaceViewDir(v.vertex)); + + return o; + } + + half4 frag( v2f_full i ) : COLOR + { + half3 normals = UnpackNormal(tex2D(_Normals, i.uv.xy)); + half3 bumpedNormal = half3(dot(i.tsBase0,normals), dot(i.tsBase1,normals), dot(i.tsBase2,normals)); + + half3 reflectVector = reflect(-i.viewDir.xyz, bumpedNormal.xyz); + + half4 color = tex2D(_MainTex, i.uv); + i.scr = i.scr/i.scr.w; + + fixed3 lm = DecodeLightmap (UNITY_SAMPLE_TEX2D(unity_Lightmap, i.uvLM.xy)); + color.rgb *= lm; + + i.scr.xy += normals.xy; + return color + tex2D(_ReflectionTex, i.scr.xy) + texCUBE(_CubeReflTex, reflectVector) * 0.1; + } + + #pragma vertex vert + #pragma fragment frag + #pragma fragmentoption ARB_precision_hint_fastest + + ENDCG + + } + } + + SubShader { + LOD 200 + + Tags { "RenderType"="Opaque" } + Fog { Mode Off } + + Pass { + + CGPROGRAM + + uniform half4 _MainTex_ST; + // half4 unity_LightmapST; + // sampler2D unity_Lightmap; + + v2f vert(appdata_full v) + { + v2f o; + + o.pos = mul (UNITY_MATRIX_MVP, v.vertex); + + o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); + o.uvLM = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw; + + o.scr = ComputeScreenPos(o.pos); + + return o; + } + + fixed4 frag( v2f i ) : COLOR + { + fixed4 color = tex2D(_MainTex, i.uv); + + fixed3 lm = DecodeLightmap(UNITY_SAMPLE_TEX2D(unity_Lightmap, i.uvLM)); + color.rgb *= lm; + + half2 screen = (i.scr.xy / i.scr.w); + + return color + tex2D(_ReflectionTex, screen) * color.a; + } + + #pragma vertex vert + #pragma fragment frag + #pragma fragmentoption ARB_precision_hint_fastest + + ENDCG + + } + } + + FallBack "AngryBots/Fallback" +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/ReflectiveBackgroundPlanar.shader b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/ReflectiveBackgroundPlanar.shader new file mode 100644 index 0000000..cee83a7 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/ReflectiveBackgroundPlanar.shader @@ -0,0 +1,160 @@ +// Upgrade NOTE: commented out 'half4 unity_LightmapST', a built-in variable +// Upgrade NOTE: commented out 'sampler2D unity_Lightmap', a built-in variable +// Upgrade NOTE: replaced tex2D unity_Lightmap with UNITY_SAMPLE_TEX2D + + +/* + +one of the most common shader in AngryBots, requires lightmap + +handles simple CUBE map reflections (higher end) or +fake planar (y is up) reflections (low end) + +*/ + +Shader "AngryBots/ReflectiveBackgroundPlanarGeometry" { + +Properties { + _MainTex ("Base", 2D) = "white" {} + _Cube ("Cube", Cube) = "" {} + _2DReflect ("2D Reflection", 2D) = "" {} + _Normal("Normal", 2D) = "bump" {} + _EmissionLM ("Emission (Lightmapper)", Float) = 0 +} + +CGINCLUDE + +// interpolator structs + +struct v2f +{ + half4 pos : SV_POSITION; + half2 uv : TEXCOORD0; + half2 uv2 : TEXCOORD1; + half2 uvLM : TEXCOORD2; +}; + +struct v2f_full +{ + half4 pos : SV_POSITION; + half2 uv : TEXCOORD0; + half3 worldViewDir : TEXCOORD1; + half3 tsBase0 : TEXCOORD2; + half3 tsBase1 : TEXCOORD3; + half3 tsBase2 : TEXCOORD4; + half2 uvLM : TEXCOORD5; +}; + +#include "AngryInclude.cginc" + +sampler2D _MainTex; +samplerCUBE _Cube; +sampler2D _2DReflect; +sampler2D _Normal; + +ENDCG + + +SubShader { + Tags { "RenderType"="Opaque" } + LOD 300 + + Pass { + CGPROGRAM + + half4 _MainTex_ST; + // half4 unity_LightmapST; + // sampler2D unity_Lightmap; + + v2f_full vert (appdata_full v) + { + v2f_full o; + o.pos = mul (UNITY_MATRIX_MVP, v.vertex); + o.uv = TRANSFORM_TEX(v.texcoord,_MainTex); + + o.uvLM = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw; + + o.worldViewDir = normalize(WorldSpaceViewDir(v.vertex)); + + WriteTangentSpaceData(v, o.tsBase0, o.tsBase1, o.tsBase2); + + return o; + } + + + fixed4 frag (v2f_full i) : COLOR0 + { + half3 nrml = UnpackNormal(tex2D(_Normal, i.uv.xy)); + half3 bumpedNormal = half3(dot(i.tsBase0,nrml), dot(i.tsBase1,nrml), dot(i.tsBase2,nrml)); + + half3 reflectVector = reflect(normalize(-i.worldViewDir.xyz), normalize(bumpedNormal.xyz)); + + half4 refl = texCUBE(_Cube, (reflectVector)); + + fixed4 tex = tex2D (_MainTex, i.uv.xy); + + tex += refl * tex.a; + + fixed3 lm = DecodeLightmap (UNITY_SAMPLE_TEX2D(unity_Lightmap, i.uvLM.xy)); + tex.rgb *= lm; + + return tex; + + } + + #pragma vertex vert + #pragma fragment frag + #pragma fragmentoption ARB_precision_hint_fastest + + ENDCG + } +} + +SubShader { + Tags { "RenderType"="Opaque" } + LOD 200 + + Pass { + CGPROGRAM + + half4 _MainTex_ST; + // half4 unity_LightmapST; + // sampler2D unity_Lightmap; + + v2f vert (appdata_full v) + { + v2f o; + o.pos = mul (UNITY_MATRIX_MVP, v.vertex); + o.uv = TRANSFORM_TEX (v.texcoord, _MainTex); + o.uvLM = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw; + o.uv2 = EthansFakeReflection (v.vertex); + + return o; + } + + fixed4 frag (v2f i) : COLOR0 + { + fixed4 tex = tex2D (_MainTex, i.uv); + + fixed4 refl = tex2D (_2DReflect, i.uv2); + tex += refl * tex.a; + + #ifdef LIGHTMAP_ON + fixed3 lm = DecodeLightmap (UNITY_SAMPLE_TEX2D (unity_Lightmap, i.uvLM)); + tex.rgb *= lm; + #endif + + return tex; + } + + #pragma vertex vert + #pragma fragment frag + #pragma fragmentoption ARB_precision_hint_fastest + #pragma multi_compile LIGHTMAP_OFF LIGHTMAP_ON + + ENDCG + } +} + +FallBack "AngryBots/Fallback" +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/SuperSimpleSelfIllumination.shader b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/SuperSimpleSelfIllumination.shader new file mode 100644 index 0000000..0da39a3 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/BackgroundAndCharacters/SuperSimpleSelfIllumination.shader @@ -0,0 +1,55 @@ +/* + +illum shader. + +self illumination based on base texture alpha channel. + +*/ + +Shader "AngryBots/SimpleSelfIllumination" { + +Properties { + _MainTex ("Base", 2D) = "grey" {} + _SelfIllumination ("Self Illumination", Range(0.0,2.0)) = 1.0 +} + +SubShader { + Pass { + CGPROGRAM + + #pragma vertex vert + #pragma fragment frag + + #include "UnityCG.cginc" + + uniform half4 _MainTex_ST; + uniform sampler2D _MainTex; + uniform fixed _SelfIllumination; + + struct v2f + { + half4 pos : POSITION; + half2 uv : TEXCOORD0; + }; + + v2f vert (appdata_base v) + { + v2f o; + o.pos = mul(UNITY_MATRIX_MVP, v.vertex); + o.uv.xy = TRANSFORM_TEX(v.texcoord,_MainTex); + + return o; + } + + half4 frag (v2f i) : COLOR + { + fixed4 tex = tex2D(_MainTex, i.uv.xy); + return tex * tex.a * _SelfIllumination; + } + + ENDCG + } +} + +FallBack Off +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/Additive.shader b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/Additive.shader new file mode 100644 index 0000000..27aa4ec --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/Additive.shader @@ -0,0 +1,59 @@ + +Shader "AngryBots/FX/Additive" { + Properties { + _MainTex ("Base", 2D) = "white" {} + _TintColor ("TintColor", Color) = (1.0, 1.0, 1.0, 1.0) + } + + CGINCLUDE + + #include "UnityCG.cginc" + + sampler2D _MainTex; + fixed4 _TintColor; + + half4 _MainTex_ST; + + struct v2f { + half4 pos : SV_POSITION; + half2 uv : TEXCOORD0; + }; + + v2f vert(appdata_full v) { + v2f o; + + o.pos = mul (UNITY_MATRIX_MVP, v.vertex); + o.uv.xy = TRANSFORM_TEX(v.texcoord, _MainTex); + + return o; + } + + fixed4 frag( v2f i ) : COLOR { + return tex2D (_MainTex, i.uv.xy) * _TintColor; + } + + ENDCG + + SubShader { + Tags { "RenderType" = "Transparent" "Reflection" = "RenderReflectionTransparentAdd" "Queue" = "Transparent"} + Cull Off + Lighting Off + ZWrite Off + Fog { Mode Off } + Blend One One + + Pass { + + CGPROGRAM + + #pragma vertex vert + #pragma fragment frag + #pragma fragmentoption ARB_precision_hint_fastest + + ENDCG + + } + + } + FallBack Off +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/Cursor.shader b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/Cursor.shader new file mode 100644 index 0000000..fa5c4b9 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/Cursor.shader @@ -0,0 +1,58 @@ + +Shader "AngryBots/FX/Cursor" { + Properties { + _MainTex ("Base", 2D) = "white" {} + } + + CGINCLUDE + + #include "UnityCG.cginc" + + sampler2D _MainTex; + + half4 _MainTex_ST; + + struct v2f { + half4 pos : SV_POSITION; + half2 uv : TEXCOORD0; + }; + + v2f vert(appdata_full v) { + v2f o; + + o.pos = mul (UNITY_MATRIX_MVP, v.vertex); + o.uv.xy = TRANSFORM_TEX(v.texcoord, _MainTex); + + return o; + } + + fixed4 frag( v2f i ) : COLOR { + return tex2D (_MainTex, i.uv.xy); + } + + ENDCG + + SubShader { + Tags { "RenderType" = "Transparent" "Queue" = "Transparent+100"} + Cull Off + Lighting Off + ZWrite Off + ZTest Always + Fog { Mode Off } + Blend SrcAlpha OneMinusSrcAlpha + + Pass { + + CGPROGRAM + + #pragma vertex vert + #pragma fragment frag + #pragma fragmentoption ARB_precision_hint_fastest + + ENDCG + + } + + } + FallBack Off +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/LaserScope.shader b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/LaserScope.shader new file mode 100644 index 0000000..3ffb86c --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/LaserScope.shader @@ -0,0 +1,63 @@ + +Shader "AngryBots/FX/LaserScope" { + Properties { + _MainTex ("MainTex", 2D) = "white" + _NoiseTex ("NoiseTex", 2D) = "white" + } + + CGINCLUDE + + #include "UnityCG.cginc" + + sampler2D _MainTex; + sampler2D _NoiseTex; + + half4 _MainTex_ST; + half4 _NoiseTex_ST; + + fixed4 _TintColor; + + struct v2f { + half4 pos : SV_POSITION; + half4 uv : TEXCOORD0; + }; + + v2f vert(appdata_full v) + { + v2f o; + + o.pos = mul (UNITY_MATRIX_MVP, v.vertex); + o.uv.xy = TRANSFORM_TEX(v.texcoord, _MainTex); + o.uv.zw = TRANSFORM_TEX(v.texcoord, _NoiseTex); + + return o; + } + + fixed4 frag( v2f i ) : COLOR + { + return tex2D (_MainTex, i.uv.xy) * tex2D (_NoiseTex, i.uv.zw); + } + + ENDCG + + SubShader { + Tags { "RenderType" = "Transparent" "Reflection" = "LaserScope" "Queue" = "Transparent"} + Cull Off + ZWrite Off + Blend SrcAlpha One + + Pass { + + CGPROGRAM + + #pragma vertex vert + #pragma fragment frag + #pragma fragmentoption ARB_precision_hint_fastest + + ENDCG + + } + + } + FallBack Off +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/Multiply.shader b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/Multiply.shader new file mode 100644 index 0000000..b97ac3d --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/Multiply.shader @@ -0,0 +1,55 @@ + +Shader "AngryBots/FX/Multiply" { + Properties { + _MainTex ("Base", 2D) = "white" {} + } + + CGINCLUDE + + #include "UnityCG.cginc" + + sampler2D _MainTex; + + struct v2f { + half4 pos : SV_POSITION; + half2 uv : TEXCOORD0; + }; + + v2f vert(appdata_full v) { + v2f o; + + o.pos = mul (UNITY_MATRIX_MVP, v.vertex); + o.uv.xy = v.texcoord.xy; + + return o; + } + + fixed4 frag( v2f i ) : COLOR { + return tex2D (_MainTex, i.uv.xy); + } + + ENDCG + + SubShader { + Tags { "RenderType" = "Transparent" "Queue" = "Transparent" } + Cull Off + Lighting Off + ZWrite Off + Fog { Mode Off } + Blend Zero SrcColor + + Pass { + + CGPROGRAM + + #pragma vertex vert + #pragma fragment frag + #pragma fragmentoption ARB_precision_hint_fastest + + ENDCG + + } + + } + FallBack Off +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/ParticleAdditive.shader b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/ParticleAdditive.shader new file mode 100644 index 0000000..3cdd9b8 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/ParticleAdditive.shader @@ -0,0 +1,60 @@ + +Shader "AngryBots/Particle/Additive" { + Properties { + _MainTex ("Base", 2D) = "white" {} + _TintColor ("TintColor", Color) = (1.0, 1.0, 1.0, 1.0) + } + + CGINCLUDE + + #include "UnityCG.cginc" + + sampler2D _MainTex; + fixed4 _TintColor; + half4 _MainTex_ST; + + struct v2f { + half4 pos : SV_POSITION; + half2 uv : TEXCOORD0; + fixed4 vertexColor : COLOR; + }; + + v2f vert(appdata_full v) { + v2f o; + + o.pos = mul (UNITY_MATRIX_MVP, v.vertex); + o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); + o.vertexColor = v.color * _TintColor; + + return o; + } + + fixed4 frag( v2f i ) : COLOR { + return tex2D (_MainTex, i.uv.xy) * i.vertexColor; + } + + ENDCG + + SubShader { + Tags { "RenderType" = "Transparent" "Queue" = "Transparent"} + Cull Off + Lighting Off + ZWrite Off + Fog { Mode Off } + Blend One One + + Pass { + + CGPROGRAM + + #pragma vertex vert + #pragma fragment frag + #pragma fragmentoption ARB_precision_hint_fastest + + ENDCG + + } + + } + FallBack Off +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/ParticleAdditiveBlend.shader b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/ParticleAdditiveBlend.shader new file mode 100644 index 0000000..e735438 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/ParticleAdditiveBlend.shader @@ -0,0 +1,60 @@ + +Shader "AngryBots/Particle/AdditiveBlend" { + Properties { + _MainTex ("Base", 2D) = "white" {} + _TintColor ("TintColor", Color) = (1.0, 1.0, 1.0, 1.0) + } + + CGINCLUDE + + #include "UnityCG.cginc" + + sampler2D _MainTex; + fixed4 _TintColor; + half4 _MainTex_ST; + + struct v2f { + half4 pos : SV_POSITION; + half2 uv : TEXCOORD0; + fixed4 vertexColor : COLOR; + }; + + v2f vert(appdata_full v) { + v2f o; + + o.pos = mul (UNITY_MATRIX_MVP, v.vertex); + o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); + o.vertexColor = v.color * _TintColor; + + return o; + } + + fixed4 frag( v2f i ) : COLOR { + return tex2D (_MainTex, i.uv.xy) * i.vertexColor; + } + + ENDCG + + SubShader { + Tags { "RenderType" = "Transparent" "Queue" = "Transparent"} + Cull Off + Lighting Off + ZWrite Off + Fog { Mode Off } + Blend SrcAlpha One + + Pass { + + CGPROGRAM + + #pragma vertex vert + #pragma fragment frag + #pragma fragmentoption ARB_precision_hint_fastest + + ENDCG + + } + + } + FallBack Off +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/ParticleBlend.shader b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/ParticleBlend.shader new file mode 100644 index 0000000..7545f3f --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Shaders/Fx/ParticleBlend.shader @@ -0,0 +1,59 @@ + +Shader "AngryBots/Particle/AlphaBlend" { + Properties { + _MainTex ("Base", 2D) = "white" {} + _TintColor ("TintColor", Color) = (1.0, 1.0, 1.0, 1.0) + } + + CGINCLUDE + + #include "UnityCG.cginc" + + sampler2D _MainTex; + fixed4 _TintColor; + + struct v2f { + half4 pos : SV_POSITION; + half2 uv : TEXCOORD0; + fixed4 vertexColor : COLOR; + }; + + v2f vert(appdata_full v) { + v2f o; + + o.pos = mul (UNITY_MATRIX_MVP, v.vertex); + o.uv.xy = v.texcoord.xy; + o.vertexColor = v.color * _TintColor; + + return o; + } + + fixed4 frag( v2f i ) : COLOR { + return tex2D (_MainTex, i.uv.xy) * i.vertexColor; + } + + ENDCG + + SubShader { + Tags { "RenderType" = "Transparent" "Queue" = "Transparent"} + Cull Off + Lighting Off + ZWrite Off + Fog { Mode Off } + Blend SrcAlpha OneMinusSrcAlpha + + Pass { + + CGPROGRAM + + #pragma vertex vert + #pragma fragment frag + #pragma fragmentoption ARB_precision_hint_fastest + + ENDCG + + } + + } + FallBack Off +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Enemy/enemy_Spider_AlertSound.wav b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Enemy/enemy_Spider_AlertSound.wav new file mode 100644 index 0000000..1861157 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Enemy/enemy_Spider_AlertSound.wav differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Enemy/enemy_Spider_DestroyedExplosion.wav b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Enemy/enemy_Spider_DestroyedExplosion.wav new file mode 100644 index 0000000..e9420c9 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Enemy/enemy_Spider_DestroyedExplosion.wav differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Enemy/enemy_Spider_Proximity.wav b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Enemy/enemy_Spider_Proximity.wav new file mode 100644 index 0000000..ab67ce8 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Enemy/enemy_Spider_Proximity.wav differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Enemy/enemy_Spider_SelfDestruct.wav b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Enemy/enemy_Spider_SelfDestruct.wav new file mode 100644 index 0000000..aaec6f4 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Enemy/enemy_Spider_SelfDestruct.wav differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Enemy/enemy_Spider_skidding.wav b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Enemy/enemy_Spider_skidding.wav new file mode 100644 index 0000000..9b796c9 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Enemy/enemy_Spider_skidding.wav differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Player/player_hit.wav b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Player/player_hit.wav new file mode 100644 index 0000000..34680e9 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Player/player_hit.wav differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Player/player_killed_1.wav b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Player/player_killed_1.wav new file mode 100644 index 0000000..2827dc4 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Player/player_killed_1.wav differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Player/player_shooting.wav b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Player/player_shooting.wav new file mode 100644 index 0000000..7b7e326 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Sounds/Player/player_shooting.wav differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Effects/HealthBar.tif b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Effects/HealthBar.tif new file mode 100644 index 0000000..6ad7d03 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Effects/HealthBar.tif differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Effects/LaserDot.psd b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Effects/LaserDot.psd new file mode 100644 index 0000000..a8aa841 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Effects/LaserDot.psd differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Effects/LaserTexture.psd b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Effects/LaserTexture.psd new file mode 100644 index 0000000..44ddb08 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Effects/LaserTexture.psd differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Effects/Materials/SimpleNoise.mat b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Effects/Materials/SimpleNoise.mat new file mode 100644 index 0000000..863a723 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Effects/Materials/SimpleNoise.mat differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Effects/Reflections/CubeMaps/LobbyRoom.cubemap b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Effects/Reflections/CubeMaps/LobbyRoom.cubemap new file mode 100644 index 0000000..6e0aaf2 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Effects/Reflections/CubeMaps/LobbyRoom.cubemap differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Effects/SimpleNoise.psd b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Effects/SimpleNoise.psd new file mode 100644 index 0000000..d4c244e Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Effects/SimpleNoise.psd differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Minebot.tif b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Minebot.tif new file mode 100644 index 0000000..f18ca8f Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Minebot.tif differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Player.tif b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Player.tif new file mode 100644 index 0000000..e3f0135 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Player.tif differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/ThumbStickPad.psd b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/ThumbStickPad.psd new file mode 100644 index 0000000..45ecdb3 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/ThumbStickPad.psd differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Weapon.tif b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Weapon.tif new file mode 100644 index 0000000..06d18fd Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AngryBotsTests/Textures/Weapon.tif differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AssertionExampleScene.unity b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AssertionExampleScene.unity new file mode 100644 index 0000000..2562b39 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/AssertionExampleScene.unity differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/CodeBasedAssertionExample.cs b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/CodeBasedAssertionExample.cs new file mode 100644 index 0000000..54579a3 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/CodeBasedAssertionExample.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using UnityTest; + +[IntegrationTest.DynamicTestAttribute("ExampleIntegrationTests")] +[IntegrationTest.SucceedWithAssertions] +public class CodeBasedAssertionExample : MonoBehaviour +{ + public float FloatField = 3; + + public GameObject goReference; + + public void Awake() + { + // An assertion that will compare a foat value from a custom component attached to a GameObject to a constant variable equal to 3. + // The comparasment will happen Start method and every 5 frames in the Update method + // Additionally, the comparer is configured to have accuracy of 0.1 for floating euqlity check. + IAssertionComponentConfigurator configurator; + var c = AssertionComponent.Create(out configurator, CheckMethod.Update | CheckMethod.Start, gameObject, "CodeBasedAssertionExample.FloatField", 3f); + configurator.UpdateCheckRepeatFrequency = 5; + c.floatingPointError = 0.1; + c.compareTypes = FloatComparer.CompareTypes.Equal; + + // Create an assertion that will fail is the FloatField from InitAssertions component of gameObject will change it's value + AssertionComponent.Create(CheckMethod.Update | CheckMethod.Start, gameObject, "CodeBasedAssertionExample.FloatField"); + + // Validate the gameObject.transform.y is always equal to 3 (defined in this component) + transform.position = new Vector3(0, 3, 0); + AssertionComponent.Create(CheckMethod.Update, gameObject, "CodeBasedAssertionExample.FloatField", gameObject, "transform.position.y"); + + // Check with the goReference field from this component is not set to null + goReference = gameObject; + var gc = AssertionComponent.Create(CheckMethod.Update, gameObject, "CodeBasedAssertionExample.goReference", null); + gc.compareType = GeneralComparer.CompareType.ANotEqualsB; + } +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/CustomComponent.cs b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/CustomComponent.cs new file mode 100644 index 0000000..f879b13 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/CustomComponent.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace UnityTest +{ + public class CustomComponent : MonoBehaviour + { + public float MyFloatProp { get; set; } + public float MyFloatField = 3; + } +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/DynamicIntegrationTest.cs b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/DynamicIntegrationTest.cs new file mode 100644 index 0000000..0772d55 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/DynamicIntegrationTest.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +[IntegrationTest.DynamicTestAttribute("ExampleIntegrationTests")] +// [IntegrationTest.Ignore] +[IntegrationTest.ExpectExceptions(false, typeof(ArgumentException))] +[IntegrationTest.SucceedWithAssertions] +[IntegrationTest.TimeoutAttribute(1)] +[IntegrationTest.ExcludePlatformAttribute(RuntimePlatform.Android, RuntimePlatform.LinuxPlayer)] +public class DynamicIntegrationTest : MonoBehaviour +{ + public void Start() + { + IntegrationTest.Pass(gameObject); + } +} diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/ExampleIntegrationTests.unity b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/ExampleIntegrationTests.unity new file mode 100644 index 0000000..4215df3 Binary files /dev/null and b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/ExampleIntegrationTests.unity differ diff --git a/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/ThrowCustomException.cs b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/ThrowCustomException.cs new file mode 100644 index 0000000..1845393 --- /dev/null +++ b/Assets/UnityTestTools/Examples/IntegrationTestsFrameworkExamples/ThrowCustomException.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +public class ThrowCustomException : MonoBehaviour +{ + public void Start() + { + throw new CustomException(); + } + + private class CustomException : Exception + { + } +} diff --git a/Assets/UnityTestTools/Examples/UnitTestExamples/Editor/SampleTests.cs b/Assets/UnityTestTools/Examples/UnitTestExamples/Editor/SampleTests.cs new file mode 100644 index 0000000..8e9f70e --- /dev/null +++ b/Assets/UnityTestTools/Examples/UnitTestExamples/Editor/SampleTests.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using NUnit.Framework; +using UnityEngine; + +namespace UnityTest +{ + [TestFixture] + [Category("Sample Tests")] + internal class SampleTests + { + [Test] + [Category("Failing Tests")] + public void ExceptionTest() + { + throw new Exception("Exception throwing test"); + } + + [Test] + [Ignore("Ignored test")] + public void IgnoredTest() + { + throw new Exception("Ignored this test"); + } + + [Test] + [MaxTime(100)] + [Category("Failing Tests")] + public void SlowTest() + { + Thread.Sleep(200); + } + + [Test] + [Category("Failing Tests")] + public void FailingTest() + { + Assert.Fail(); + } + + [Test] + [Category("Failing Tests")] + public void InconclusiveTest() + { + Assert.Inconclusive(); + } + + [Test] + public void PassingTest() + { + Assert.Pass(); + } + + [Test] + public void ParameterizedTest([Values(1, 2, 3)] int a) + { + Assert.Pass(); + } + + [Test] + public void RangeTest([NUnit.Framework.Range(1, 10, 3)] int x) + { + Assert.Pass(); + } + + [Test] + [Culture("pl-PL")] + public void CultureSpecificTest() + { + } + + [Test] + [ExpectedException(typeof(ArgumentException), ExpectedMessage = "expected message")] + public void ExpectedExceptionTest() + { + throw new ArgumentException("expected message"); + } + + [Datapoint] + public double zero = 0; + [Datapoint] + public double positive = 1; + [Datapoint] + public double negative = -1; + [Datapoint] + public double max = double.MaxValue; + [Datapoint] + public double infinity = double.PositiveInfinity; + + [Theory] + public void SquareRootDefinition(double num) + { + Assume.That(num >= 0.0 && num < double.MaxValue); + + var sqrt = Math.Sqrt(num); + + Assert.That(sqrt >= 0.0); + Assert.That(sqrt * sqrt, Is.EqualTo(num).Within(0.000001)); + } + } +} diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/DTOFormatter.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/DTOFormatter.cs new file mode 100644 index 0000000..d930676 --- /dev/null +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/DTOFormatter.cs @@ -0,0 +1,128 @@ +using UnityEngine; +using System; +using System.IO; + +namespace UnityTest +{ + + public class DTOFormatter { + + private interface ITransferInterface + { + void Transfer(ref ResultDTO.MessageType val); + void Transfer(ref TestResultState val); + void Transfer(ref byte val); + void Transfer(ref bool val); + void Transfer(ref int val); + void Transfer(ref float val); + void Transfer(ref double val); + void Transfer(ref string val); + } + + private class Writer : ITransferInterface + { + private readonly Stream _stream; + public Writer(Stream stream) { _stream = stream; } + + private void WriteConvertedNumber(byte[] bytes) + { + if(BitConverter.IsLittleEndian) + Array.Reverse(bytes); + _stream.Write(bytes, 0, bytes.Length); + } + + public void Transfer(ref ResultDTO.MessageType val) { _stream.WriteByte((byte)val); } + public void Transfer(ref TestResultState val) { _stream.WriteByte((byte)val); } + public void Transfer(ref byte val) { _stream.WriteByte(val); } + public void Transfer(ref bool val) { _stream.WriteByte((byte)(val ? 0x01 : 0x00)); } + public void Transfer(ref int val) { WriteConvertedNumber(BitConverter.GetBytes(val)); } + public void Transfer(ref float val) { WriteConvertedNumber(BitConverter.GetBytes(val)); } + public void Transfer(ref double val) { WriteConvertedNumber(BitConverter.GetBytes(val)); } + + public void Transfer(ref string val) + { + var bytes = System.Text.Encoding.BigEndianUnicode.GetBytes(val); + int length = bytes.Length; + Transfer(ref length); + _stream.Write(bytes, 0, bytes.Length); + } + } + + private class Reader : ITransferInterface + { + private readonly Stream _stream; + public Reader(Stream stream) { _stream = stream; } + + private byte[] ReadConvertedNumber(int size) + { + byte[] buffer = new byte[size]; + _stream.Read (buffer, 0, buffer.Length); + if(BitConverter.IsLittleEndian) + Array.Reverse(buffer); + return buffer; + } + + public void Transfer(ref ResultDTO.MessageType val) { val = (ResultDTO.MessageType)_stream.ReadByte(); } + public void Transfer(ref TestResultState val) { val = (TestResultState)_stream.ReadByte(); } + public void Transfer(ref byte val) { val = (byte)_stream.ReadByte(); } + public void Transfer(ref bool val) { val = (_stream.ReadByte() != 0); } + public void Transfer(ref int val) { val = BitConverter.ToInt32(ReadConvertedNumber(4), 0); } + public void Transfer(ref float val) { val = BitConverter.ToSingle(ReadConvertedNumber(4), 0); } + public void Transfer(ref double val) { val = BitConverter.ToDouble(ReadConvertedNumber(8), 0); } + + public void Transfer(ref string val) + { + int length = 0; + Transfer (ref length); + var bytes = new byte[length]; + _stream.Read(bytes, 0, length); + val = System.Text.Encoding.BigEndianUnicode.GetString(bytes); + } + } + + private void Transfer(ResultDTO dto, ITransferInterface transfer) + { + transfer.Transfer(ref dto.messageType); + + transfer.Transfer(ref dto.levelCount); + transfer.Transfer(ref dto.loadedLevel); + transfer.Transfer(ref dto.loadedLevelName); + + if(dto.messageType == ResultDTO.MessageType.Ping + || dto.messageType == ResultDTO.MessageType.RunStarted + || dto.messageType == ResultDTO.MessageType.RunFinished + || dto.messageType == ResultDTO.MessageType.RunInterrupted) + return; + + transfer.Transfer(ref dto.testName); + transfer.Transfer(ref dto.testTimeout); + + if(transfer is Reader) + dto.testResult = new SerializableTestResult(); + SerializableTestResult str = (SerializableTestResult)dto.testResult; + + transfer.Transfer(ref str.resultState); + transfer.Transfer(ref str.message); + transfer.Transfer(ref str.executed); + transfer.Transfer(ref str.name); + transfer.Transfer(ref str.fullName); + transfer.Transfer(ref str.id); + transfer.Transfer(ref str.isSuccess); + transfer.Transfer(ref str.duration); + transfer.Transfer(ref str.stackTrace); + } + + public void Serialize (System.IO.Stream stream, ResultDTO dto) + { + Transfer(dto, new Writer(stream)); + } + + public object Deserialize (System.IO.Stream stream) + { + var result = (ResultDTO)System.Runtime.Serialization.FormatterServices.GetSafeUninitializedObject(typeof(ResultDTO)); + Transfer (result, new Reader(stream)); + return result; + } + } + +} \ No newline at end of file diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsHierarchyAnnotation.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsHierarchyAnnotation.cs new file mode 100644 index 0000000..4aa5dc4 --- /dev/null +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsHierarchyAnnotation.cs @@ -0,0 +1,44 @@ +using UnityEngine; +using System.Collections; +using UnityEditor; + +namespace UnityTest +{ + + [InitializeOnLoad] + public class IntegrationTestsHierarchyAnnotation { + + static IntegrationTestsHierarchyAnnotation() + { + EditorApplication.hierarchyWindowItemOnGUI += DoAnnotationGUI; + } + + public static void DoAnnotationGUI(int id, Rect rect) + { + var obj = EditorUtility.InstanceIDToObject(id) as GameObject; + if(!obj) return; + + var tc = obj.GetComponent(); + if(!tc) return; + + if (!EditorApplication.isPlayingOrWillChangePlaymode + && rect.Contains(Event.current.mousePosition) + && Event.current.type == EventType.MouseDown + && Event.current.button == 1) + { + IntegrationTestRendererBase.DrawContextMenu(tc); + Event.current.Use (); + } + + EditorGUIUtility.SetIconSize(new Vector2(15, 15)); + var result = IntegrationTestsRunnerWindow.GetResultForTest(tc); + if (result != null) + { + var icon = result.Executed ? IntegrationTestRendererBase.GetIconForResult(result.resultType) : Icons.UnknownImg; + EditorGUI.LabelField(new Rect(rect.xMax - 18, rect.yMin - 2, rect.width, rect.height), new GUIContent(icon)); + } + EditorGUIUtility.SetIconSize(Vector2.zero); + } + } + +} \ No newline at end of file diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerSettings.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerSettings.cs index c16ebc4..0d63329 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerSettings.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerSettings.cs @@ -1,19 +1,25 @@ using System; using System.Collections.Generic; using UnityEngine; +using UnityEditor; namespace UnityTest { public class IntegrationTestsRunnerSettings : ProjectSettingsBase { - public bool showOptions; - public string filterString; - public bool showAdvancedFilter; - public bool showSucceededTest = true; - public bool showFailedTest = true; - public bool showNotRunnedTest = true; - public bool showIgnoredTest = true; public bool addNewGameObjectUnderSelectedTest; public bool blockUIWhenRunning = true; + + public void ToggleAddNewGameObjectUnderSelectedTest () + { + addNewGameObjectUnderSelectedTest = !addNewGameObjectUnderSelectedTest; + Save (); + } + + public void ToggleBlockUIWhenRunning () + { + blockUIWhenRunning = !blockUIWhenRunning; + Save (); + } } } diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerWindow.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerWindow.cs index 1c7bb05..f01d54f 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerWindow.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/IntegrationTestsRunnerWindow.cs @@ -8,27 +8,19 @@ namespace UnityTest { [Serializable] - public class IntegrationTestsRunnerWindow : EditorWindow + public class IntegrationTestsRunnerWindow : EditorWindow, IHasCustomMenu { #region GUI Contents - private readonly GUIContent m_GUIOptionsHideLabel = new GUIContent("Hide", Icons.GearImg); - private readonly GUIContent m_GUIOptionsShowLabel = new GUIContent("Options", Icons.GearImg); - private readonly GUIContent m_GUICreateNewTest = new GUIContent(Icons.PlusImg, "Create new test"); - private readonly GUIContent m_GUIRunSelectedTests = new GUIContent(Icons.RunImg, "Run selected test(s)"); - private readonly GUIContent m_GUIRunAllTests = new GUIContent(Icons.RunAllImg, "Run all tests"); - private readonly GUIContent m_GUIAdvancedFilterShow = new GUIContent("Advanced"); - private readonly GUIContent m_GUIAdvancedFilterHide = new GUIContent("Hide"); + private readonly GUIContent m_GUICreateNewTest = new GUIContent("Create", "Create new test"); + private readonly GUIContent m_GUIRunSelectedTests = new GUIContent("Run Selected", "Run selected test(s)"); + private readonly GUIContent m_GUIRunAllTests = new GUIContent("Run All", "Run all tests"); private readonly GUIContent m_GUIAddGoUderTest = new GUIContent("Add GOs under test", "Add new GameObject under selected test"); private readonly GUIContent m_GUIBlockUI = new GUIContent("Block UI when running", "Block UI when running tests"); - private readonly GUIContent m_GUIShowSucceededTests = new GUIContent("Succeeded", Icons.SuccessImg, "Show tests that succeeded"); - private readonly GUIContent m_GUIShowFailedTests = new GUIContent("Failed", Icons.FailImg, "Show tests that failed"); - private readonly GUIContent m_GUIShowIgnoredTests = new GUIContent("Ignored", Icons.IgnoreImg, "Show tests that are ignored"); - private readonly GUIContent m_GUIShowNotRunTests = new GUIContent("Not Run", Icons.UnknownImg, "Show tests that didn't run"); #endregion #region runner steerign vars private static IntegrationTestsRunnerWindow s_Instance; - [SerializeField] private List m_TestsToRun; + [SerializeField] private List m_TestsToRun; [SerializeField] private List m_DynamicTestsToRun; [SerializeField] private bool m_ReadyToRun; private bool m_IsBuilding; @@ -37,6 +29,7 @@ public class IntegrationTestsRunnerWindow : EditorWindow private Vector2 m_TestInfoScroll, m_TestListScroll; private IntegrationTestRendererBase[] m_TestLines; private string m_CurrectSceneName; + private TestFilterSettings m_FilterSettings; [SerializeField] private GameObject m_SelectedLine; [SerializeField] private List m_ResultList = new List(); @@ -66,7 +59,7 @@ private static void InitBackgroundRunners() private static void OnPlaymodeStateChanged() { - if (EditorApplication.isPlaying == EditorApplication.isPlayingOrWillChangePlaymode) + if (s_Instance && EditorApplication.isPlaying == EditorApplication.isPlayingOrWillChangePlaymode) s_Instance.RebuildTestList(); } @@ -82,6 +75,7 @@ public void OnDestroy() private static void BackgroundSceneChangeWatch() { + if (!s_Instance) return; if (s_Instance.m_CurrectSceneName != null && s_Instance.m_CurrectSceneName == EditorApplication.currentScene) return; if (EditorApplication.isPlayingOrWillChangePlaymode) return; TestComponent.DestroyAllDynamicTests(); @@ -91,10 +85,11 @@ private static void BackgroundSceneChangeWatch() public void OnEnable() { - title = "Integration Tests Runner"; + title = "Integration Tests"; s_Instance = this; m_Settings = ProjectSettingsBase.Load(); + m_FilterSettings = new TestFilterSettings("UnityTest.IntegrationTestsRunnerWindow"); InitBackgroundRunners(); if (!EditorApplication.isPlayingOrWillChangePlaymode && !m_ReadyToRun) RebuildTestList(); @@ -128,7 +123,7 @@ public void OnSelectionChange() public static void OnHierarchyChangeUpdate() { - if (s_Instance.m_TestLines == null || EditorApplication.isPlayingOrWillChangePlaymode) return; + if (!s_Instance || s_Instance.m_TestLines == null || EditorApplication.isPlayingOrWillChangePlaymode) return; // create a test runner if it doesn't exist TestRunner.GetTestRunner(); @@ -158,6 +153,12 @@ public static void OnHierarchyChangeUpdate() if (selectedInHierarchy) selectedInHierarchy = false; else s_Instance.RebuildTestList(); } + + public static TestResult GetResultForTest(TestComponent tc) + { + if(!s_Instance) return new TestResult(tc); + return s_Instance.m_ResultList.FirstOrDefault(r => r.GameObject == tc.gameObject); + } public static void OnHierarchyWindowItemDraw(int id, Rect rect) { @@ -165,26 +166,6 @@ public static void OnHierarchyWindowItemDraw(int id, Rect rect) if (o is GameObject) { var go = o as GameObject; - var tc = go.GetComponent(); - if (tc != null) - { - if (!EditorApplication.isPlayingOrWillChangePlaymode - && rect.Contains(Event.current.mousePosition) - && Event.current.type == EventType.MouseDown - && Event.current.button == 1) - { - IntegrationTestRendererBase.DrawContextMenu(tc); - } - - EditorGUIUtility.SetIconSize(new Vector2(15, 15)); - var result = s_Instance.m_ResultList.Find(r => r.GameObject == go); - if (result != null) - { - var icon = result.Executed ? IntegrationTestRendererBase.GetIconForResult(result.resultType) : Icons.UnknownImg; - EditorGUI.LabelField(new Rect(rect.xMax - 18, rect.yMin - 2, rect.width, rect.height), new GUIContent(icon)); - } - EditorGUIUtility.SetIconSize(Vector2.zero); - } if (Event.current.type == EventType.MouseDown && Event.current.button == 0 @@ -204,6 +185,7 @@ public static void OnHierarchyWindowItemDraw(int id, Rect rect) private static void SelectInHierarchy(GameObject gameObject) { + if (!s_Instance) return; if (gameObject == s_Instance.m_SelectedLine) return; if (!gameObject.activeSelf) { @@ -212,7 +194,7 @@ private static void SelectInHierarchy(GameObject gameObject) } var tests = TestComponent.FindAllTestsOnScene(); - var skipList = gameObject.GetComponentsInChildren(typeof(TestComponent), true); + var skipList = gameObject.GetComponentsInChildren(typeof(TestComponent), true).ToList(); tests.RemoveAll(skipList.Contains); foreach (var test in tests) { @@ -227,10 +209,12 @@ private void RunTests(IList tests) return; FocusWindowIfItsOpen(GetType()); - m_TestsToRun = tests.Where(t => t is TestComponent).Cast().ToList(); - var temp = m_TestsToRun.Where(t => t.dynamic).ToArray(); - m_DynamicTestsToRun = temp.Select(c => c.dynamicTypeName).ToList(); - m_TestsToRun.RemoveAll(temp.Contains); + var testComponents = tests.Where(t => t is TestComponent).Cast().ToList(); + var dynaminTests = testComponents.Where(t => t.dynamic).ToList(); + m_DynamicTestsToRun = dynaminTests.Select(c => c.dynamicTypeName).ToList(); + testComponents.RemoveAll(dynaminTests.Contains); + + m_TestsToRun = testComponents.Select( tc => tc.gameObject ).ToList(); m_ReadyToRun = true; TestComponent.DisableAllTests(); @@ -246,11 +230,12 @@ public void Update() { m_ReadyToRun = false; var testRunner = TestRunner.GetTestRunner(); - testRunner.TestRunnerCallback.Add(new RunnerCallback(this)); - testRunner.InitRunner(m_TestsToRun.ToList(), m_DynamicTestsToRun); + testRunner.TestRunnerCallback.Add(new RunnerCallback(this)); + var testComponents = m_TestsToRun.Select(go => go.GetComponent()).ToList(); + testRunner.InitRunner(testComponents, m_DynamicTestsToRun); } } - + private void RebuildTestList() { m_TestLines = null; @@ -301,6 +286,8 @@ private void RebuildTestList() IntegrationTestRendererBase.RunTest = RunTests; IntegrationTestGroupLine.FoldMarkers = m_FoldMarkers; IntegrationTestLine.Results = m_ResultList; + + m_FilterSettings.UpdateCounters(m_ResultList.Cast()); m_FoldMarkers.RemoveAll(o => o == null); @@ -361,21 +348,19 @@ public void OnGUI() public void PrintHeadPanel() { - GUILayout.Space(10); - EditorGUILayout.BeginHorizontal(); - var layoutOptions = new[] { GUILayout.Height(24), GUILayout.Width(32) }; - if (GUILayout.Button(m_GUIRunAllTests, Styles.buttonLeft, layoutOptions) - && !EditorApplication.isPlayingOrWillChangePlaymode) + EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); + EditorGUI.BeginDisabledGroup(EditorApplication.isPlayingOrWillChangePlaymode); + if (GUILayout.Button(m_GUIRunAllTests, EditorStyles.toolbarButton)) { RunTests(TestComponent.FindAllTestsOnScene().Cast().ToList()); } - if (GUILayout.Button(m_GUIRunSelectedTests, Styles.buttonMid, layoutOptions) - && !EditorApplication.isPlayingOrWillChangePlaymode) + EditorGUI.BeginDisabledGroup(!Selection.gameObjects.Any (t => t.GetComponent(typeof(ITestComponent)))); + if (GUILayout.Button(m_GUIRunSelectedTests, EditorStyles.toolbarButton)) { RunTests(Selection.gameObjects.Select(t => t.GetComponent(typeof(TestComponent))).Cast().ToList()); } - if (GUILayout.Button(m_GUICreateNewTest, Styles.buttonRight, layoutOptions) - && !EditorApplication.isPlayingOrWillChangePlaymode) + EditorGUI.EndDisabledGroup(); + if (GUILayout.Button(m_GUICreateNewTest, EditorStyles.toolbarButton)) { var test = TestComponent.CreateTest(); if (Selection.gameObjects.Length == 1 @@ -387,60 +372,26 @@ public void PrintHeadPanel() Selection.activeGameObject = test; RebuildTestList(); } - GUILayout.FlexibleSpace(); - if (GUILayout.Button(m_Settings.showOptions ? m_GUIOptionsHideLabel : m_GUIOptionsShowLabel, GUILayout.Height(24), GUILayout.Width(80))) - m_Settings.showOptions = !m_Settings.showOptions; - EditorGUILayout.EndHorizontal(); - - if (m_Settings.showOptions) - PrintOptions(); - - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.LabelField("Filter:", GUILayout.Width(35)); - m_Settings.filterString = EditorGUILayout.TextField(m_Settings.filterString); - if (GUILayout.Button(m_Settings.showAdvancedFilter ? m_GUIAdvancedFilterHide : m_GUIAdvancedFilterShow, GUILayout.Width(80), GUILayout.Height(16))) - m_Settings.showAdvancedFilter = !m_Settings.showAdvancedFilter; - EditorGUILayout.EndHorizontal(); - - if (m_Settings.showAdvancedFilter) - PrintAdvancedFilter(); - } - - public void PrintOptions() - { - var style = EditorStyles.toggle; - EditorGUILayout.BeginVertical(); - EditorGUI.BeginChangeCheck(); - - m_Settings.addNewGameObjectUnderSelectedTest = EditorGUILayout.Toggle(m_GUIAddGoUderTest, m_Settings.addNewGameObjectUnderSelectedTest, style); - m_Settings.blockUIWhenRunning = EditorGUILayout.Toggle(m_GUIBlockUI, m_Settings.blockUIWhenRunning, style); - if (EditorGUI.EndChangeCheck()) m_Settings.Save(); - - EditorGUILayout.EndVertical(); + EditorGUI.EndDisabledGroup(); + + GUILayout.FlexibleSpace (); + + m_FilterSettings.OnGUI (); + + EditorGUILayout.EndHorizontal (); } - - private void PrintAdvancedFilter() + + public void AddItemsToMenu(GenericMenu menu) { - EditorGUI.BeginChangeCheck(); - EditorGUILayout.BeginHorizontal(); - m_Settings.showSucceededTest = GUILayout.Toggle(m_Settings.showSucceededTest, m_GUIShowSucceededTests, GUI.skin.FindStyle(GUI.skin.button.name + "left"), GUILayout.ExpandWidth(true)); - m_Settings.showFailedTest = GUILayout.Toggle(m_Settings.showFailedTest, m_GUIShowFailedTests, GUI.skin.FindStyle(GUI.skin.button.name + "mid")); - m_Settings.showIgnoredTest = GUILayout.Toggle(m_Settings.showIgnoredTest, m_GUIShowIgnoredTests, GUI.skin.FindStyle(GUI.skin.button.name + "mid")); - m_Settings.showNotRunnedTest = GUILayout.Toggle(m_Settings.showNotRunnedTest, m_GUIShowNotRunTests, GUI.skin.FindStyle(GUI.skin.button.name + "right"), GUILayout.ExpandWidth(true)); - EditorGUILayout.EndHorizontal(); - if (EditorGUI.EndChangeCheck()) m_Settings.Save(); + menu.AddItem(m_GUIAddGoUderTest, m_Settings.addNewGameObjectUnderSelectedTest, m_Settings.ToggleAddNewGameObjectUnderSelectedTest); + menu.AddItem(m_GUIBlockUI, m_Settings.blockUIWhenRunning, m_Settings.ToggleBlockUIWhenRunning); } - + private bool PrintTestList(IntegrationTestRendererBase[] renderedLines) { if (renderedLines == null) return false; - var filter = new RenderingOptions(); - filter.showSucceeded = m_Settings.showSucceededTest; - filter.showFailed = m_Settings.showFailedTest; - filter.showNotRunned = m_Settings.showNotRunnedTest; - filter.showIgnored = m_Settings.showIgnoredTest; - filter.nameFilter = m_Settings.filterString; + var filter = m_FilterSettings.BuildRenderingOptions(); bool repaint = false; foreach (var renderedLine in renderedLines) diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/NetworkResultsReceiver.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/NetworkResultsReceiver.cs index c7924c2..88b8dc5 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/NetworkResultsReceiver.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/NetworkResultsReceiver.cs @@ -46,7 +46,7 @@ private void AcceptCallback(TcpClient client) m_LastMessageReceived = DateTime.Now; using (var stream = client.GetStream()) { - var bf = new BinaryFormatter(); + var bf = new DTOFormatter(); dto = (ResultDTO)bf.Deserialize(stream); stream.Close(); } diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunner.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunner.cs index 0f265d8..230a6a1 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunner.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunner.cs @@ -61,7 +61,8 @@ public static void BuildAndRunInPlayer(PlatformRunnerConfiguration configuration catch (SocketException e) { Debug.LogException(e); - EditorApplication.Exit(Batch.returnCodeRunError); + if (InternalEditorUtility.inBatchMode) + EditorApplication.Exit(Batch.returnCodeRunError); } } @@ -95,7 +96,7 @@ public static void BuildAndRunInPlayer(PlatformRunnerConfiguration configuration if (configuration.sendResultsOverNetwork) NetworkResultsReceiver.StartReceiver(configuration); - else + else if (InternalEditorUtility.inBatchMode) EditorApplication.Exit(Batch.returnCodeTestsOk); } diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerSettingsWindow.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerSettingsWindow.cs index a8531d5..190700b 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerSettingsWindow.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/PlatformRunner/PlatformRunnerSettingsWindow.cs @@ -62,7 +62,7 @@ public void OnGUI() { if (Event.current.type == EventType.mouseDown && Event.current.button == 0) { - if (!Event.current.control) + if (!Event.current.control && !Event.current.command) m_SelectedScenes.Clear(); if (!m_SelectedScenes.Contains(scenePath)) m_SelectedScenes.Add(scenePath); diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/IntegrationTestGroupLine.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/IntegrationTestGroupLine.cs index 5301958..a7d8619 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/IntegrationTestGroupLine.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/IntegrationTestGroupLine.cs @@ -17,13 +17,9 @@ public IntegrationTestGroupLine(GameObject gameObject) : base(gameObject) protected internal override void DrawLine(Rect rect, GUIContent label, bool isSelected, RenderingOptions options) { - EditorGUILayout.BeginHorizontal(); - EditorGUI.BeginChangeCheck(); var isClassFolded = !EditorGUI.Foldout(rect, !Folded, label, isSelected ? Styles.selectedFoldout : Styles.foldout); if (EditorGUI.EndChangeCheck()) Folded = isClassFolded; - - EditorGUILayout.EndHorizontal(); } private bool Folded diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/IntegrationTestLine.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/IntegrationTestLine.cs index 40f32ea..e0b5d1a 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/IntegrationTestLine.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/IntegrationTestLine.cs @@ -17,20 +17,19 @@ public IntegrationTestLine(GameObject gameObject, TestResult testResult) : base( protected internal override void DrawLine(Rect rect, GUIContent label, bool isSelected, RenderingOptions options) { - EditorGUILayout.BeginHorizontal(); - rect.x += 10; + if(Event.current.type != EventType.repaint) + return; - EditorGUI.LabelField(rect, label, isSelected ? Styles.selectedLabel : Styles.label); + Styles.testName.Draw (rect, label, false, false, false, isSelected); if (m_Result.IsTimeout) { - var timeoutRect = new Rect(rect); - timeoutRect.x = timeoutRect.x + timeoutRect.width; - timeoutRect.width = 24; - EditorGUI.LabelField(timeoutRect, s_GUITimeoutIcon); - GUILayout.FlexibleSpace(); + float min, max; + Styles.testName.CalcMinMaxWidth(label, out min, out max); + var timeoutRect = new Rect(rect); + timeoutRect.x += min - 12; + Styles.testName.Draw(timeoutRect, s_GUITimeoutIcon, false, false, false, isSelected); } - EditorGUILayout.EndHorizontal(); } protected internal override TestResult.ResultType GetResult() diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/IntegrationTestRendererBase.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/IntegrationTestRendererBase.cs index 1172445..be4b3a4 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/IntegrationTestRendererBase.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/Editor/Renderer/IntegrationTestRendererBase.cs @@ -77,9 +77,9 @@ protected internal virtual void Render(int indend, RenderingOptions options) protected void OnSelect() { - if (!Event.current.control) Selection.objects = new Object[0]; + if (!Event.current.control && !Event.current.command) Selection.objects = new Object[0]; - if (Event.current.control && Selection.gameObjects.Contains(test.gameObject)) + if ((Event.current.control || Event.current.command) && Selection.gameObjects.Contains(test.gameObject)) Selection.objects = Selection.gameObjects.Where(o => o != test.gameObject).ToArray(); else Selection.objects = Selection.gameObjects.Concat(new[] { test.gameObject }).ToArray(); diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/NetworkResultSender.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/NetworkResultSender.cs index b4ea587..d7024d9 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/NetworkResultSender.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/NetworkResultSender.cs @@ -55,7 +55,7 @@ private bool SendDTO(ResultDTO dto) return false; } - var bf = new BinaryFormatter(); + var bf = new DTOFormatter(); bf.Serialize(tcpClient.GetStream(), dto); tcpClient.GetStream().Close(); tcpClient.Close(); diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/ResultDTO.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/ResultDTO.cs index 14a1f06..8922b2e 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/ResultDTO.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/ResultDTO.cs @@ -23,7 +23,7 @@ private ResultDTO(MessageType messageType) loadedLevelName = Application.loadedLevelName; } - public enum MessageType + public enum MessageType : byte { Ping, RunStarted, @@ -80,6 +80,7 @@ private static ITestResult GetSerializableTestResult(TestResult test) str.isSuccess = test.IsSuccess; str.duration = test.duration; str.stackTrace = test.stacktrace; + str.isIgnored = test.IsIgnored; return str; } @@ -98,6 +99,7 @@ internal class SerializableTestResult : ITestResult public bool isSuccess; public double duration; public string stackTrace; + public bool isIgnored; public TestResultState ResultState { @@ -109,6 +111,11 @@ public string Message get { return message; } } + public string Logs + { + get { return null; } + } + public bool Executed { get { return executed; } @@ -143,6 +150,11 @@ public string StackTrace { get { return stackTrace; } } + + public bool IsIgnored + { + get { return isIgnored; } + } } #endregion } diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestComponent.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestComponent.cs index a35643e..09bd3fd 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestComponent.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestComponent.cs @@ -258,7 +258,6 @@ private static GameObject CreateTest(string name) { var go = new GameObject(name); go.AddComponent(); - go.transform.hideFlags |= HideFlags.HideInInspector; return go; } diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestRunner.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestRunner.cs index d683a42..78b69da 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestRunner.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestRunner.cs @@ -34,7 +34,6 @@ public bool isInitializedByRunner private double m_StartTime; private bool m_ReadyToRun; - private AssertionComponent[] m_AssertionsToCheck; private string m_TestMessages; private string m_Stacktrace; private TestState m_TestState = TestState.Running; @@ -84,9 +83,7 @@ public void Start() public void InitRunner(List tests, List dynamicTestsToRun) { - m_CurrentlyRegisteredLogCallback = GetLogCallbackField(); - m_LogCallback = LogHandler; - Application.RegisterLogCallback(m_LogCallback); + Application.logMessageReceived += LogHandler; // Init dynamic tests foreach (var typeName in dynamicTestsToRun) @@ -141,7 +138,6 @@ public void Update() m_ReadyToRun = false; StartCoroutine("StateMachine"); } - LogCallbackStillRegistered(); } public void OnDestroy() @@ -158,7 +154,7 @@ public void OnDestroy() var remainingTests = m_TestsProvider.GetRemainingTests(); TestRunnerCallback.TestRunInterrupted(remainingTests.ToList()); } - Application.RegisterLogCallback(null); + Application.logMessageReceived -= LogHandler; } private void LogHandler(string condition, string stacktrace, LogType type) @@ -226,11 +222,15 @@ public IEnumerator StateMachine() { if (m_TestState == TestState.Running) { - if (m_AssertionsToCheck != null && m_AssertionsToCheck.All(a => a.checksPerformed > 0)) - { - IntegrationTest.Pass(currentTest.gameObject); - m_TestState = TestState.Success; - } + if(currentTest.ShouldSucceedOnAssertions()) + { + var assertionsToCheck = currentTest.gameObject.GetComponentsInChildren().Where(a => a.enabled).ToArray(); + if (assertionsToCheck.All(a => a.checksPerformed > 0)) + { + IntegrationTest.Pass(currentTest.gameObject); + m_TestState = TestState.Success; + } + } if (currentTest != null && Time.time > m_StartTime + currentTest.GetTimeout()) { m_TestState = TestState.Timeout; @@ -322,20 +322,12 @@ private void StartNewTest() m_TestMessages = ""; m_Stacktrace = ""; m_TestState = TestState.Running; - m_AssertionsToCheck = null; m_StartTime = Time.time; currentTest = m_TestsProvider.GetNextTest() as TestComponent; var testResult = m_ResultList.Single(result => result.TestComponent == currentTest); - if (currentTest != null && currentTest.ShouldSucceedOnAssertions()) - { - var assertionList = currentTest.gameObject.GetComponentsInChildren().Where(a => a.enabled); - if (assertionList.Any()) - m_AssertionsToCheck = assertionList.ToArray(); - } - if (currentTest != null && currentTest.IsExludedOnThisPlatform()) { m_TestState = TestState.Ignored; @@ -387,8 +379,7 @@ public static TestRunner GetTestRunner() private static GameObject Create() { var runner = new GameObject("TestRunner"); - var component = runner.AddComponent(); - component.hideFlags = HideFlags.NotEditable; + runner.AddComponent(); Debug.Log("Created Test Runner"); return runner; } @@ -411,35 +402,6 @@ private static bool IsBatchMode() #endregion - #region LogCallback check - private Application.LogCallback m_LogCallback; - private FieldInfo m_CurrentlyRegisteredLogCallback; - - public void LogCallbackStillRegistered() - { - if (Application.platform == RuntimePlatform.OSXWebPlayer - || Application.platform == RuntimePlatform.WindowsWebPlayer) - return; - if (m_CurrentlyRegisteredLogCallback == null) return; - var v = (Application.LogCallback)m_CurrentlyRegisteredLogCallback.GetValue(null); - if (v == m_LogCallback) return; - Debug.LogError("Log callback got changed. This may be caused by other tools using RegisterLogCallback."); - Application.RegisterLogCallback(m_LogCallback); - } - - private FieldInfo GetLogCallbackField() - { -#if !UNITY_METRO - var type = typeof(Application); - var f = type.GetFields(BindingFlags.Static | BindingFlags.NonPublic).Where(p => p.Name == "s_LogCallback"); - if (f.Count() != 1) return null; - return f.Single(); -#else - return null; -#endif - } - #endregion - enum TestState { Running, diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestRunnerConfigurator.cs b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestRunnerConfigurator.cs index 783c7ef..1204121 100644 --- a/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestRunnerConfigurator.cs +++ b/Assets/UnityTestTools/IntegrationTestsFramework/TestRunner/TestRunnerConfigurator.cs @@ -107,18 +107,26 @@ public static List GetAvailableNetworkIPs() return new List{IPAddress.Loopback.ToString()}; var ipList = new List(); + var allIpsList = new List(); foreach (var netInterface in NetworkInterface.GetAllNetworkInterfaces()) { if (netInterface.NetworkInterfaceType != NetworkInterfaceType.Wireless80211 && netInterface.NetworkInterfaceType != NetworkInterfaceType.Ethernet) continue; + + var ipAdresses = netInterface.GetIPProperties().UnicastAddresses + .Where(a => a.Address.AddressFamily == AddressFamily.InterNetwork); + allIpsList.AddRange(ipAdresses); + if (netInterface.OperationalStatus != OperationalStatus.Up) continue; - var ipAdresses = netInterface.GetIPProperties().UnicastAddresses - .Where(a => a.Address.AddressFamily == AddressFamily.InterNetwork); - ipList.AddRange(ipAdresses); + ipList.AddRange(ipAdresses); } + + //On Mac 10.10 all interfaces return OperationalStatus.Unknown, thus this workaround + if(!ipList.Any()) return allIpsList.Select(i => i.Address.ToString()).ToList(); + // sort ip list by their masks to predict which ip belongs to lan network ipList.Sort((ip1, ip2) => { diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeCollisionFailure.prefab b/Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeCollisionFailure.prefab index 3425eb9..d8faebf 100644 Binary files a/Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeCollisionFailure.prefab and b/Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeCollisionFailure.prefab differ diff --git a/Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeTriggerFailure.prefab b/Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeTriggerFailure.prefab index 5469913..1f929e3 100644 Binary files a/Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeTriggerFailure.prefab and b/Assets/UnityTestTools/IntegrationTestsFramework/TestingAssets/CubeTriggerFailure.prefab differ diff --git a/Assets/UnityTestTools/UnitTesting/Editor/Batch.cs b/Assets/UnityTestTools/UnitTesting/Editor/Batch.cs index 6f4b396..0235e89 100644 --- a/Assets/UnityTestTools/UnitTesting/Editor/Batch.cs +++ b/Assets/UnityTestTools/UnitTesting/Editor/Batch.cs @@ -21,6 +21,7 @@ public static partial class Batch public static void RunUnitTests() { + PlayerSettings.useMacAppStoreValidation = false; var filter = GetTestFilter(); var resultFilePath = GetParameterArgument(k_ResultFilePathParam) ?? Directory.GetCurrentDirectory(); if (Directory.Exists(resultFilePath)) diff --git a/Assets/UnityTestTools/UnitTesting/Editor/NUnit/Renderer/TestLine.cs b/Assets/UnityTestTools/UnitTesting/Editor/NUnit/Renderer/TestLine.cs index a55c357..d902039 100644 --- a/Assets/UnityTestTools/UnitTesting/Editor/NUnit/Renderer/TestLine.cs +++ b/Assets/UnityTestTools/UnitTesting/Editor/NUnit/Renderer/TestLine.cs @@ -15,6 +15,8 @@ public class TestLine : UnitTestRendererLine, IComparable protected static GUIContent s_GUIOpenInEditor = new GUIContent("Open in editor"); private readonly string m_ResultId; private readonly IList m_Categories; + + private GUIContent m_Content; public TestLine(TestMethod test, string resultId) : base(test) { @@ -29,6 +31,7 @@ public TestLine(TestMethod test, string resultId) : base(test) foreach (string category in test.Parent.Parent.Categories) c.Add(category); m_Categories = c; + m_Content = new GUIContent(m_RenderedName, null, m_FullName); } public UnitTestResult result @@ -53,16 +56,16 @@ protected override void DrawLine(bool isSelected, RenderingOptions options) : Icons.UnknownImg; if (m_Test.RunState == RunState.Ignored) icon = GuiHelper.GetIconForResult(TestResultState.Ignored); + + m_Content.image = icon; - var guiContent = new GUIContent(m_RenderedName, icon, m_FullName); - - GUILayout.Space(10); - var rect = GUILayoutUtility.GetRect(guiContent, EditorStyles.label, GUILayout.ExpandWidth(true) /*, GUILayout.MaxHeight (18)*/); + var rect = GUILayoutUtility.GetRect(m_Content, Styles.testName, GUILayout.ExpandWidth(true)); OnLeftMouseButtonClick(rect); OnContextClick(rect); - EditorGUI.LabelField(rect, guiContent, isSelected ? Styles.selectedLabel : Styles.label); + if(Event.current.type == EventType.repaint) + Styles.testName.Draw(rect, m_Content, false, false, false, isSelected); if (result.Outdated) GUI.color = tempColor; } @@ -78,11 +81,11 @@ protected internal override bool IsVisible(RenderingOptions options) return false; if (options.categories != null && options.categories.Length > 0 && !options.categories.Any(c => m_Categories.Contains(c))) return false; - if (!options.showIgnored && (m_Test.RunState == RunState.Ignored || m_Test.RunState == RunState.Skipped)) + if (!options.showIgnored && (m_Test.RunState == RunState.Ignored || (result.Executed && m_Test.RunState == RunState.Skipped))) return false; - if (!options.showFailed && (result.IsFailure || result.IsError || result.IsInconclusive)) + if (!options.showFailed && result.Executed && (result.IsFailure || result.IsError || result.IsInconclusive)) return false; - if (!options.showNotRunned && !result.Executed) + if (!options.showNotRunned && !result.Executed && !result.IsIgnored) return false; if (!options.showSucceeded && result.IsSuccess) return false; @@ -95,19 +98,21 @@ public override string GetResultText() var text = tempTest.Name; if (tempTest.Executed) text += " (" + tempTest.Duration.ToString("##0.###") + "s)"; - if (!tempTest.IsSuccess) + text += "\n"; + if (!string.IsNullOrEmpty(tempTest.Message)) { - text += "\n"; - if (!string.IsNullOrEmpty(tempTest.Message)) - { - text += "---\n"; - text += tempTest.Message.Trim(); - } - if (!string.IsNullOrEmpty(tempTest.StackTrace)) - { - var stackTrace = StackTraceFilter.Filter(tempTest.StackTrace).Trim(); - text += "\n---EXCEPTION---\n" + stackTrace; - } + text += "---\n"; + text += tempTest.Message.Trim(); + } + if (!string.IsNullOrEmpty(tempTest.Logs)) + { + text += "---Logs---\n"; + text += tempTest.Logs.Trim(); + } + if (!tempTest.IsSuccess && !string.IsNullOrEmpty(tempTest.StackTrace)) + { + var stackTrace = StackTraceFilter.Filter(tempTest.StackTrace).Trim(); + text += "\n---EXCEPTION---\n" + stackTrace; } return text.Trim(); } diff --git a/Assets/UnityTestTools/UnitTesting/Editor/NUnit/Renderer/UnitTestRendererLine.cs b/Assets/UnityTestTools/UnitTesting/Editor/NUnit/Renderer/UnitTestRendererLine.cs index a61aafb..1312a59 100644 --- a/Assets/UnityTestTools/UnitTesting/Editor/NUnit/Renderer/UnitTestRendererLine.cs +++ b/Assets/UnityTestTools/UnitTesting/Editor/NUnit/Renderer/UnitTestRendererLine.cs @@ -57,9 +57,9 @@ protected internal virtual void Render(int indend, RenderingOptions options) protected void OnSelect() { - if (!Event.current.control) SelectedLines.Clear(); + if (!Event.current.control && !Event.current.command) SelectedLines.Clear(); - if (Event.current.control && SelectedLines.Contains(this)) + if ((Event.current.control || Event.current.command) && SelectedLines.Contains(this)) SelectedLines.Remove(this); else SelectedLines.Add(this); @@ -84,6 +84,14 @@ public void RunSelectedTests() { RunTest(new TestFilter { objects = SelectedLines.Select(line => line.m_Test.TestName).ToArray() }); } + + public bool IsAnySelected + { + get + { + return SelectedLines.Count > 0; + } + } public virtual string GetResultText() { diff --git a/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/GuiHelper.cs b/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/GuiHelper.cs index 87efda5..f9c2531 100644 --- a/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/GuiHelper.cs +++ b/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/GuiHelper.cs @@ -122,7 +122,9 @@ private static SequencePoint GetSequencePointOfTest(UnitTestResult test) private static void OpenInEditorInternal(string filename, int line) { - InternalEditorUtility.OpenFileAtLineExternal(filename, line); + string assetPath = filename.Substring(Application.dataPath.Length - "Assets/".Length + 1); + var scriptAsset = AssetDatabase.LoadMainAssetAtPath(assetPath); + AssetDatabase.OpenAsset(scriptAsset, line); } public static bool GetConsoleErrorPause() diff --git a/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/NUnitExtensions.cs b/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/NUnitExtensions.cs index b653098..abf963b 100644 --- a/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/NUnitExtensions.cs +++ b/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/NUnitExtensions.cs @@ -6,16 +6,18 @@ namespace UnityTest { public static class NUnitExtensions { - public static UnitTestResult UnitTestResult(this NUnit.Core.TestResult result) + public static UnitTestResult UnitTestResult(this NUnit.Core.TestResult result, string logs) { return new UnitTestResult { Executed = result.Executed, ResultState = (TestResultState)result.ResultState, Message = result.Message, + Logs = logs, StackTrace = result.StackTrace, Duration = result.Time, Test = new UnitTestInfo(result.Test.TestName.TestID.ToString()), + IsIgnored = (result.ResultState == NUnit.Core.ResultState.Ignored) || result.Test.RunState == NUnit.Core.RunState.Ignored }; } } diff --git a/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/NUnitTestEngine.cs b/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/NUnitTestEngine.cs index 2ef800f..2ed658e 100644 --- a/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/NUnitTestEngine.cs +++ b/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/NUnitTestEngine.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; +using System.Text; using NUnit.Core; using NUnit.Core.Filters; using UnityEditor; @@ -43,7 +44,8 @@ public UnitTestRendererLine GetTests(out UnitTestResult[] results, out string[] private UnitTestRendererLine[] ParseTestList(Test test, List results, HashSet categories) { - foreach (string category in test.Categories) categories.Add(category); + foreach (string category in test.Categories) + categories.Add(category); if (test is TestMethod) { @@ -104,9 +106,11 @@ public static Assembly[] GetAssembliesWithTests() var libs = new List(); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { - if (assembly.GetReferencedAssemblies().All(a => a.Name != "nunit.framework")) continue; + if (assembly.GetReferencedAssemblies().All(a => a.Name != "nunit.framework")) + continue; if (assembly.Location.Replace('\\', '/').StartsWith(Application.dataPath) - || k_WhitelistedAssemblies.Contains(assembly.GetName().Name)) libs.Add(assembly); + || k_WhitelistedAssemblies.Contains(assembly.GetName().Name)) + libs.Add(assembly); } return libs.ToArray(); } @@ -128,6 +132,10 @@ private void ExecuteTestSuite(TestSuite suite, ITestRunnerCallback testRunnerEve eventListener = new NullListener(); else eventListener = new TestRunnerEventListener(testRunnerEventListener); + + TestExecutionContext.CurrentContext.Out = new EventListenerTextWriter(eventListener, TestOutputType.Out); + TestExecutionContext.CurrentContext.Error = new EventListenerTextWriter(eventListener, TestOutputType.Error); + suite.Run(eventListener, GetFilter(filter)); } @@ -143,10 +151,11 @@ private ITestFilter GetFilter(TestFilter filter) nUnitFilter.Add(new OrFilter(filter.objects.Where(o => o is TestName).Select(o => new NameFilter(o as TestName)).ToArray())); return nUnitFilter; } - + public class TestRunnerEventListener : EventListener { private readonly ITestRunnerCallback m_TestRunnerEventListener; + private StringBuilder m_testLog; public TestRunnerEventListener(ITestRunnerCallback testRunnerEventListener) { @@ -170,12 +179,14 @@ public void RunFinished(Exception exception) public void TestStarted(TestName testName) { + m_testLog = new StringBuilder(); m_TestRunnerEventListener.TestStarted(testName.FullName); } public void TestFinished(NUnit.Core.TestResult result) { - m_TestRunnerEventListener.TestFinished(result.UnitTestResult()); + m_TestRunnerEventListener.TestFinished(result.UnitTestResult(m_testLog.ToString())); + m_testLog = null; } public void SuiteStarted(TestName testName) @@ -192,6 +203,8 @@ public void UnhandledException(Exception exception) public void TestOutput(TestOutput testOutput) { + if (m_testLog != null) + m_testLog.AppendLine(testOutput.Text); } } } diff --git a/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/TestRunner.cs b/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/TestRunner.cs index e63c62f..d1ce5f9 100644 --- a/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/TestRunner.cs +++ b/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/TestRunner.cs @@ -12,6 +12,7 @@ public partial class UnitTestView private void UpdateTestInfo(ITestResult result) { FindTestResult(result.Id).Update(result, false); + m_FilterSettings.UpdateCounters(m_ResultList.Cast()); } private UnitTestResult FindTestResult(string resultId) @@ -28,7 +29,7 @@ private UnitTestResult FindTestResult(string resultId) private void RunTests() { var filter = new TestFilter(); - var categories = GetSelectedCategories(); + var categories = m_FilterSettings.GetSelectedCategories(); if (categories != null && categories.Length > 0) filter.categories = categories; RunTests(filter); diff --git a/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/UnitTestInfo.cs b/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/UnitTestInfo.cs index 2cc924e..5dad7e4 100644 --- a/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/UnitTestInfo.cs +++ b/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/UnitTestInfo.cs @@ -22,6 +22,7 @@ public class UnitTestInfo public string[] Categories { get; private set; } public string AssemblyPath { get; private set; } public string Id { get; private set; } + public bool IsIgnored { get; private set; } public UnitTestInfo(TestMethod testMethod) { @@ -40,6 +41,8 @@ public UnitTestInfo(TestMethod testMethod) Categories = testMethod.Categories.Cast().ToArray(); AssemblyPath = GetAssemblyPath(testMethod); + + IsIgnored = (testMethod.RunState == RunState.Ignored); } private string GetAssemblyPath(TestMethod testMethod) diff --git a/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/UnitTestResult.cs b/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/UnitTestResult.cs index 2a1308c..83b5123 100644 --- a/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/UnitTestResult.cs +++ b/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/UnitTestResult.cs @@ -16,6 +16,9 @@ public class UnitTestResult : ITestResult public double Duration { get; set; } public string Message { get; set; } public string StackTrace { get; set; } + public bool IsIgnored { get; set; } + + public string Logs { get; set; } public bool Outdated { get; set; } @@ -24,8 +27,10 @@ public void Update(ITestResult source, bool outdated) ResultState = source.ResultState; Duration = source.Duration; Message = source.Message; + Logs = source.Logs; StackTrace = source.StackTrace; Executed = source.Executed; + IsIgnored = source.IsIgnored || (Test != null && Test.IsIgnored); Outdated = outdated; } @@ -51,11 +56,6 @@ public bool IsInconclusive get { return ResultState == TestResultState.Inconclusive; } } - public bool IsIgnored - { - get { return ResultState == TestResultState.Ignored; } - } - #endregion } } diff --git a/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/UnitTestView.cs b/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/UnitTestView.cs index 692a9d9..3604370 100644 --- a/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/UnitTestView.cs +++ b/Assets/UnityTestTools/UnitTesting/Editor/TestRunner/UnitTestView.cs @@ -7,16 +7,17 @@ namespace UnityTest { [Serializable] - public partial class UnitTestView : EditorWindow + public partial class UnitTestView : EditorWindow, IHasCustomMenu { private static UnitTestView s_Instance; private static readonly IUnitTestEngine k_TestEngine = new NUnitTestEngine(); [SerializeField] private List m_ResultList = new List(); - [SerializeField] private string[] m_AvailableCategories; [SerializeField] private List m_FoldMarkers = new List(); [SerializeField] private List m_SelectedLines = new List(); UnitTestRendererLine m_TestLines; + + private TestFilterSettings m_FilterSettings; #region runner steering vars private Vector2 m_TestListScroll, m_TestInfoScroll; @@ -27,31 +28,26 @@ public partial class UnitTestView : EditorWindow private UnitTestsRunnerSettings m_Settings; #region GUI Contents - private readonly GUIContent m_GUIRunSelectedTestsIcon = new GUIContent(Icons.RunImg, "Run selected tests"); - private readonly GUIContent m_GUIRunAllTestsIcon = new GUIContent(Icons.RunAllImg, "Run all tests"); - private readonly GUIContent m_GUIRerunFailedTestsIcon = new GUIContent(Icons.RunFailedImg, "Rerun failed tests"); - private readonly GUIContent m_GUIOptionButton = new GUIContent("Options", Icons.GearImg); - private readonly GUIContent m_GUIHideButton = new GUIContent("Hide", Icons.GearImg); + private readonly GUIContent m_GUIRunSelectedTestsIcon = new GUIContent("Run Selected", "Run selected tests"); + private readonly GUIContent m_GUIRunAllTestsIcon = new GUIContent("Run All", "Run all tests"); + private readonly GUIContent m_GUIRerunFailedTestsIcon = new GUIContent("Rerun Failed", "Rerun failed tests"); private readonly GUIContent m_GUIRunOnRecompile = new GUIContent("Run on recompile", "Run all tests after recompilation"); private readonly GUIContent m_GUIShowDetailsBelowTests = new GUIContent("Show details below tests", "Show run details below test list"); private readonly GUIContent m_GUIRunTestsOnNewScene = new GUIContent("Run tests on a new scene", "Run tests on a new scene"); private readonly GUIContent m_GUIAutoSaveSceneBeforeRun = new GUIContent("Autosave scene", "The runner will automatically save the current scene changes before it starts"); - private readonly GUIContent m_GUIShowSucceededTests = new GUIContent("Succeeded", Icons.SuccessImg, "Show tests that succeeded"); - private readonly GUIContent m_GUIShowFailedTests = new GUIContent("Failed", Icons.FailImg, "Show tests that failed"); - private readonly GUIContent m_GUIShowIgnoredTests = new GUIContent("Ignored", Icons.IgnoreImg, "Show tests that are ignored"); - private readonly GUIContent m_GUIShowNotRunTests = new GUIContent("Not Run", Icons.UnknownImg, "Show tests that didn't run"); #endregion public UnitTestView() { - title = "Unit Tests Runner"; m_ResultList.Clear(); } public void OnEnable() { + title = "Unit Tests"; s_Instance = this; m_Settings = ProjectSettingsBase.Load(); + m_FilterSettings = new TestFilterSettings("UnityTest.UnitTestView"); RefreshTests(); EnableBackgroundRunner(m_Settings.runOnRecompilation); } @@ -61,58 +57,35 @@ public void OnDestroy() s_Instance = null; EnableBackgroundRunner(false); } - - public void Awake() - { - RefreshTests(); - } - + public void OnGUI() { - GUILayout.Space(10); EditorGUILayout.BeginVertical(); - EditorGUILayout.BeginHorizontal(); + EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); - var layoutOptions = new[] { GUILayout.Width(32), GUILayout.Height(24) }; - if (GUILayout.Button(m_GUIRunAllTestsIcon, Styles.buttonLeft, layoutOptions)) + if (GUILayout.Button(m_GUIRunAllTestsIcon, EditorStyles.toolbarButton)) { RunTests(); GUIUtility.ExitGUI(); } - if (GUILayout.Button(m_GUIRunSelectedTestsIcon, Styles.buttonMid, layoutOptions)) + EditorGUI.BeginDisabledGroup(!m_TestLines.IsAnySelected); + if (GUILayout.Button(m_GUIRunSelectedTestsIcon, EditorStyles.toolbarButton)) { m_TestLines.RunSelectedTests(); } - if (GUILayout.Button(m_GUIRerunFailedTestsIcon, Styles.buttonRight, layoutOptions)) + EditorGUI.EndDisabledGroup(); + if (GUILayout.Button(m_GUIRerunFailedTestsIcon, EditorStyles.toolbarButton)) { m_TestLines.RunTests(m_ResultList.Where(result => result.IsFailure || result.IsError).Select(l => l.FullName).ToArray()); } GUILayout.FlexibleSpace(); + + m_FilterSettings.OnGUI (); - if (GUILayout.Button(m_Settings.optionsFoldout ? m_GUIHideButton : m_GUIOptionButton, GUILayout.Height(24), GUILayout.Width(80))) - { - m_Settings.optionsFoldout = !m_Settings.optionsFoldout; - } - EditorGUILayout.EndHorizontal(); - - if (m_Settings.optionsFoldout) DrawOptions(); - - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.LabelField("Filter:", GUILayout.Width(35)); - m_Settings.testFilter = EditorGUILayout.TextField(m_Settings.testFilter, EditorStyles.textField); - - if (m_AvailableCategories != null && m_AvailableCategories.Length > 0) - m_Settings.categoriesMask = EditorGUILayout.MaskField(m_Settings.categoriesMask, m_AvailableCategories, GUILayout.MaxWidth(90)); - - if (GUILayout.Button(m_Settings.filtersFoldout ? "Hide" : "Advanced", GUILayout.Width(80), GUILayout.Height(15))) - m_Settings.filtersFoldout = !m_Settings.filtersFoldout; EditorGUILayout.EndHorizontal(); - if (m_Settings.filtersFoldout) - DrawFilters(); - if (m_Settings.horizontalSplit) EditorGUILayout.BeginVertical(); else @@ -129,18 +102,6 @@ public void OnGUI() EditorGUILayout.EndVertical(); } - private string[] GetSelectedCategories() - { - var selectedCategories = new List(); - foreach (var availableCategory in m_AvailableCategories) - { - var idx = Array.FindIndex(m_AvailableCategories, a => a == availableCategory); - var mask = 1 << idx; - if ((m_Settings.categoriesMask & mask) != 0) selectedCategories.Add(availableCategory); - } - return selectedCategories.ToArray(); - } - private void RenderTestList() { EditorGUILayout.BeginVertical(Styles.testList); @@ -149,15 +110,7 @@ private void RenderTestList() GUILayout.MaxWidth(2000)); if (m_TestLines != null) { - var options = new RenderingOptions(); - options.showSucceeded = m_Settings.showSucceeded; - options.showFailed = m_Settings.showFailed; - options.showIgnored = m_Settings.showIgnored; - options.showNotRunned = m_Settings.showNotRun; - options.nameFilter = m_Settings.testFilter; - options.categories = GetSelectedCategories(); - - if (m_TestLines.Render(options)) Repaint(); + if (m_TestLines.Render(m_FilterSettings.BuildRenderingOptions())) Repaint(); } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); @@ -215,44 +168,28 @@ private void RenderTestInfo() EditorGUILayout.EndScrollView(); } - - private void DrawFilters() + + private void ToggleRunOnRecompilation() { - EditorGUI.BeginChangeCheck(); - EditorGUILayout.BeginHorizontal(); - m_Settings.showSucceeded = GUILayout.Toggle(m_Settings.showSucceeded, m_GUIShowSucceededTests, GUI.skin.FindStyle(GUI.skin.button.name + "left"), GUILayout.ExpandWidth(true)); - m_Settings.showFailed = GUILayout.Toggle(m_Settings.showFailed, m_GUIShowFailedTests, GUI.skin.FindStyle(GUI.skin.button.name + "mid")); - m_Settings.showIgnored = GUILayout.Toggle(m_Settings.showIgnored, m_GUIShowIgnoredTests, GUI.skin.FindStyle(GUI.skin.button.name + "mid")); - m_Settings.showNotRun = GUILayout.Toggle(m_Settings.showNotRun, m_GUIShowNotRunTests, GUI.skin.FindStyle(GUI.skin.button.name + "right"), GUILayout.ExpandWidth(true)); - EditorGUILayout.EndHorizontal(); - if (EditorGUI.EndChangeCheck()) m_Settings.Save(); + m_Settings.runOnRecompilation = !m_Settings.runOnRecompilation; + EnableBackgroundRunner(m_Settings.runOnRecompilation); } - - private void DrawOptions() + + public void AddItemsToMenu (GenericMenu menu) { - EditorGUI.BeginChangeCheck(); - - EditorGUI.BeginChangeCheck(); - m_Settings.runOnRecompilation = EditorGUILayout.Toggle(m_GUIRunOnRecompile, m_Settings.runOnRecompilation); - if (EditorGUI.EndChangeCheck()) EnableBackgroundRunner(m_Settings.runOnRecompilation); - - m_Settings.runTestOnANewScene = EditorGUILayout.Toggle(m_GUIRunTestsOnNewScene, m_Settings.runTestOnANewScene); - EditorGUI.BeginDisabledGroup(!m_Settings.runTestOnANewScene); - m_Settings.autoSaveSceneBeforeRun = EditorGUILayout.Toggle(m_GUIAutoSaveSceneBeforeRun, m_Settings.autoSaveSceneBeforeRun); - EditorGUI.EndDisabledGroup(); - m_Settings.horizontalSplit = EditorGUILayout.Toggle(m_GUIShowDetailsBelowTests, m_Settings.horizontalSplit); - - if (EditorGUI.EndChangeCheck()) - { - m_Settings.Save(); - } - EditorGUILayout.Space(); + menu.AddItem(m_GUIRunOnRecompile, m_Settings.runOnRecompilation, ToggleRunOnRecompilation); + menu.AddItem(m_GUIRunTestsOnNewScene, m_Settings.runTestOnANewScene, m_Settings.ToggleRunTestOnANewScene); + if(!m_Settings.runTestOnANewScene) + menu.AddDisabledItem(m_GUIAutoSaveSceneBeforeRun); + else + menu.AddItem(m_GUIAutoSaveSceneBeforeRun, m_Settings.autoSaveSceneBeforeRun, m_Settings.ToggleAutoSaveSceneBeforeRun); + menu.AddItem(m_GUIShowDetailsBelowTests, m_Settings.horizontalSplit, m_Settings.ToggleHorizontalSplit); } private void RefreshTests() { UnitTestResult[] newResults; - m_TestLines = k_TestEngine.GetTests(out newResults, out m_AvailableCategories); + m_TestLines = k_TestEngine.GetTests(out newResults, out m_FilterSettings.AvailableCategories); foreach (var newResult in newResults) { @@ -267,6 +204,8 @@ private void RefreshTests() TestLine.GetUnitTestResult = FindTestResult; m_ResultList = new List(newResults); + + m_FilterSettings.UpdateCounters(m_ResultList.Cast()); Repaint(); } diff --git a/Assets/UnityTestTools/UnitTesting/Editor/UnitTestsRunnerSettings.cs b/Assets/UnityTestTools/UnitTesting/Editor/UnitTestsRunnerSettings.cs index 9c35f45..1feca66 100644 --- a/Assets/UnityTestTools/UnitTesting/Editor/UnitTestsRunnerSettings.cs +++ b/Assets/UnityTestTools/UnitTesting/Editor/UnitTestsRunnerSettings.cs @@ -4,20 +4,27 @@ namespace UnityTest { + public class UnitTestsRunnerSettings : ProjectSettingsBase { - public bool optionsFoldout; - public bool filtersFoldout; public bool runOnRecompilation; public bool horizontalSplit = true; public bool autoSaveSceneBeforeRun; public bool runTestOnANewScene; - public int categoriesMask; - public string testFilter = ""; - public bool showFailed = true; - public bool showIgnored = true; - public bool showNotRun = true; - public bool showSucceeded = true; + public void ToggleRunTestOnANewScene() { + runTestOnANewScene = !runTestOnANewScene; + Save (); + } + + public void ToggleAutoSaveSceneBeforeRun() { + autoSaveSceneBeforeRun = !autoSaveSceneBeforeRun; + Save (); + } + + public void ToggleHorizontalSplit() { + horizontalSplit = !horizontalSplit; + Save (); + } } } diff --git a/Assets/UnityTestTools/changelog.txt b/Assets/UnityTestTools/changelog.txt index 003fa31..5a9cadc 100644 --- a/Assets/UnityTestTools/changelog.txt +++ b/Assets/UnityTestTools/changelog.txt @@ -1,3 +1,35 @@ +Version 1.5 + +- Unity 5 related compatibility changes + +Version 1.4.4 + +- Minimal supported Unity version is now 4.3 +- UI changes +- code refactoring + +Version 1.4.3 + +- Remove reference to Resources.LoadAssetAtPath from runtime code + +Version 1.4.2 + +(assertion component) +- fixed string comparer bug that prevented updating the value + +(unit tests) +- unit test runner will log to stdout now +- fixes issues with opening tests in IDEs + +(integration tests) +- transform component is now visible for integration tests components +- added better support for mac's keyboard +- fixed 'succeed on assertion' for code generated assertion + +(other) +- minor bugfixes +- general improvments + Version 1.4.1 - Fixed platform compilation issues diff --git a/Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll b/Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll index 4da17a0..cc7a8bc 100644 Binary files a/Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll and b/Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll differ diff --git a/Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Messaging.dll b/Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Messaging.dll index 37693b9..9094b4b 100644 Binary files a/Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Messaging.dll and b/Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Messaging.dll differ diff --git a/Assets/UnityVS/Editor/UnityVS.VersionSpecific.dll b/Assets/UnityVS/Editor/UnityVS.VersionSpecific.dll index 3ffa426..7bdc30d 100644 Binary files a/Assets/UnityVS/Editor/UnityVS.VersionSpecific.dll and b/Assets/UnityVS/Editor/UnityVS.VersionSpecific.dll differ diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset index 9127da4..d75e792 100644 Binary files a/ProjectSettings/GraphicsSettings.asset and b/ProjectSettings/GraphicsSettings.asset differ diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 74de96c..e25dd91 100644 Binary files a/ProjectSettings/ProjectSettings.asset and b/ProjectSettings/ProjectSettings.asset differ diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 137b53a..b0ac510 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 5.0.0b20 +m_EditorVersion: 5.0.0f4 m_StandardAssetsVersion: 0 diff --git a/UnityVS.LINQ to GameObject.CSharp.Editor.csproj b/UnityVS.LINQ to GameObject.CSharp.Editor.csproj new file mode 100644 index 0000000..c4c0a11 --- /dev/null +++ b/UnityVS.LINQ to GameObject.CSharp.Editor.csproj @@ -0,0 +1,199 @@ + + + + Debug + AnyCPU + 10.0.20506 + 2.0 + {69B76BE8-A990-936D-D794-035855292087} + Library + + Assembly-CSharp-Editor + 512 + {E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + .NETFramework + v3.5 + Unity Full v3.5 + + Editor:5 + StandaloneWindows:5 + 5.0.0f4 + + + pdbonly + false + Temp\UnityVS_bin\Debug\ + prompt + 4 + DEBUG;TRACE;UNITY_5_0_0;UNITY_5_0;UNITY_5;ENABLE_LICENSE_RENAME;ENABLE_NEW_BUGREPORTER;ENABLE_2D_PHYSICS;ENABLE_4_6_FEATURES;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_NEW_HIERARCHY;ENABLE_PHYSICS;ENABLE_PHYSICS_PHYSX3;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_UNITYEVENTS;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_AUDIOMIXER_SUSPEND;ENABLE_NONPRO;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_MONO;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE + + + pdbonly + false + Temp\UnityVS_bin\Release\ + prompt + 4 + TRACE;UNITY_5_0_0;UNITY_5_0;UNITY_5;ENABLE_LICENSE_RENAME;ENABLE_NEW_BUGREPORTER;ENABLE_2D_PHYSICS;ENABLE_4_6_FEATURES;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_NEW_HIERARCHY;ENABLE_PHYSICS;ENABLE_PHYSICS_PHYSX3;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_UNITYEVENTS;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_AUDIOMIXER_SUSPEND;ENABLE_NONPRO;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_MONO;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE + + + + + + + + + + Library\UnityAssemblies\UnityEngine.dll + + + Library\UnityAssemblies\UnityEditor.dll + + + + Library\UnityAssemblies\UnityEngine.UI.dll + + + Library\UnityAssemblies\UnityEditor.Graphs.dll + + + Library\UnityAssemblies\UnityEditor.Android.Extensions.dll + + + Library\UnityAssemblies\UnityEditor.iOS.Extensions.dll + + + Library\UnityAssemblies\UnityEditor.WP8.Extensions.dll + + + Library\UnityAssemblies\UnityEditor.Metro.Extensions.dll + + + Library\UnityAssemblies\UnityEditor.BB10.Extensions.dll + + + Library\UnityAssemblies\UnityEditor.WebGL.Extensions.dll + + + Library\UnityAssemblies\UnityEditor.LinuxStandalone.Extensions.dll + + + Library\UnityAssemblies\UnityEditor.WindowsStandalone.Extensions.dll + + + Library\UnityAssemblies\UnityEditor.OSXStandalone.Extensions.dll + + + Assets\UnityTestTools\UnitTesting\Editor\NSubstitute\NSubstitute.dll + + + Assets\UnityTestTools\UnitTesting\Editor\NUnit\Libs\Mono.Cecil.dll + + + Assets\UnityTestTools\UnitTesting\Editor\NUnit\Libs\Mono.Cecil.Mdb.dll + + + Assets\UnityTestTools\UnitTesting\Editor\NUnit\Libs\nunit.core.dll + + + Assets\UnityTestTools\UnitTesting\Editor\NUnit\Libs\nunit.core.interfaces.dll + + + Assets\UnityTestTools\UnitTesting\Editor\NUnit\Libs\nunit.framework.dll + + + Assets\UnityVS\Editor\SyntaxTree.VisualStudio.Unity.Bridge.dll + + + Assets\UnityVS\Editor\SyntaxTree.VisualStudio.Unity.Messaging.dll + + + Assets\UnityVS\Editor\UnityVS.VersionSpecific.dll + + + Library\ScriptAssemblies\Assembly-UnityScript.dll + + + + + {B7DF533E-748F-8388-4A2F-2CE669586F33} + UnityVS.LINQ to GameObject.CSharp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/UnityVS.LINQ to GameObject.CSharp.csproj b/UnityVS.LINQ to GameObject.CSharp.csproj new file mode 100644 index 0000000..1f72a35 --- /dev/null +++ b/UnityVS.LINQ to GameObject.CSharp.csproj @@ -0,0 +1,126 @@ + + + + Debug + AnyCPU + 10.0.20506 + 2.0 + {B7DF533E-748F-8388-4A2F-2CE669586F33} + Library + + Assembly-CSharp + 512 + {E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + .NETFramework + v3.5 + Unity Subset v3.5 + + Game:1 + StandaloneWindows:5 + 5.0.0f4 + + + pdbonly + false + Temp\UnityVS_bin\Debug\ + prompt + 4 + DEBUG;TRACE;UNITY_5_0_0;UNITY_5_0;UNITY_5;ENABLE_LICENSE_RENAME;ENABLE_NEW_BUGREPORTER;ENABLE_2D_PHYSICS;ENABLE_4_6_FEATURES;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_NEW_HIERARCHY;ENABLE_PHYSICS;ENABLE_PHYSICS_PHYSX3;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_UNITYEVENTS;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_AUDIOMIXER_SUSPEND;ENABLE_NONPRO;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_MONO;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE + + + pdbonly + false + Temp\UnityVS_bin\Release\ + prompt + 4 + TRACE;UNITY_5_0_0;UNITY_5_0;UNITY_5;ENABLE_LICENSE_RENAME;ENABLE_NEW_BUGREPORTER;ENABLE_2D_PHYSICS;ENABLE_4_6_FEATURES;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_NEW_HIERARCHY;ENABLE_PHYSICS;ENABLE_PHYSICS_PHYSX3;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_UNITYEVENTS;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_AUDIOMIXER_SUSPEND;ENABLE_NONPRO;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_MONO;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE + + + + + + + + + + Library\UnityAssemblies\UnityEngine.dll + + + Library\UnityAssemblies\UnityEditor.dll + + + + Library\UnityAssemblies\UnityEngine.UI.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/UnityVS.LINQ to GameObject.sln b/UnityVS.LINQ to GameObject.sln new file mode 100644 index 0000000..736e4e8 --- /dev/null +++ b/UnityVS.LINQ to GameObject.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2015 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityVS.LINQ to GameObject.CSharp.Editor", "UnityVS.LINQ to GameObject.CSharp.Editor.csproj", "{69B76BE8-A990-936D-D794-035855292087}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityVS.LINQ to GameObject.CSharp", "UnityVS.LINQ to GameObject.CSharp.csproj", "{B7DF533E-748F-8388-4A2F-2CE669586F33}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {69B76BE8-A990-936D-D794-035855292087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {69B76BE8-A990-936D-D794-035855292087}.Debug|Any CPU.Build.0 = Debug|Any CPU + {69B76BE8-A990-936D-D794-035855292087}.Release|Any CPU.ActiveCfg = Release|Any CPU + {69B76BE8-A990-936D-D794-035855292087}.Release|Any CPU.Build.0 = Release|Any CPU + {B7DF533E-748F-8388-4A2F-2CE669586F33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B7DF533E-748F-8388-4A2F-2CE669586F33}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B7DF533E-748F-8388-4A2F-2CE669586F33}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B7DF533E-748F-8388-4A2F-2CE669586F33}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal