kiltec

InputSystemExtension.cs

Feb 10th, 2023 (edited)
1,041
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | Gaming | 0 0
  1. #if UNITY_EDITOR
  2.  
  3. using UnityEditor;
  4. using UnityEngine;
  5.  
  6. public static class InputSystemExtension
  7. {
  8.     public static bool CheckForInputSystemAsset()
  9.     {
  10.         bool inputSystemAssetFound;
  11.         string[] assets = AssetDatabase.FindAssets("t:ScriptableObject InputSettings");
  12.  
  13.         if (assets.Length > 0)
  14.         {
  15.             inputSystemAssetFound = true;
  16.             Debug.Log("Input System Asset found.");
  17.         }
  18.         else
  19.         {
  20.             inputSystemAssetFound = false;
  21.             Debug.Log("No Input System Assets found.");
  22.         }
  23.  
  24.         return inputSystemAssetFound;
  25.     }
  26.  
  27.     public static bool CheckForInputSystem()
  28.     {
  29.         var inputSystemPackageInstalled = false;
  30.         var inputSystemPackage = UnityEditor.PackageManager.PackageInfo.GetAllRegisteredPackages();
  31.         var length = inputSystemPackage.Length;
  32.        
  33.         for (int i = 0; i < length; i++)
  34.         {
  35.             if (inputSystemPackage[i].name == "com.unity.inputsystem")
  36.             {
  37.                 inputSystemPackageInstalled = true;
  38.             }
  39.         }
  40.  
  41.         if (inputSystemPackageInstalled) { Debug.Log("Input System package is installed"); }
  42.         else { Debug.Log("Input System package is not installed"); }
  43.  
  44.         return inputSystemPackageInstalled;
  45.     }
  46. }
  47.  
  48. #endif
Advertisement
Add Comment
Please, Sign In to add comment