DummyLoader.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using UnityEngine.Rendering;
  2. using System.Collections.Generic;
  3. using System.Runtime.CompilerServices;
  4. [assembly: InternalsVisibleTo("Unity.XR.Management.EditorTests")]
  5. namespace UnityEngine.XR.Management.Tests
  6. {
  7. internal class DummyLoader : XRLoader
  8. {
  9. public bool shouldFail = false;
  10. public int id;
  11. public GraphicsDeviceType supportedDeviceType = GraphicsDeviceType.Null;
  12. public DummyLoader()
  13. {
  14. }
  15. public override bool Initialize()
  16. {
  17. return !shouldFail;
  18. }
  19. public override T GetLoadedSubsystem<T>()
  20. {
  21. return default(T);
  22. }
  23. public override List<GraphicsDeviceType> GetSupportedGraphicsDeviceTypes(bool buildingPlayer)
  24. {
  25. if (supportedDeviceType == GraphicsDeviceType.Null)
  26. {
  27. return new List<GraphicsDeviceType>();
  28. }
  29. return new List<GraphicsDeviceType>() { supportedDeviceType };
  30. }
  31. protected bool Equals(DummyLoader other)
  32. {
  33. return base.Equals(other) && shouldFail == other.shouldFail && id == other.id;
  34. }
  35. public override bool Equals(object obj)
  36. {
  37. if (ReferenceEquals(null, obj)) return false;
  38. if (ReferenceEquals(this, obj)) return true;
  39. if (obj.GetType() != this.GetType()) return false;
  40. return Equals((DummyLoader)obj);
  41. }
  42. public override int GetHashCode()
  43. {
  44. unchecked
  45. {
  46. int hashCode = base.GetHashCode();
  47. hashCode = (hashCode * 397) ^ shouldFail.GetHashCode();
  48. hashCode = (hashCode * 397) ^ id;
  49. return hashCode;
  50. }
  51. }
  52. }
  53. }