/// ---------------------------------------------
/// Opsive Shared
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.Shared.Editor.Import
{
using System;
using UnityEditor;
using UnityEngine;
using UnityEngine.Serialization;
///
/// Small ScriptableObject which shows the import window if it has not been shown.
///
public class ImportStatus : ScriptableObject
{
[Tooltip("Has the Character Controller Update Project Settings window been shown?")]
[SerializeField] protected bool m_CharacterProjectSettingsShown;
[Tooltip("Has the Behavior Designer Welcome window been shown?")]
[SerializeField] protected bool m_BehaviorWindowShown;
[Tooltip("Has the State Designer Welcome window been shown?")]
[SerializeField] protected bool m_StateWindowShown;
[Tooltip("Package names whose startup window has already been shown.")]
[FormerlySerializedAs("m_InitializedPackageNames")]
[SerializeField] protected string[] m_StartupWindowShownPackageNames;
///
/// Gets or sets whether the Character Controller project settings window has been shown.
///
public bool CharacterProjectSettingsShown { get { return m_CharacterProjectSettingsShown; } set { m_CharacterProjectSettingsShown = value; } }
///
/// Gets or sets whether the Behavior Designer welcome window has been shown.
///
public bool BehaviorWindowShown { get { return m_BehaviorWindowShown; } set { m_BehaviorWindowShown = value; } }
///
/// Gets the package names whose startup window has already been shown.
///
public string[] StartupWindowShownPackageNames { get { return m_StartupWindowShownPackageNames ?? Array.Empty(); } }
///
/// Returns true if the specified package name has already had its startup window shown.
///
/// The package name to check.
/// True if the package name is already tracked.
public bool ContainsStartupWindowShownPackage(string packageName)
{
if (string.IsNullOrEmpty(packageName) || m_StartupWindowShownPackageNames == null) {
return false;
}
return Array.IndexOf(m_StartupWindowShownPackageNames, packageName) != -1;
}
///
/// Adds the specified package name to the tracked startup-window list if it is not already present.
///
/// The package name to add.
/// True if the package name was added.
public bool AddStartupWindowShownPackage(string packageName)
{
if (string.IsNullOrEmpty(packageName) || ContainsStartupWindowShownPackage(packageName)) {
return false;
}
if (m_StartupWindowShownPackageNames == null) {
m_StartupWindowShownPackageNames = new[] { packageName };
} else {
var packageNames = new string[m_StartupWindowShownPackageNames.Length + 1];
Array.Copy(m_StartupWindowShownPackageNames, packageNames, m_StartupWindowShownPackageNames.Length);
packageNames[m_StartupWindowShownPackageNames.Length] = packageName;
m_StartupWindowShownPackageNames = packageNames;
}
EditorUtility.SetDirty(this);
return true;
}
}
}