Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Fluctio.FluctioSim.EditorCore.Dependencies.DependencyTypes;
using Fluctio.FluctioSim.EditorUtils.EditorGeneral;
using UnityEditor;

namespace Fluctio.FluctioSim.EditorCore.Dependencies
{
	// TODO: auto-update some dependencies when this package itself updates?
	public static class DependencyCheck
	{
		private static readonly TimeSpan LoadingCheckInterval = TimeSpan.FromSeconds(0.5);
		
		public static readonly List<IDependency> Dependencies = new()
		{
			// TODO: add dependency on git?
			new PackageDependency("ML Agents", "com.unity.ml-agents"),
			new PackageDependency("MuJoCo", "org.mujoco.mujoco"),
			new MujocoBinaryDependency(),
			new ConfigurationDependency(),
			new PythonDependency(),
			new PythonVenvDependency(),
		};

		private static bool IsAnyDependency(DependencyStateType stateType)
		{
			return Dependencies.Any(dependency => dependency.GetState().StateType == stateType);
		}

		[InitializeOnLoadMethod]
		private static void Init()
		{
			if (!EditorUtil.DidEditorJustOpen)
			{
				return;
			}
			EditorApplication.delayCall += DelayedInit;
		}

		private static async void DelayedInit()
		{
			while (IsAnyDependency(DependencyStateType.Loading) && !IsAnyDependency(DependencyStateType.Problem))
			{
				await Task.Delay(LoadingCheckInterval);
			}
			if (IsAnyDependency(DependencyStateType.Problem))
			{
				EditorWindow.GetWindow<DependencyWindow>();
			}
		}
	}
}