基础内容
必要插件安装 缓动曲线和动画基础 ElementFolder,Track与其次级模块,PathNode重构
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
namespace MoreMountains.Feedbacks
|
||||
{
|
||||
/// <summary>
|
||||
/// A class handling the lifecycle of the balls included in the MMFeedbacks demo
|
||||
/// It waits for 2 seconds after the spawn of the ball, and destroys it, playing a MMFeedbacks while it does so
|
||||
/// </summary>
|
||||
[AddComponentMenu("")]
|
||||
public class DemoBall : MonoBehaviour
|
||||
{
|
||||
/// the duration (in seconds) of the life of the ball
|
||||
public float LifeSpan = 2f;
|
||||
/// the feedback to play when the ball dies
|
||||
public MMFeedbacks DeathFeedback;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// On start, we trigger the programmed death of the ball
|
||||
/// </summary>
|
||||
protected virtual void Start()
|
||||
{
|
||||
StartCoroutine(ProgrammedDeath());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Waits for 2 seconds, then kills the ball object after having played the MMFeedbacks
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected virtual IEnumerator ProgrammedDeath()
|
||||
{
|
||||
yield return MMCoroutine.WaitFor(LifeSpan);
|
||||
DeathFeedback?.PlayFeedbacks();
|
||||
this.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af269cd09768709469620a982332135d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
#if MM_UI
|
||||
using UnityEngine.UI;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEditor.Events;
|
||||
#endif
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
namespace MoreMountains.Feedbacks
|
||||
{
|
||||
/// <summary>
|
||||
/// A simple class used to handle demo buttons in the MMF_PlayerDemo and MMFeedbacksDemo scenes
|
||||
/// </summary>
|
||||
[ExecuteAlways]
|
||||
[AddComponentMenu("")]
|
||||
public class DemoButton : MonoBehaviour
|
||||
{
|
||||
[Header("Behaviour")]
|
||||
public bool NotSupportedInWebGL = false;
|
||||
|
||||
[Header("Bindings")]
|
||||
public Button TargetButton;
|
||||
public Text ButtonText;
|
||||
public Text WebGL;
|
||||
public MMF_Player TargetMMF_Player;
|
||||
|
||||
protected Color _disabledColor = new Color(255, 255, 255, 0.5f);
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
HandleWebGL();
|
||||
TargetButton.onClick.AddListener(OnClickEvent);
|
||||
}
|
||||
|
||||
protected void OnDisable()
|
||||
{
|
||||
TargetButton.onClick.RemoveListener(OnClickEvent);
|
||||
}
|
||||
|
||||
public void OnClickEvent()
|
||||
{
|
||||
TargetMMF_Player?.PlayFeedbacks();
|
||||
}
|
||||
|
||||
protected virtual void HandleWebGL()
|
||||
{
|
||||
if (WebGL != null)
|
||||
{
|
||||
#if UNITY_WEBGL
|
||||
TargetButton.interactable = !NotSupportedInWebGL;
|
||||
WebGL.gameObject.SetActive(NotSupportedInWebGL);
|
||||
ButtonText.color = NotSupportedInWebGL ? _disabledColor : Color.white;
|
||||
#else
|
||||
WebGL.gameObject.SetActive(false);
|
||||
TargetButton.interactable = true;
|
||||
ButtonText.color = Color.white;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df25bf84edad1d74684be3596d8f570d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MoreMountains.Feedbacks
|
||||
{
|
||||
/// <summary>
|
||||
/// A class used on the MMFeedback's demo ghost
|
||||
/// </summary>
|
||||
[AddComponentMenu("")]
|
||||
public class DemoGhost : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Called via animation event, disables the object
|
||||
/// </summary>
|
||||
public virtual void OnAnimationEnd()
|
||||
{
|
||||
this.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69c5c5e06e4b97d419ad1fd8c422c7b6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,101 @@
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace MoreMountains.Feedbacks
|
||||
{
|
||||
/// <summary>
|
||||
/// This class, meant to be used in MMFeedbacks demos, will check for requirements, and output an
|
||||
/// error message if necessary.
|
||||
/// </summary>
|
||||
[AddComponentMenu("")]
|
||||
public class DemoPackageTester : MonoBehaviour
|
||||
{
|
||||
[MMFInformation("This component is only used to display an error in the console in case dependencies for this demo haven't been installed. You can safely remove it if you want, and typically you wouldn't want to keep that in your own game.", MMFInformationAttribute.InformationType.Warning, false)]
|
||||
/// does the scene require post processing to be installed?
|
||||
public bool RequiresPostProcessing;
|
||||
/// does the scene require TextMesh Pro to be installed?
|
||||
public bool RequiresTMP;
|
||||
/// does the scene require Cinemachine to be installed?
|
||||
public bool RequiresCinemachine;
|
||||
|
||||
/// <summary>
|
||||
/// On Awake we test for dependencies
|
||||
/// </summary>
|
||||
protected virtual void Awake()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
TestForDependencies();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether or not dependencies have been correctly installed
|
||||
/// </summary>
|
||||
protected virtual void TestForDependencies()
|
||||
{
|
||||
bool missingDependencies = false;
|
||||
string missingString = "";
|
||||
bool cinemachineFound = false;
|
||||
bool tmpFound = false;
|
||||
bool postProcessingFound = false;
|
||||
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
cinemachineFound = true;
|
||||
#endif
|
||||
|
||||
#if (MM_TEXTMESHPRO || MM_UGUI2)
|
||||
tmpFound = true;
|
||||
#endif
|
||||
|
||||
#if MM_POSTPROCESSING
|
||||
postProcessingFound = true;
|
||||
#endif
|
||||
|
||||
if (missingDependencies)
|
||||
{
|
||||
// we do nothing but without that we get an annoying warning so here we are.
|
||||
}
|
||||
|
||||
if (RequiresCinemachine && !cinemachineFound)
|
||||
{
|
||||
missingDependencies = true;
|
||||
missingString += "Cinemachine";
|
||||
}
|
||||
|
||||
if (RequiresTMP && !tmpFound)
|
||||
{
|
||||
missingDependencies = true;
|
||||
if (missingString != "") { missingString += ", "; }
|
||||
missingString += "TextMeshPro";
|
||||
}
|
||||
|
||||
if (RequiresPostProcessing && !postProcessingFound)
|
||||
{
|
||||
missingDependencies = true;
|
||||
if (missingString != "") { missingString += ", "; }
|
||||
missingString += "PostProcessing";
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (missingDependencies)
|
||||
{
|
||||
Debug.LogError("[DemoPackageTester] It looks like you're missing some dependencies required by this demo ("+missingString+")." +
|
||||
" You'll have to install them to run this demo. You can learn more about how to do so in the documentation, at http://feel-docs.moremountains.com/how-to-install.html" +
|
||||
"\n\n");
|
||||
|
||||
if (EditorUtility.DisplayDialog("Missing dependencies!",
|
||||
"This demo requires a few dependencies to be installed first (Cinemachine, TextMesh Pro, PostProcessing).\n\n" +
|
||||
"You can use Feel without them of course, but this demo needs them to work (check out the documentation to learn more!).\n\n" +
|
||||
"Would you like to automatically install them?", "Yes, install dependencies", "No"))
|
||||
{
|
||||
MMFDependencyInstaller.InstallFromPlay();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ac950cd485569740affc32a280665ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,154 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEditor.PackageManager.Requests;
|
||||
using UnityEditor.PackageManager;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
using System.Threading.Tasks;
|
||||
using MoreMountains.Tools;
|
||||
|
||||
namespace MoreMountains.Feedbacks
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is used to automatically install optional dependencies used in MMFeedbacks
|
||||
/// </summary>
|
||||
public static class MMFDependencyInstaller
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
static ListRequest _listRequest;
|
||||
static AddRequest _addRequest;
|
||||
static int _currentIndex;
|
||||
|
||||
private static string[] _packages = new string[]
|
||||
{"com.unity.cinemachine",
|
||||
"com.unity.postprocessing",
|
||||
"com.unity.textmeshpro",
|
||||
"com.unity.2d.animation"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Installs all dependencies listed in _packages
|
||||
/// </summary>
|
||||
[MenuItem("Tools/More Mountains/MMFeedbacks/Install All Dependencies", false, 703)]
|
||||
public static void InstallAllDependencies()
|
||||
{
|
||||
_currentIndex = 0;
|
||||
_listRequest = null;
|
||||
_addRequest = null;
|
||||
|
||||
MMDebug.DebugLogInfo("[MMFDependencyInstaller] Installation start");
|
||||
_listRequest = Client.List();
|
||||
|
||||
EditorApplication.update += ListProgress;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Installs all dependencies, use this when calling from a running application
|
||||
/// </summary>
|
||||
public async static void InstallFromPlay()
|
||||
{
|
||||
EditorApplication.ExitPlaymode();
|
||||
while (Application.isPlaying)
|
||||
{
|
||||
await Task.Delay(500);
|
||||
}
|
||||
await Task.Delay(500);
|
||||
|
||||
ClearConsole();
|
||||
|
||||
await Task.Delay(500);
|
||||
InstallAllDependencies();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the console. Why isn't this a built-in one liner? Who knows.
|
||||
/// </summary>
|
||||
public static void ClearConsole()
|
||||
{
|
||||
var logEntries = System.Type.GetType("UnityEditor.LogEntries, UnityEditor.dll");
|
||||
if (logEntries != null)
|
||||
{
|
||||
var clearMethod = logEntries.GetMethod("Clear", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
|
||||
if (clearMethod != null)
|
||||
{
|
||||
clearMethod.Invoke(null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Proceeds to install the next package in line
|
||||
/// </summary>
|
||||
static void InstallNext()
|
||||
{
|
||||
if (_currentIndex < _packages.Length)
|
||||
{
|
||||
bool packageFound = false;
|
||||
foreach (var package in _listRequest.Result)
|
||||
{
|
||||
if (package.name == _packages[_currentIndex])
|
||||
{
|
||||
packageFound = true;
|
||||
MMDebug.DebugLogInfo("[MMFDependencyInstaller] "+package.name+" is already installed");
|
||||
_currentIndex++;
|
||||
InstallNext();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!packageFound)
|
||||
{
|
||||
MMDebug.DebugLogInfo("[MMFDependencyInstaller] installing "+_packages[_currentIndex]);
|
||||
_addRequest = Client.Add(_packages[_currentIndex]);
|
||||
EditorApplication.update += AddProgress;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MMDebug.DebugLogInfo("[MMFDependencyInstaller] Installation complete");
|
||||
MMDebug.DebugLogInfo("[MMFDependencyInstaller] It's recommended to now close that scene and reopen it before playing it.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the list request
|
||||
/// </summary>
|
||||
static void ListProgress()
|
||||
{
|
||||
if (_listRequest.IsCompleted)
|
||||
{
|
||||
EditorApplication.update -= ListProgress;
|
||||
if (_listRequest.Status == StatusCode.Success)
|
||||
{
|
||||
InstallNext();
|
||||
}
|
||||
else if (_listRequest.Status >= StatusCode.Failure)
|
||||
{
|
||||
MMDebug.DebugLogInfo(_listRequest.Error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes add requests
|
||||
/// </summary>
|
||||
static void AddProgress()
|
||||
{
|
||||
if (_addRequest.IsCompleted)
|
||||
{
|
||||
if (_addRequest.Status == StatusCode.Success)
|
||||
{
|
||||
MMDebug.DebugLogInfo("[MMFDependencyInstaller] "+_addRequest.Result.packageId+" has been installed");
|
||||
_currentIndex++;
|
||||
InstallNext();
|
||||
}
|
||||
else if (_addRequest.Status >= StatusCode.Failure)
|
||||
{
|
||||
MMDebug.DebugLogInfo(_addRequest.Error.message);
|
||||
}
|
||||
EditorApplication.update -= AddProgress;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f486667260dbdcb4cadd460c2fd25885
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user