Reputation: 358
I'm creating a module that looks for a text field in scene. if TextMeshPro is installed it looks for it, and if not, look for regular textfield/text mesh
the question is: how can I condition (pseudo code)
if(textMeshProExists)
Look for A
else
Look for B
Upvotes: 1
Views: 3833
Reputation: 156
a asmdef file can help this.
Add one Version Defines, PACKAGE_ADDRESSABLES.
you can use it in your code.
Upvotes: 1
Reputation: 10137
You can use the Package Manager scripting API to interact with the Package Manager programmatically.
Browsing the list of packages in a Project:
using System;
using UnityEditor;
using UnityEditor.PackageManager.Requests;
using UnityEditor.PackageManager;
using UnityEngine;
namespace Unity.Editor.Example {
static class ListPackageExample
{
static ListRequest Request;
[MenuItem("Window/List Package Example")]
static void List()
{
Request = Client.List(); // List packages installed for the Project
EditorApplication.update += Progress;
}
static void Progress()
{
if (Request.IsCompleted)
{
if (Request.Status == StatusCode.Success)
foreach (var package in Request.Result)
Debug.Log("Package name: " + package.name);
else if (Request.Status >= StatusCode.Failure)
Debug.Log(Request.Error.message);
EditorApplication.update -= Progress;
}
}
}
}
Upvotes: 5