Insanely huge initial commit

This commit is contained in:
2026-02-21 16:40:15 -08:00
parent 208d626100
commit f74c547a13
33825 changed files with 5213498 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b062a1793c8d8ec448d1cb2594114352
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,72 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Tools
{
/// <summary>
/// Actions are behaviours and describe what your character is doing. Examples include patrolling, shooting, jumping, etc.
/// </summary>
public abstract class AIAction : MonoBehaviour
{
public enum InitializationModes { EveryTime, OnlyOnce, }
public InitializationModes InitializationMode;
protected bool _initialized;
/// a label you can set to organize your AI Actions, not used by anything else
[Tooltip("a label you can set to organize your AI Actions, not used by anything else")]
public string Label;
public abstract void PerformAction();
public virtual bool ActionInProgress { get; set; }
protected AIBrain _brain;
protected virtual bool ShouldInitialize
{
get
{
switch (InitializationMode)
{
case InitializationModes.EveryTime:
return true;
case InitializationModes.OnlyOnce:
return _initialized == false;
}
return true;
}
}
/// <summary>
/// On Awake we grab our AIBrain
/// </summary>
protected virtual void Awake()
{
_brain = this.gameObject.GetComponentInParent<AIBrain>();
}
/// <summary>
/// Initializes the action. Meant to be overridden
/// </summary>
public virtual void Initialization()
{
_initialized = true;
}
/// <summary>
/// Describes what happens when the brain enters the state this action is in. Meant to be overridden.
/// </summary>
public virtual void OnEnterState()
{
ActionInProgress = true;
}
/// <summary>
/// Describes what happens when the brain exits the state this action is in. Meant to be overridden.
/// </summary>
public virtual void OnExitState()
{
ActionInProgress = false;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4d7020c7ee7492e40848350adbd515be
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,262 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;
namespace MoreMountains.Tools
{
/// <summary>
/// the AI brain is responsible from going from one state to the other based on the defined transitions. It's basically just a collection of states, and it's where you'll link all the actions, decisions, states and transitions together.
/// </summary>
[AddComponentMenu("More Mountains/Tools/AI/AIBrain")]
public class AIBrain : MonoBehaviour
{
[Header("Debug")]
/// the owner of that AI Brain, usually the associated character
[MMReadOnly]
public GameObject Owner;
/// the collection of states
public List<AIState> States;
/// this brain's current state
public virtual AIState CurrentState { get; protected set; }
/// the time we've spent in the current state
[MMReadOnly]
public float TimeInThisState;
/// the current target
[MMReadOnly]
public Transform Target;
/// the last known world position of the target
[MMReadOnly]
public Vector3 _lastKnownTargetPosition = Vector3.zero;
[Header("State")]
/// whether or not this brain is active
public bool BrainActive = true;
public bool ResetBrainOnStart = true;
public bool ResetBrainOnEnable = false;
[Header("Frequencies")]
/// the frequency (in seconds) at which to perform actions (lower values : higher frequency, high values : lower frequency but better performance)
public float ActionsFrequency = 0f;
/// the frequency (in seconds) at which to evaluate decisions
public float DecisionFrequency = 0f;
/// whether or not to randomize the action and decision frequencies
public bool RandomizeFrequencies = false;
/// the min and max values between which to randomize the action frequency
[MMVector("min","max")]
public Vector2 RandomActionFrequency = new Vector2(0.5f, 1f);
/// the min and max values between which to randomize the decision frequency
[MMVector("min","max")]
public Vector2 RandomDecisionFrequency = new Vector2(0.5f, 1f);
protected AIDecision[] _decisions;
protected AIAction[] _actions;
protected float _lastActionsUpdate = 0f;
protected float _lastDecisionsUpdate = 0f;
protected AIState _initialState;
public virtual AIAction[] GetAttachedActions()
{
AIAction[] actions = this.gameObject.GetComponentsInChildren<AIAction>();
return actions;
}
public virtual AIDecision[] GetAttachedDecisions()
{
AIDecision[] decisions = this.gameObject.GetComponentsInChildren<AIDecision>();
return decisions;
}
protected virtual void OnEnable()
{
if (ResetBrainOnEnable)
{
ResetBrain();
}
}
/// <summary>
/// On awake we set our brain for all states
/// </summary>
protected virtual void Awake()
{
foreach (AIState state in States)
{
state.SetBrain(this);
}
_decisions = GetAttachedDecisions();
_actions = GetAttachedActions();
if (RandomizeFrequencies)
{
ActionsFrequency = Random.Range(RandomActionFrequency.x, RandomActionFrequency.y);
DecisionFrequency = Random.Range(RandomDecisionFrequency.x, RandomDecisionFrequency.y);
}
}
/// <summary>
/// On Start we set our first state
/// </summary>
protected virtual void Start()
{
if (ResetBrainOnStart)
{
ResetBrain();
}
}
/// <summary>
/// Every frame we update our current state
/// </summary>
protected virtual void Update()
{
if (!BrainActive || (CurrentState == null) || (Time.timeScale == 0f))
{
return;
}
if (Time.time - _lastActionsUpdate > ActionsFrequency)
{
CurrentState.PerformActions();
_lastActionsUpdate = Time.time;
}
if (!BrainActive)
{
return;
}
if (Time.time - _lastDecisionsUpdate > DecisionFrequency)
{
CurrentState.EvaluateTransitions();
_lastDecisionsUpdate = Time.time;
}
TimeInThisState += Time.deltaTime;
StoreLastKnownPosition();
}
/// <summary>
/// Transitions to the specified state, trigger exit and enter states events
/// </summary>
/// <param name="newStateName"></param>
public virtual void TransitionToState(string newStateName)
{
if (CurrentState == null)
{
CurrentState = FindState(newStateName);
if (CurrentState != null)
{
CurrentState.EnterState();
}
return;
}
if (newStateName != CurrentState.StateName)
{
CurrentState.ExitState();
OnExitState();
CurrentState = FindState(newStateName);
if (CurrentState != null)
{
CurrentState.EnterState();
}
}
}
/// <summary>
/// When exiting a state we reset our time counter
/// </summary>
protected virtual void OnExitState()
{
TimeInThisState = 0f;
}
/// <summary>
/// Initializes all decisions
/// </summary>
protected virtual void InitializeDecisions()
{
if (_decisions == null)
{
_decisions = GetAttachedDecisions();
}
foreach(AIDecision decision in _decisions)
{
decision.Initialization();
}
}
/// <summary>
/// Initializes all actions
/// </summary>
protected virtual void InitializeActions()
{
if (_actions == null)
{
_actions = GetAttachedActions();
}
foreach(AIAction action in _actions)
{
action.Initialization();
}
}
/// <summary>
/// Returns a state based on the specified state name
/// </summary>
/// <param name="stateName"></param>
/// <returns></returns>
protected AIState FindState(string stateName)
{
foreach (AIState state in States)
{
if (state.StateName == stateName)
{
return state;
}
}
if (stateName != "")
{
Debug.LogError("You're trying to transition to state '" + stateName + "' in " + this.gameObject.name + "'s AI Brain, but no state of this name exists. Make sure your states are named properly, and that your transitions states match existing states.");
}
return null;
}
/// <summary>
/// Stores the last known position of the target
/// </summary>
protected virtual void StoreLastKnownPosition()
{
if (Target != null)
{
_lastKnownTargetPosition = Target.transform.position;
}
}
/// <summary>
/// Resets the brain, forcing it to enter its first state
/// </summary>
public virtual void ResetBrain()
{
InitializeDecisions();
InitializeActions();
BrainActive = true;
this.enabled = true;
if (CurrentState != null)
{
CurrentState.ExitState();
OnExitState();
}
if (States.Count > 0)
{
CurrentState = States[0];
CurrentState?.EnterState();
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eec89e4158bf96841b9bc830fc5385ca
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,54 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Tools
{
/// <summary>
/// Decisions are components that will be evaluated by transitions, every frame, and will return true or false. Examples include time spent in a state, distance to a target, or object detection within an area.
/// </summary>
public abstract class AIDecision : MonoBehaviour
{
/// Decide will be performed every frame while the Brain is in a state this Decision is in. Should return true or false, which will then determine the transition's outcome.
public abstract bool Decide();
/// a label you can set to organize your AI Decisions, not used by anything else
[Tooltip("a label you can set to organize your AI Decisions, not used by anything else")]
public string Label;
public virtual bool DecisionInProgress { get; set; }
protected AIBrain _brain;
/// <summary>
/// On Awake we grab our Brain
/// </summary>
protected virtual void Awake()
{
_brain = this.gameObject.GetComponentInParent<AIBrain>();
}
/// <summary>
/// Meant to be overridden, called when the game starts
/// </summary>
public virtual void Initialization()
{
}
/// <summary>
/// Meant to be overridden, called when the Brain enters a State this Decision is in
/// </summary>
public virtual void OnEnterState()
{
DecisionInProgress = true;
}
/// <summary>
/// Meant to be overridden, called when the Brain exits a State this Decision is in
/// </summary>
public virtual void OnExitState()
{
DecisionInProgress = false;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 86aa60c7eb6e3fe4a8c3624c6b3f1abc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,131 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Tools
{
[System.Serializable]
public class AIActionsList : MMReorderableArray<AIAction>
{
}
[System.Serializable]
public class AITransitionsList : MMReorderableArray<AITransition>
{
}
/// <summary>
/// A State is a combination of one or more actions, and one or more transitions. An example of a state could be "_patrolling until an enemy gets in range_".
/// </summary>
[System.Serializable]
public class AIState
{
/// the name of the state (will be used as a reference in Transitions
public string StateName;
[MMReorderableAttribute(null, "Action", null)]
public AIActionsList Actions;
[MMReorderableAttribute(null, "Transition", null)]
public AITransitionsList Transitions;/*
/// a list of actions to perform in this state
public List<AIAction> Actions;
/// a list of transitions to evaluate to exit this state
public List<AITransition> Transitions;*/
protected AIBrain _brain;
/// <summary>
/// Sets this state's brain to the one specified in parameters
/// </summary>
/// <param name="brain"></param>
public virtual void SetBrain(AIBrain brain)
{
_brain = brain;
}
/// <summary>
/// On enter state we pass that info to our actions and decisions
/// </summary>
public virtual void EnterState()
{
foreach (AIAction action in Actions)
{
action.OnEnterState();
}
foreach (AITransition transition in Transitions)
{
if (transition.Decision != null)
{
transition.Decision.OnEnterState();
}
}
}
/// <summary>
/// On exit state we pass that info to our actions and decisions
/// </summary>
public virtual void ExitState()
{
foreach (AIAction action in Actions)
{
action.OnExitState();
}
foreach (AITransition transition in Transitions)
{
if (transition.Decision != null)
{
transition.Decision.OnExitState();
}
}
}
/// <summary>
/// Performs this state's actions
/// </summary>
public virtual void PerformActions()
{
if (Actions.Count == 0) { return; }
for (int i=0; i<Actions.Count; i++)
{
if (Actions[i] != null)
{
Actions[i].PerformAction();
}
else
{
Debug.LogError("An action in " + _brain.gameObject.name + " on state " + StateName + " is null.");
}
}
}
/// <summary>
/// Tests this state's transitions
/// </summary>
public virtual void EvaluateTransitions()
{
if (Transitions.Count == 0) { return; }
for (int i = 0; i < Transitions.Count; i++)
{
if (Transitions[i].Decision != null)
{
if (Transitions[i].Decision.Decide())
{
if (!string.IsNullOrEmpty(Transitions[i].TrueState))
{
_brain.TransitionToState(Transitions[i].TrueState);
break;
}
}
else
{
if (!string.IsNullOrEmpty(Transitions[i].FalseState))
{
_brain.TransitionToState(Transitions[i].FalseState);
break;
}
}
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6e1187ab043b6154493c3407ed149566
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Tools
{
/// <summary>
/// Transitions are a combination of one or more decisions and destination states whether or not these transitions are true or false. An example of a transition could be "_if an enemy gets in range, transition to the Shooting state_".
/// </summary>
[System.Serializable]
public class AITransition
{
/// this transition's decision
public AIDecision Decision;
/// the state to transition to if this Decision returns true
public string TrueState;
/// the state to transition to if this Decision returns false
public string FalseState;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 36bf680dabd04c14288ec99ad204ee89
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 11c2284278bfce54a9d90b80bc88118a
folderAsset: yes
timeCreated: 1523893762
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 602325afa3a7e49e6a02b9bef136256b
folderAsset: yes
timeCreated: 1480001014
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 0f03458534bea45e4bba9ab3411321b2
timeCreated: 1480001014
licenseType: Store
TrueTypeFontImporter:
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontNames:
- Orange Kid
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e9c2c059b6db042f9a6c5169883cfd91
folderAsset: yes
timeCreated: 1480084340
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,586 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1000011764500980}
m_IsPrefabParent: 1
--- !u!1 &1000010625031310
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224000013839664430}
- component: {fileID: 222000012145136048}
- component: {fileID: 114000012127359052}
m_Layer: 5
m_Name: AchievementDescription
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1000010787308212
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224000010446898764}
- component: {fileID: 222000010806795656}
- component: {fileID: 114000011025716940}
m_Layer: 5
m_Name: AchievementTitle
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1000011017784956
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224000010929275142}
- component: {fileID: 222000013828483476}
- component: {fileID: 114000014023583406}
m_Layer: 5
m_Name: AchievementBackgroundUnlocked
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!1 &1000011678039142
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224000011865885252}
- component: {fileID: 222000014014719096}
- component: {fileID: 114000014234426190}
- component: {fileID: 114123889840356516}
m_Layer: 5
m_Name: ProgressBar
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1000011764500980
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224000014175055234}
- component: {fileID: 114000010642984398}
- component: {fileID: 225000012185432622}
m_Layer: 5
m_Name: AchievementDisplay
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1000012137379068
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224000011735803302}
- component: {fileID: 222000014068580754}
- component: {fileID: 114000012046079386}
m_Layer: 5
m_Name: AchievementIcon
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1000012904130690
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224000011949108480}
- component: {fileID: 222000011779272360}
- component: {fileID: 114000013121188064}
m_Layer: 5
m_Name: AchievementBackground
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1000014260414582
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224000010576291022}
- component: {fileID: 222000010728672920}
- component: {fileID: 114000011002272268}
m_Layer: 5
m_Name: ProgressBarFront
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &114000010642984398
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011764500980}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e775494159ed5e4c997035d2df49776, type: 3}
m_Name:
m_EditorClassIdentifier:
BackgroundLocked: {fileID: 114000013121188064}
BackgroundUnlocked: {fileID: 114000014023583406}
Icon: {fileID: 114000012046079386}
Title: {fileID: 114000011025716940}
Description: {fileID: 114000012127359052}
ProgressBarDisplay: {fileID: 114123889840356516}
--- !u!114 &114000011002272268
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000014260414582}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &114000011025716940
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010787308212}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 12800000, guid: 0f03458534bea45e4bba9ab3411321b2, type: 3}
m_FontSize: 30
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 1
m_MaxSize: 40
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Achievement Title
--- !u!114 &114000012046079386
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000012137379068}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: 16a86a7f581fc4dfb953e0df8ad3ecac, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &114000012127359052
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010625031310}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0.578}
m_RaycastTarget: 0
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 12800000, guid: 0f03458534bea45e4bba9ab3411321b2, type: 3}
m_FontSize: 26
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 1
m_MaxSize: 40
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 0.68
m_Text: The achievement's description goes here ipsum dolor lorem sit amet ipsum
dolor sit amet ipsum dolor sit amet
--- !u!114 &114000013121188064
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000012904130690}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: cecdbf60b0c9d47c9a26b99a41425de0, type: 3}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &114000014023583406
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011017784956}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: c379ef0fb8ae144a5b0a0b1d0c02d125, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &114000014234426190
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011678039142}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &114123889840356516
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011678039142}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0a42a23ce4f9ed24abde69beacbef2f4, type: 3}
m_Name:
m_EditorClassIdentifier:
ForegroundBar: {fileID: 224000010576291022}
PlayerID:
--- !u!222 &222000010728672920
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000014260414582}
--- !u!222 &222000010806795656
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010787308212}
--- !u!222 &222000011779272360
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000012904130690}
--- !u!222 &222000012145136048
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010625031310}
--- !u!222 &222000013828483476
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011017784956}
--- !u!222 &222000014014719096
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011678039142}
--- !u!222 &222000014068580754
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000012137379068}
--- !u!224 &224000010446898764
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010787308212}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 224000014175055234}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -201, y: 100}
m_SizeDelta: {x: 354.109, y: 50.075}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224000010576291022
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000014260414582}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 224000011865885252}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 335, y: 5}
m_Pivot: {x: 0, y: 0.5}
--- !u!224 &224000010929275142
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011017784956}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 1}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 224000014175055234}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -256, y: 64}
m_SizeDelta: {x: 512, y: 128}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224000011735803302
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000012137379068}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 224000014175055234}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: -448, y: 64}
m_SizeDelta: {x: 128, y: 128}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224000011865885252
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011678039142}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 224000010576291022}
m_Father: {fileID: 224000014175055234}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: -209.4, y: 13.9}
m_SizeDelta: {x: 335, y: 5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224000011949108480
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000012904130690}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 1}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 224000014175055234}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: -256, y: 64}
m_SizeDelta: {x: 512, y: 128}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224000013839664430
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010625031310}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 224000014175055234}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -201, y: 55}
m_SizeDelta: {x: 353.894, y: 79.908}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224000014175055234
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011764500980}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 224000011949108480}
- {fileID: 224000010929275142}
- {fileID: 224000011735803302}
- {fileID: 224000010446898764}
- {fileID: 224000013839664430}
- {fileID: 224000011865885252}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: -6.1451902, y: 20.653046}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!225 &225000012185432622
CanvasGroup:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011764500980}
m_Enabled: 1
m_Alpha: 1
m_Interactable: 1
m_BlocksRaycasts: 1
m_IgnoreParentGroups: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bf6e65de4f70a4dcf99ceb68e999d287
timeCreated: 1480162379
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 4360e4e414a1faa4c9f4249158fb7f7a
folderAsset: yes
timeCreated: 1480084340
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,586 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1000011764500980}
m_IsPrefabParent: 1
--- !u!1 &1000010625031310
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224000013839664430}
- component: {fileID: 222000012145136048}
- component: {fileID: 114000012127359052}
m_Layer: 5
m_Name: AchievementDescription
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1000010787308212
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224000010446898764}
- component: {fileID: 222000010806795656}
- component: {fileID: 114000011025716940}
m_Layer: 5
m_Name: AchievementTitle
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1000011017784956
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224000010929275142}
- component: {fileID: 222000013828483476}
- component: {fileID: 114000014023583406}
m_Layer: 5
m_Name: AchievementBackgroundUnlocked
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!1 &1000011678039142
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224000011865885252}
- component: {fileID: 222000014014719096}
- component: {fileID: 114000014234426190}
- component: {fileID: 114000012929178306}
m_Layer: 5
m_Name: ProgressBar
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1000011764500980
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224000014175055234}
- component: {fileID: 114000010642984398}
- component: {fileID: 225000012185432622}
m_Layer: 5
m_Name: AchievementDisplay
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1000012137379068
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224000011735803302}
- component: {fileID: 222000014068580754}
- component: {fileID: 114000012046079386}
m_Layer: 5
m_Name: AchievementIcon
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1000012904130690
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224000011949108480}
- component: {fileID: 222000011779272360}
- component: {fileID: 114000013121188064}
m_Layer: 5
m_Name: AchievementBackground
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1000014260414582
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 224000010576291022}
- component: {fileID: 222000010728672920}
- component: {fileID: 114000011002272268}
m_Layer: 5
m_Name: ProgressBarFront
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &114000010642984398
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011764500980}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e775494159ed5e4c997035d2df49776, type: 3}
m_Name:
m_EditorClassIdentifier:
BackgroundLocked: {fileID: 114000013121188064}
BackgroundUnlocked: {fileID: 114000014023583406}
Icon: {fileID: 114000012046079386}
Title: {fileID: 114000011025716940}
Description: {fileID: 114000012127359052}
ProgressBarDisplay: {fileID: 114000012929178306}
--- !u!114 &114000011002272268
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000014260414582}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &114000011025716940
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010787308212}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 12800000, guid: 0f03458534bea45e4bba9ab3411321b2, type: 3}
m_FontSize: 30
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 1
m_MaxSize: 40
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Achievement Title
--- !u!114 &114000012046079386
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000012137379068}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: 16a86a7f581fc4dfb953e0df8ad3ecac, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &114000012127359052
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010625031310}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0.578}
m_RaycastTarget: 0
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 12800000, guid: 0f03458534bea45e4bba9ab3411321b2, type: 3}
m_FontSize: 26
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 1
m_MaxSize: 40
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 0.68
m_Text: The achievement's description goes here ipsum dolor lorem sit amet ipsum
dolor sit amet ipsum dolor sit amet
--- !u!114 &114000012929178306
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011678039142}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0a42a23ce4f9ed24abde69beacbef2f4, type: 3}
m_Name:
m_EditorClassIdentifier:
ForegroundBar: {fileID: 224000010576291022}
PlayerID:
--- !u!114 &114000013121188064
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000012904130690}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: cecdbf60b0c9d47c9a26b99a41425de0, type: 3}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &114000014023583406
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011017784956}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: c379ef0fb8ae144a5b0a0b1d0c02d125, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!114 &114000014234426190
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011678039142}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &222000010728672920
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000014260414582}
--- !u!222 &222000010806795656
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010787308212}
--- !u!222 &222000011779272360
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000012904130690}
--- !u!222 &222000012145136048
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010625031310}
--- !u!222 &222000013828483476
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011017784956}
--- !u!222 &222000014014719096
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011678039142}
--- !u!222 &222000014068580754
CanvasRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000012137379068}
--- !u!224 &224000010446898764
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010787308212}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 224000014175055234}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -201, y: 100}
m_SizeDelta: {x: 354.109, y: 50.075}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224000010576291022
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000014260414582}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 224000011865885252}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 335, y: 5}
m_Pivot: {x: 0, y: 0.5}
--- !u!224 &224000010929275142
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011017784956}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 1}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 224000014175055234}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -256, y: 64}
m_SizeDelta: {x: 512, y: 128}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224000011735803302
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000012137379068}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 224000014175055234}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: -448, y: 64}
m_SizeDelta: {x: 128, y: 128}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224000011865885252
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011678039142}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 224000010576291022}
m_Father: {fileID: 224000014175055234}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: -209.4, y: 13.9}
m_SizeDelta: {x: 335, y: 5}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224000011949108480
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000012904130690}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 1}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 224000014175055234}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: -256, y: 64}
m_SizeDelta: {x: 512, y: 128}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224000013839664430
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010625031310}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 224000014175055234}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -201, y: 55}
m_SizeDelta: {x: 353.894, y: 79.908}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!224 &224000014175055234
RectTransform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011764500980}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 224000011949108480}
- {fileID: 224000010929275142}
- {fileID: 224000011735803302}
- {fileID: 224000010446898764}
- {fileID: 224000013839664430}
- {fileID: 224000011865885252}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: -29.421097, y: -15.587612}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!225 &225000012185432622
CanvasGroup:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000011764500980}
m_Enabled: 1
m_Alpha: 1
m_Interactable: 1
m_BlocksRaycasts: 1
m_IgnoreParentGroups: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 445360f52aabb4446be71f24e6576a72
timeCreated: 1480162379
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: af38923d3d51548fe95ccec5e05de8c8
folderAsset: yes
timeCreated: 1480084329
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,119 @@
using UnityEngine;
using System.Collections;
using System;
namespace MoreMountains.Tools
{
/// <summary>
/// This achievement system supports 2 types of achievements : simple (do something > get achievement), and progress based (jump X times, kill X enemies, etc).
/// </summary>
public enum AchievementTypes { Simple, Progress }
[Serializable]
public class MMAchievement
{
[Header("Identification")]
/// the unique identifier for this achievement
public string AchievementID;
/// is this achievement progress based or
public AchievementTypes AchievementType;
/// if this is true, the achievement won't be displayed in a list
public bool HiddenAchievement;
/// if this is true, the achievement has been unlocked. Otherwise, it's still up for grabs
public bool UnlockedStatus;
[Header("Description")]
/// the achievement's name/title
public string Title;
/// the achievement's description
public string Description;
/// the amount of points unlocking this achievement gets you
public int Points;
[Header("Image and Sounds")]
/// the image to display while this achievement is locked
public Sprite LockedImage;
/// the image to display when the achievement is unlocked
public Sprite UnlockedImage;
/// a sound to play when the achievement is unlocked
public AudioClip UnlockedSound;
[Header("Progress")]
/// the amount of progress needed to unlock this achievement.
public int ProgressTarget;
/// the current amount of progress made on this achievement
public int ProgressCurrent;
protected MMAchievementDisplayItem _achievementDisplayItem;
/// <summary>
/// Unlocks the achievement, asks for a save of the current achievements, and triggers an MMAchievementUnlockedEvent for this achievement.
/// This will usually then be caught by the MMAchievementDisplay class.
/// </summary>
public virtual void UnlockAchievement()
{
// if the achievement has already been unlocked, we do nothing and exit
if (UnlockedStatus)
{
return;
}
UnlockedStatus = true;
MMGameEvent.Trigger("Save");
MMAchievementUnlockedEvent.Trigger(this);
}
/// <summary>
/// Locks the achievement.
/// </summary>
public virtual void LockAchievement()
{
UnlockedStatus = false;
}
/// <summary>
/// Adds the specified value to the current progress.
/// </summary>
/// <param name="newProgress">New progress.</param>
public virtual void AddProgress(int newProgress)
{
ProgressCurrent += newProgress;
EvaluateProgress();
}
/// <summary>
/// Sets the progress to the value passed in parameter.
/// </summary>
/// <param name="newProgress">New progress.</param>
public virtual void SetProgress(int newProgress)
{
ProgressCurrent = newProgress;
EvaluateProgress();
}
/// <summary>
/// Evaluates the current progress of the achievement, and unlocks it if needed.
/// </summary>
protected virtual void EvaluateProgress()
{
MMAchievementChangedEvent.Trigger(this);
if (ProgressCurrent >= ProgressTarget)
{
ProgressCurrent = ProgressTarget;
UnlockAchievement();
}
}
/// <summary>
/// Copies this achievement (useful when loading from a scriptable object list)
/// </summary>
public virtual MMAchievement Copy()
{
MMAchievement clone = new MMAchievement ();
// we use Json utility to store a copy of our achievement, not a reference
clone = JsonUtility.FromJson<MMAchievement>(JsonUtility.ToJson(this));
return clone;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 12a7d0ec5f1424c129527c01a444e964
timeCreated: 1480085861
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using MoreMountains.Tools;
namespace MoreMountains.Tools
{
/// <summary>
/// This class is used to display an achievement. Add it to a prefab containing all the required elements listed below.
/// </summary>
[AddComponentMenu("More Mountains/Tools/Achievements/MMAchievementDisplayItem")]
public class MMAchievementDisplayItem : MonoBehaviour
{
public Image BackgroundLocked;
public Image BackgroundUnlocked;
public Image Icon;
public Text Title;
public Text Description;
public MMProgressBar ProgressBarDisplay;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4e775494159ed5e4c997035d2df49776
timeCreated: 1480176460
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,104 @@
using UnityEngine;
using System.Collections;
using MoreMountains.Tools;
using UnityEngine.SceneManagement;
namespace MoreMountains.Tools
{
/// <summary>
/// A class used to display the achievements on screen.
/// The AchievementDisplayItems will be parented to it, so it's better if it has a LayoutGroup (Vertical or Horizontal) too.
/// </summary>
[AddComponentMenu("More Mountains/Tools/Achievements/MMAchievementDisplayer")]
public class MMAchievementDisplayer : MonoBehaviour, MMEventListener<MMAchievementUnlockedEvent>
{
[Header("Achievements")]
/// the prefab to use to display achievements
public MMAchievementDisplayItem AchievementDisplayPrefab;
/// the duration the achievement will remain on screen for when unlocked
public float AchievementDisplayDuration = 5f;
/// the fade in/out speed
public float AchievementFadeDuration = 0.2f;
protected WaitForSeconds _achievementFadeOutWFS;
/// <summary>
/// Instantiates an achievement display prefab and shows it for the specified duration
/// </summary>
/// <returns>The achievement.</returns>
/// <param name="achievement">Achievement.</param>
public virtual IEnumerator DisplayAchievement(MMAchievement achievement)
{
if ((this.transform == null) || (AchievementDisplayPrefab == null))
{
yield break;
}
// we instantiate our achievement display prefab, and add it to the group that will automatically handle its position
GameObject instance = (GameObject)Instantiate(AchievementDisplayPrefab.gameObject);
instance.transform.SetParent(this.transform,false);
// we get the achievement displayer
MMAchievementDisplayItem achievementDisplay = instance.GetComponent<MMAchievementDisplayItem> ();
if (achievementDisplay == null)
{
yield break;
}
// we fill our achievement
achievementDisplay.Title.text = achievement.Title;
achievementDisplay.Description.text = achievement.Description;
achievementDisplay.Icon.sprite = achievement.UnlockedImage;
if (achievement.AchievementType == AchievementTypes.Progress)
{
achievementDisplay.ProgressBarDisplay.gameObject.SetActive(true);
}
else
{
achievementDisplay.ProgressBarDisplay.gameObject.SetActive(false);
}
// we play a sound if set
if (achievement.UnlockedSound != null)
{
MMSfxEvent.Trigger (achievement.UnlockedSound);
}
// we fade it in and out
CanvasGroup achievementCanvasGroup = instance.GetComponent<CanvasGroup> ();
if (achievementCanvasGroup != null)
{
achievementCanvasGroup.alpha = 0;
StartCoroutine(MMFade.FadeCanvasGroup(achievementCanvasGroup, AchievementFadeDuration, 1));
yield return _achievementFadeOutWFS;
StartCoroutine(MMFade.FadeCanvasGroup(achievementCanvasGroup, AchievementFadeDuration, 0));
}
}
/// <summary>
/// When an achievement is unlocked, we display it
/// </summary>
/// <param name="achievementUnlockedEvent">Achievement unlocked event.</param>
public virtual void OnMMEvent(MMAchievementUnlockedEvent achievementUnlockedEvent)
{
StartCoroutine(DisplayAchievement (achievementUnlockedEvent.Achievement));
}
/// <summary>
/// On enable, we start listening for unlocked achievements
/// </summary>
protected virtual void OnEnable()
{
this.MMEventStartListening<MMAchievementUnlockedEvent>();
_achievementFadeOutWFS = new WaitForSeconds (AchievementFadeDuration + AchievementDisplayDuration);
}
/// <summary>
/// On disable, we stop listening for unlocked achievements
/// </summary>
protected virtual void OnDisable()
{
this.MMEventStopListening<MMAchievementUnlockedEvent>();
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f759f536b039f2b46881cfc8ea77c496
timeCreated: 1480176245
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,53 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace MoreMountains.Tools
{
/// <summary>
/// An event type used to broadcast the fact that an achievement has been unlocked
/// </summary>
public struct MMAchievementUnlockedEvent
{
/// the achievement that has been unlocked
public MMAchievement Achievement;
/// <summary>
/// Constructor
/// </summary>
/// <param name="newAchievement">New achievement.</param>
public MMAchievementUnlockedEvent(MMAchievement newAchievement)
{
Achievement = newAchievement;
}
static MMAchievementUnlockedEvent e;
public static void Trigger(MMAchievement newAchievement)
{
e.Achievement = newAchievement;
MMEventManager.TriggerEvent(e);
}
}
public struct MMAchievementChangedEvent
{
/// the achievement that has been unlocked
public MMAchievement Achievement;
/// <summary>
/// Constructor
/// </summary>
/// <param name="newAchievement">New achievement.</param>
public MMAchievementChangedEvent(MMAchievement newAchievement)
{
Achievement = newAchievement;
}
static MMAchievementChangedEvent e;
public static void Trigger(MMAchievement newAchievement)
{
e.Achievement = newAchievement;
MMEventManager.TriggerEvent(e);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d8ab561ba77c94d3fafd05ffde7d9f7c
timeCreated: 1480085871
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,34 @@
using UnityEngine;
using System.Collections;
using MoreMountains.Tools;
using System.Collections.Generic;
namespace MoreMountains.Tools
{
[CreateAssetMenu(fileName="AchievementList",menuName="MoreMountains/Achievement List")]
/// <summary>
/// A scriptable object containing a list of achievements. You need to create one and store it in a Resources folder for this to work.
/// </summary>
public class MMAchievementList : ScriptableObject
{
/// the unique ID of this achievement list. This is used to save/load data.
public string AchievementsListID = "AchievementsList";
/// the list of achievements
public List<MMAchievement> Achievements;
/// <summary>
/// Asks for a reset of all the achievements in this list (they'll all be locked again, their progress lost).
/// </summary>
public virtual void ResetAchievements()
{
Debug.LogFormat ("Reset Achievements");
MMAchievementManager.ResetAchievements (AchievementsListID);
}
private MMReferenceHolder<MMAchievementList> _instances;
protected virtual void OnEnable() { _instances.Reference(this); }
protected virtual void OnDisable() { _instances.Dispose(); }
public static MMAchievementList Any => MMReferenceHolder<MMAchievementList>.Any;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 6f8f916bd4c5a444fa42e298d90f488d
timeCreated: 1480177569
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,225 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace MoreMountains.Tools
{
[ExecuteAlways]
/// <summary>
/// This static class is in charge of storing the current state of the achievements, unlocking/locking them, and saving them to data files
/// </summary>
public static class MMAchievementManager
{
public static List<MMAchievement> AchievementsList { get { return _achievements; }}
private static List<MMAchievement> _achievements;
private static MMAchievement _achievement = null;
public static string _defaultFileName = "Achievements";
public static string _saveFolderName = "MMAchievements/";
public static string _saveFileExtension = ".achievements";
public static string SaveFileName;
public static string ListID;
/// <summary>
/// You'll need to call this method to initialize the manager
/// </summary>
public static void LoadAchievementList(MMAchievementList achievementList)
{
_achievements = new List<MMAchievement> ();
if (achievementList == null)
{
return;
}
// we store the ID for save purposes
ListID = achievementList.AchievementsListID;
foreach (MMAchievement achievement in achievementList.Achievements)
{
_achievements.Add (achievement.Copy());
}
}
/// <summary>
/// Unlocks the specified achievement (if found).
/// </summary>
/// <param name="achievementID">Achievement I.</param>
public static void UnlockAchievement(string achievementID)
{
_achievement = AchievementManagerContains(achievementID);
if (_achievement != null)
{
_achievement.UnlockAchievement();
}
}
/// <summary>
/// Locks the specified achievement (if found).
/// </summary>
/// <param name="achievementID">Achievement ID.</param>
public static void LockAchievement(string achievementID)
{
_achievement = AchievementManagerContains(achievementID);
if (_achievement != null)
{
_achievement.LockAchievement();
}
}
/// <summary>
/// Adds progress to the specified achievement (if found).
/// </summary>
/// <param name="achievementID">Achievement ID.</param>
/// <param name="newProgress">New progress.</param>
public static void AddProgress(string achievementID, int newProgress)
{
_achievement = AchievementManagerContains(achievementID);
if (_achievement != null)
{
_achievement.AddProgress(newProgress);
}
}
/// <summary>
/// Sets the progress of the specified achievement (if found) to the specified progress.
/// </summary>
/// <param name="achievementID">Achievement ID.</param>
/// <param name="newProgress">New progress.</param>
public static void SetProgress(string achievementID, int newProgress)
{
_achievement = AchievementManagerContains(achievementID);
if (_achievement != null)
{
_achievement.SetProgress(newProgress);
}
}
/// <summary>
/// Determines if the achievement manager contains an achievement of the specified ID. Returns it if found, otherwise returns null
/// </summary>
/// <returns>The achievement corresponding to the searched ID if found, otherwise null.</returns>
/// <param name="searchedID">Searched I.</param>
private static MMAchievement AchievementManagerContains(string searchedID)
{
if (_achievements.Count == 0)
{
return null;
}
foreach(MMAchievement achievement in _achievements)
{
if (achievement.AchievementID == searchedID)
{
return achievement;
}
}
return null;
}
// SAVE ------------------------------------------------------------------------------------------------------------------------------------
/// <summary>
/// Removes saved data and resets all achievements from a list
/// </summary>
/// <param name="listID">The ID of the achievement list to reset.</param>
public static void ResetAchievements(string listID)
{
if (_achievements != null)
{
foreach(MMAchievement achievement in _achievements)
{
achievement.ProgressCurrent = 0;
achievement.UnlockedStatus = false;
}
}
DeterminePath (listID);
MMSaveLoadManager.DeleteSave(SaveFileName + _saveFileExtension, _saveFolderName);
Debug.LogFormat ("Achievements Reset");
}
public static void ResetAllAchievements()
{
ResetAchievements (ListID);
}
/// <summary>
/// Loads the saved achievements file and updates the array with its content.
/// </summary>
public static void LoadSavedAchievements()
{
DeterminePath ();
SerializedMMAchievementManager serializedMMAchievementManager = (SerializedMMAchievementManager)MMSaveLoadManager.Load(typeof(SerializedMMAchievementManager), SaveFileName+ _saveFileExtension, _saveFolderName);
ExtractSerializedMMAchievementManager(serializedMMAchievementManager);
}
/// <summary>
/// Saves the achievements current status to a file on disk
/// </summary>
public static void SaveAchievements()
{
DeterminePath ();
SerializedMMAchievementManager serializedMMAchievementManager = new SerializedMMAchievementManager();
FillSerializedMMAchievementManager(serializedMMAchievementManager);
MMSaveLoadManager.Save(serializedMMAchievementManager, SaveFileName+_saveFileExtension, _saveFolderName);
}
/// <summary>
/// Determines the path the achievements save file should be saved to.
/// </summary>
private static void DeterminePath(string specifiedFileName = "")
{
string tempFileName = (!string.IsNullOrEmpty(ListID)) ? ListID : _defaultFileName;
if (!string.IsNullOrEmpty(specifiedFileName))
{
tempFileName = specifiedFileName;
}
SaveFileName = tempFileName;
}
/// <summary>
/// Serializes the contents of the achievements array to a serialized, ready to save object
/// </summary>
/// <param name="serializedInventory">Serialized inventory.</param>
public static void FillSerializedMMAchievementManager(SerializedMMAchievementManager serializedAchievements)
{
serializedAchievements.Achievements = new SerializedMMAchievement[_achievements.Count];
for (int i = 0; i < _achievements.Count(); i++)
{
SerializedMMAchievement newAchievement = new SerializedMMAchievement (_achievements[i].AchievementID, _achievements[i].UnlockedStatus, _achievements[i].ProgressCurrent);
serializedAchievements.Achievements [i] = newAchievement;
}
}
/// <summary>
/// Extracts the serialized achievements into our achievements array if the achievements ID match.
/// </summary>
/// <param name="serializedAchievements">Serialized achievements.</param>
public static void ExtractSerializedMMAchievementManager(SerializedMMAchievementManager serializedAchievements)
{
if (serializedAchievements == null)
{
return;
}
for (int i = 0; i < _achievements.Count(); i++)
{
for (int j=0; j<serializedAchievements.Achievements.Length; j++)
{
if (_achievements[i].AchievementID == serializedAchievements.Achievements[j].AchievementID)
{
_achievements [i].UnlockedStatus = serializedAchievements.Achievements [j].UnlockedStatus;
_achievements [i].ProgressCurrent = serializedAchievements.Achievements [j].ProgressCurrent;
}
}
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 7190b0080c757413082e75f41313dee8
timeCreated: 1480085861
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,81 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace MoreMountains.Tools
{
/// <summary>
/// That class is meant to be extended to implement the achievement rules specific to your game.
/// </summary>
public abstract class MMAchievementRules : MonoBehaviour, MMEventListener<MMGameEvent>
{
public MMAchievementList AchievementList;
[MMInspectorButton("PrintCurrentStatus")]
public bool PrintCurrentStatusBtn;
public virtual void PrintCurrentStatus()
{
foreach (MMAchievement achievement in MMAchievementManager.AchievementsList)
{
string status = achievement.UnlockedStatus ? "unlocked" : "locked";
Debug.Log("["+achievement.AchievementID + "] "+achievement.Title+", status : "+status+", progress : "+achievement.ProgressCurrent+"/"+achievement.ProgressTarget);
}
}
/// <summary>
/// On Awake, loads the achievement list and the saved file
/// </summary>
protected virtual void Awake()
{
// we load the list of achievements, stored in a ScriptableObject in our Resources folder.
MMAchievementManager.LoadAchievementList (AchievementList);
// we load our saved file, to update that list with the saved values.
MMAchievementManager.LoadSavedAchievements ();
}
/// <summary>
/// On enable, we start listening for MMGameEvents. You may want to extend that to listen to other types of events.
/// </summary>
protected virtual void OnEnable()
{
this.MMEventStartListening<MMGameEvent>();
}
/// <summary>
/// On disable, we stop listening for MMGameEvents. You may want to extend that to stop listening to other types of events.
/// </summary>
protected virtual void OnDisable()
{
this.MMEventStopListening<MMGameEvent>();
}
/// <summary>
/// When we catch an MMGameEvent, we do stuff based on its name
/// </summary>
/// <param name="gameEvent">Game event.</param>
public virtual void OnMMEvent(MMGameEvent gameEvent)
{
switch (gameEvent.EventName)
{
case "Save":
MMAchievementManager.SaveAchievements ();
break;
/*
// These are just examples of how you could catch a GameStart MMGameEvent and trigger the potential unlock of a corresponding achievement
case "GameStart":
MMAchievementManager.UnlockAchievement("theFirestarter");
break;
case "LifeLost":
MMAchievementManager.UnlockAchievement("theEndOfEverything");
break;
case "Pause":
MMAchievementManager.UnlockAchievement("timeStop");
break;
case "Jump":
MMAchievementManager.UnlockAchievement ("aSmallStepForMan");
MMAchievementManager.AddProgress ("toInfinityAndBeyond", 1);
break;*/
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2c7c529377dc843a9a2316262550c4d6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- AchievementList: {fileID: 11400000, guid: 18225175314a9854581d8d6262302958, type: 2}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,39 @@
using UnityEngine;
using System.Collections;
using System;
namespace MoreMountains.Tools
{
[Serializable]
/// <summary>
/// A serializable class used to store an achievement into a save file
/// </summary>
public class SerializedMMAchievement
{
public string AchievementID;
public bool UnlockedStatus;
public int ProgressCurrent;
/// <summary>
/// Initializes a new instance of the <see cref="MoreMountains.Tools.SerializedMMAchievement"/> class.
/// </summary>
/// <param name="achievementID">Achievement I.</param>
/// <param name="unlockedStatus">If set to <c>true</c> unlocked status.</param>
/// <param name="progressCurrent">Progress current.</param>
public SerializedMMAchievement(string achievementID, bool unlockedStatus, int progressCurrent)
{
AchievementID = achievementID;
UnlockedStatus = unlockedStatus;
ProgressCurrent = progressCurrent;
}
}
[Serializable]
/// <summary>
/// Serializable MM achievement manager.
/// </summary>
public class SerializedMMAchievementManager
{
public SerializedMMAchievement[] Achievements;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 24f964aa3d55241b591bc1da7903819e
timeCreated: 1480085861
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7fee60bb7a0474e9bad63c409ba9e02d
folderAsset: yes
timeCreated: 1479996221
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -0,0 +1,135 @@
fileFormatVersion: 2
guid: cecdbf60b0c9d47c9a26b99a41425de0
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 16
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 32, y: 32, z: 32, w: 32}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -0,0 +1,135 @@
fileFormatVersion: 2
guid: c379ef0fb8ae144a5b0a0b1d0c02d125
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -0,0 +1,135 @@
fileFormatVersion: 2
guid: 16a86a7f581fc4dfb953e0df8ad3ecac
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: -1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
cookieLightType: 1
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 28a7af70e6a6fce4f9a6d27d6bbf82cc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,58 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Tools
{
/// <summary>
/// Use this class to enable or disable other gameobjects automatically on Start or Awake
/// </summary>
[AddComponentMenu("More Mountains/Tools/Activation/MMActivationOnStart")]
public class MMActivationOnStart : MonoBehaviour
{
/// The possible modes that define whether this should run at Awake or Start
public enum Modes { Awake, Start }
/// the selected mode for this instance
public Modes Mode = Modes.Start;
/// if true, objects will be activated on start, disabled otherwise
public bool StateOnStart = true;
/// the list of gameobjects whose active state will be affected on start
public List<GameObject> TargetObjects;
/// <summary>
/// On Awake, we set our state if needed
/// </summary>
protected virtual void Awake()
{
if (Mode != Modes.Awake)
{
return;
}
SetState();
}
/// <summary>
/// On Start, we set our state if needed
/// </summary>
protected virtual void Start()
{
if (Mode != Modes.Start)
{
return;
}
SetState();
}
/// <summary>
/// Sets the state of all target objects
/// </summary>
protected virtual void SetState()
{
foreach (GameObject obj in TargetObjects)
{
obj.SetActive(StateOnStart);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 55a9829731bf3d3458319a5a829f1f04
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,106 @@
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
namespace MoreMountains.Tools
{
/// <summary>
/// A class used to store bindings
/// </summary>
[Serializable]
public class PlatformBindings
{
public enum PlatformActions { DoNothing, Disable }
public RuntimePlatform Platform = RuntimePlatform.WindowsPlayer;
public PlatformActions PlatformAction = PlatformActions.DoNothing;
}
/// <summary>
/// Add this class to a gameobject, and it'll enable/disable it based on platform context, using Application.platform to detect the platform
/// </summary>
[AddComponentMenu("More Mountains/Tools/Activation/MMApplicationPlatformActivation")]
public class MMApplicationPlatformActivation : MonoBehaviour
{
/// the possible times at which this script can run
public enum ExecutionTimes { Awake, Start, OnEnable }
[Header("Settings")]
/// the selected execution time
public ExecutionTimes ExecutionTime = ExecutionTimes.Awake;
/// whether or not this should output a debug line in the console
public bool DebugToTheConsole = false;
[Header("Platforms")]
public List<PlatformBindings> Platforms;
/// <summary>
/// On Enable, processes the state if needed
/// </summary>
protected virtual void OnEnable()
{
if (ExecutionTime == ExecutionTimes.OnEnable)
{
Process();
}
}
/// <summary>
/// On Awake, processes the state if needed
/// </summary>
protected virtual void Awake()
{
if (ExecutionTime == ExecutionTimes.Awake)
{
Process();
}
}
/// <summary>
/// On Start, processes the state if needed
/// </summary>
protected virtual void Start()
{
if (ExecutionTime == ExecutionTimes.Start)
{
Process();
}
}
/// <summary>
/// Enables or disables the object based on current platform
/// </summary>
protected virtual void Process()
{
foreach (PlatformBindings platform in Platforms)
{
if (platform.Platform == Application.platform)
{
DisableIfNeeded(platform.PlatformAction, platform.Platform.ToString());
}
}
if (Application.platform == RuntimePlatform.Android)
{
}
}
/// <summary>
/// Disables the object if needed, and outputs a debug log if requested
/// </summary>
/// <param name="platform"></param>
/// <param name="platformName"></param>
protected virtual void DisableIfNeeded(PlatformBindings.PlatformActions platform, string platformName)
{
if (this.gameObject.activeInHierarchy && (platform == PlatformBindings.PlatformActions.Disable))
{
this.gameObject.SetActive(false);
if (DebugToTheConsole)
{
Debug.LogFormat(this.gameObject.name + " got disabled via MMPlatformActivation, platform : " + platformName + ".");
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4b49077b56e67ff469bc52b6a64e5e17
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,106 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace MoreMountains.Tools
{
/// <summary>
/// A data class to store auto execution info to be used in MMAutoExecution
/// </summary>
[System.Serializable]
public class MMAutoExecutionItem
{
/// if this is true, Event will be invoked on Awake
public bool AutoExecuteOnAwake;
/// if this is true, Event will be invoked on Enable
public bool AutoExecuteOnEnable;
/// if this is true, Event will be invoked on Disable
public bool AutoExecuteOnDisable;
/// if this is true, Event will be invoked on Start
public bool AutoExecuteOnStart;
/// if this is true, Event will be invoked on Instantiate (you'll need to send a OnInstantiate message for this to happen
public bool AutoExecuteOnInstantiate;
public UnityEvent Event;
}
/// <summary>
/// This simple class lets you trigger Unity events automatically, on Awake, Enable, Disable, Start, or on instantiate
/// For that last one, you'll want to send a "OnInstantiate" message when instantiating this object
/// </summary>
public class MMAutoExecution : MonoBehaviour
{
/// a list of events to trigger automatically
public List<MMAutoExecutionItem> Events;
/// <summary>
/// On Awake we invoke our events if needed
/// </summary>
protected virtual void Awake()
{
foreach (MMAutoExecutionItem item in Events)
{
if ((item.AutoExecuteOnAwake) && (item.Event != null))
{
item.Event.Invoke();
}
}
}
/// <summary>
/// On Start we invoke our events if needed
/// </summary>
protected virtual void Start()
{
foreach (MMAutoExecutionItem item in Events)
{
if ((item.AutoExecuteOnStart) && (item.Event != null))
{
item.Event.Invoke();
}
}
}
/// <summary>
/// On Enable we invoke our events if needed
/// </summary>
protected virtual void OnEnable()
{
foreach (MMAutoExecutionItem item in Events)
{
if ((item.AutoExecuteOnEnable) && (item.Event != null))
{
item.Event.Invoke();
}
}
}
/// <summary>
/// On Enable we invoke our events if needed
/// </summary>
protected virtual void OnDisable()
{
foreach (MMAutoExecutionItem item in Events)
{
if ((item.AutoExecuteOnDisable) && (item.Event != null))
{
item.Event.Invoke();
}
}
}
/// <summary>
/// On Instantiate we invoke our events if needed
/// </summary>
protected virtual void OnInstantiate()
{
foreach (MMAutoExecutionItem item in Events)
{
if ((item.AutoExecuteOnInstantiate) && (item.Event != null))
{
item.Event.Invoke();
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 723c68a65280145479e4e0b2f94a6ff0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,50 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using MoreMountains.Tools;
namespace MoreMountains.Tools
{
/// <summary>
/// Add this component to a gameobject, and it'll let you enable target monos after all other targets have been disabled
/// </summary>
[AddComponentMenu("More Mountains/Tools/Activation/MMConditionalActivation")]
public class MMConditionalActivation : MonoBehaviour
{
/// a list of monos to enable
public MonoBehaviour[] EnableThese;
/// a list of all the monos that have to have been disabled first
public MonoBehaviour[] AfterTheseAreAllDisabled;
protected bool _enabled = false;
/// <summary>
/// On update, we check if we should disable
/// </summary>
protected virtual void Update()
{
if (_enabled)
{
return;
}
bool allDisabled = true;
foreach (MonoBehaviour component in AfterTheseAreAllDisabled)
{
if (component.isActiveAndEnabled)
{
allDisabled = false;
}
}
if (allDisabled)
{
foreach (MonoBehaviour component in EnableThese)
{
component.enabled = true;
}
_enabled = true;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8434b53deaa9ae04f87f3c24bf70d482
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using UnityEngine;
namespace MoreMountains.Tools
{
/// <summary>
/// Add this component to an object and it'll persist across scenes
/// </summary>
public class MMDontDestroyOnLoad : MonoBehaviour
{
/// <summary>
/// On Awake we make sure our object will not destroy on the next scene load
/// </summary>
protected void Awake()
{
DontDestroyOnLoad(this.gameObject);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c6dc6bc8e4bb2834e80531c648886d13
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,106 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
using UnityEngine.InputSystem;
#endif
namespace MoreMountains.Tools
{
/// <summary>
/// A class used to store MMInputExecution bindings, associating a target keycode to UnityEvents
/// </summary>
[System.Serializable]
public class MMInputExecutionBinding
{
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
public Key TargetInputKey = Key.Space;
#else
/// the key the user needs to press to trigger events
public KeyCode TargetKey = KeyCode.Space;
#endif
/// the event to trigger when the key is pressed down
public UnityEvent OnKeyDown;
/// the event to trigger every frame if the key is being pressed
public UnityEvent OnKey;
/// the event to trigger when the key is released
public UnityEvent OnKeyUp;
/// <summary>
/// Checks for input and invokes events if needed
/// </summary>
public virtual void ProcessInput()
{
bool key = false;
bool keyDown = false;
bool keyUp = false;
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
key = Keyboard.current[TargetInputKey].isPressed;
keyDown = Keyboard.current[TargetInputKey].wasPressedThisFrame;
keyUp = Keyboard.current[TargetInputKey].wasReleasedThisFrame;
#else
key = Input.GetKey(TargetKey);
keyDown = Input.GetKeyDown(TargetKey);
keyUp = Input.GetKeyUp(TargetKey);
#endif
if (OnKey != null)
{
if (key)
{
OnKey.Invoke();
}
}
if (OnKeyDown != null)
{
if (keyDown)
{
OnKeyDown.Invoke();
}
}
if (OnKeyUp != null)
{
if (keyUp)
{
OnKeyUp.Invoke();
}
}
}
}
/// <summary>
/// A simple class used to bind target keys to specific events to trigger when the key is pressed or released
/// </summary>
public class MMInputExecution : MonoBehaviour
{
[Header("Bindings")]
/// a list of bindings
public List<MMInputExecutionBinding> Bindings;
/// <summary>
/// On update we process our input
/// </summary>
protected virtual void Update()
{
HandleInput();
}
/// <summary>
/// Parses all bindings and asks them to trigger events if needed
/// </summary>
protected virtual void HandleInput()
{
if (Bindings == null)
{
return;
}
foreach(MMInputExecutionBinding binding in Bindings)
{
binding.ProcessInput();
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: af3876ae77702e24e8e1b06f675c0860
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,71 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace MoreMountains.Tools
{
/// <summary>
/// Attach this class to a collider and it'll let you trigger events when the user clicks/drags/enters/etc that collider
/// </summary>
public class MMOnMouse : MonoBehaviour
{
/// OnMouseDown is called when the user has pressed the mouse button while over the Collider.
[Tooltip("OnMouseDown is called when the user has pressed the mouse button while over the Collider.")]
public UnityEvent OnMouseDownEvent;
/// OnMouseDrag is called when the user has clicked on a Collider and is still holding down the mouse.
[Tooltip("OnMouseDrag is called when the user has clicked on a Collider and is still holding down the mouse.")]
public UnityEvent OnMouseDragEvent;
/// Called when the mouse enters the Collider.
[Tooltip("Called when the mouse enters the Collider.")]
public UnityEvent OnMouseEnterEvent;
/// Called when the mouse is not any longer over the Collider.
[Tooltip("Called when the mouse is not any longer over the Collider.")]
public UnityEvent OnMouseExitEvent;
/// Called every frame while the mouse is over the Collider.
[Tooltip("Called every frame while the mouse is over the Collider.")]
public UnityEvent OnMouseOverEvent;
/// OnMouseUp is called when the user has released the mouse button.
[Tooltip("OnMouseUp is called when the user has released the mouse button.")]
public UnityEvent OnMouseUpEvent;
/// OnMouseUpAsButton is only called when the mouse is released over the same Collider as it was pressed.
[Tooltip("OnMouseUpAsButton is only called when the mouse is released over the same Collider as it was pressed.")]
public UnityEvent OnMouseUpAsButtonEvent;
protected virtual void OnMouseDown()
{
OnMouseDownEvent.Invoke();
}
protected virtual void OnMouseDrag()
{
OnMouseDragEvent.Invoke();
}
protected virtual void OnMouseEnter()
{
OnMouseEnterEvent.Invoke();
}
protected virtual void OnMouseExit()
{
OnMouseExitEvent.Invoke();
}
protected virtual void OnMouseOver()
{
OnMouseOverEvent.Invoke();
}
protected virtual void OnMouseUp()
{
OnMouseUpEvent.Invoke();
}
protected virtual void OnMouseUpAsButton()
{
OnMouseUpAsButtonEvent.Invoke();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 80361f5e0185bb247a814457c589c1f3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Tools
{
/// <summary>
/// This component lets you parent the transform you put it on to any target parent (or to the root if none is set), on Awake, Start or anytime you call its Parent() method
/// </summary>
public class MMParentingOnStart : MonoBehaviour
{
/// the possible modes this can run on
public enum Modes { Awake, Start, Script }
/// the selected mode
public Modes Mode = Modes.Awake;
/// the parent to parent to, leave empty if you want to unparent completely
public Transform TargetParent;
/// <summary>
/// On Awake we parent if needed
/// </summary>
protected virtual void Awake()
{
if (Mode == Modes.Awake)
{
Parent();
}
}
/// <summary>
/// On Start we parent if needed
/// </summary>
protected virtual void Start()
{
if (Mode == Modes.Start)
{
Parent();
}
}
/// <summary>
/// Sets this transform's parent to the target
/// </summary>
public virtual void Parent()
{
this.transform.SetParent(TargetParent);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 996385a9b56b4d14eb03dc65ed309620
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,51 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace MoreMountains.Tools
{
/// <summary>
/// This class will let you trigger a OnRandomInterval event periodically, at random intervals
/// </summary>
public class MMPeriodicExecution : MonoBehaviour
{
/// the min and max duration of the interval between two events, in seconds
[MMVector("Min", "Max")]
public Vector2 RandomIntervalDuration = new Vector2(1f, 3f);
/// the event to play at the end of each interval
public UnityEvent OnRandomInterval;
protected float _lastUpdateAt = 0f;
protected float _currentInterval = 0f;
/// <summary>
/// On Start we initialize our interval duration
/// </summary>
protected virtual void Start()
{
DetermineNewInterval();
}
/// <summary>
/// On Update we check if we've reached the end of an interval
/// </summary>
protected virtual void Update()
{
if (Time.time - _lastUpdateAt > _currentInterval)
{
OnRandomInterval?.Invoke();
_lastUpdateAt = Time.time;
DetermineNewInterval();
}
}
/// <summary>
/// Randomizes a new duration
/// </summary>
protected virtual void DetermineNewInterval()
{
_currentInterval = Random.Range(RandomIntervalDuration.x, RandomIntervalDuration.y);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b91c53058d9ddc04bbc92506986923a3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,230 @@
using UnityEngine;
using System.Collections;
namespace MoreMountains.Tools
{
/// <summary>
/// Add this class to a gameobject, and it'll enable/disable it based on platform context, using conditional defintions to do so
/// </summary>
[AddComponentMenu("More Mountains/Tools/Activation/MMPlatformActivation")]
public class MMPlatformActivation : MonoBehaviour
{
/// the possible times at which this script can run
public enum ExecutionTimes { Awake, Start, OnEnable }
public enum PlatformActions { DoNothing, Disable }
[Header("Settings")]
/// the selected execution time
public ExecutionTimes ExecutionTime = ExecutionTimes.Awake;
/// whether or not this should output a debug line in the console
public bool DebugToTheConsole = false;
[Header("Desktop")]
/// whether or not this gameobject should be active on Windows
public PlatformActions UNITY_STANDALONE_WIN = PlatformActions.DoNothing;
/// whether or not this gameobject should be active on OSX
public PlatformActions UNITY_STANDALONE_OSX = PlatformActions.DoNothing;
/// whether or not this gameobject should be active on Linux
public PlatformActions UNITY_STANDALONE_LINUX = PlatformActions.DoNothing;
/// whether or not this gameobject should be active on standalone
public PlatformActions UNITY_STANDALONE = PlatformActions.DoNothing;
[Header("Mobile")]
/// whether or not this gameobject should be active on iOS
public PlatformActions UNITY_IOS = PlatformActions.DoNothing;
/// whether or not this gameobject should be active on iPhone
public PlatformActions UNITY_IPHONE = PlatformActions.DoNothing;
/// whether or not this gameobject should be active on Android
public PlatformActions UNITY_ANDROID = PlatformActions.DoNothing;
/// whether or not this gameobject should be active on Tizen
public PlatformActions UNITY_TIZEN = PlatformActions.DoNothing;
[Header("Console")]
/// whether or not this gameobject should be active on Wii
public PlatformActions UNITY_WII = PlatformActions.DoNothing;
/// whether or not this gameobject should be active on PS4
public PlatformActions UNITY_PS4 = PlatformActions.DoNothing;
/// whether or not this gameobject should be active on XBoxOne
public PlatformActions UNITY_XBOXONE = PlatformActions.DoNothing;
[Header("Others")]
/// whether or not this gameobject should be active on WebGL
public PlatformActions UNITY_WEBGL = PlatformActions.DoNothing;
/// whether or not this gameobject should be active on Lumin
public PlatformActions UNITY_LUMIN = PlatformActions.DoNothing;
/// whether or not this gameobject should be active on TVOS
public PlatformActions UNITY_TVOS = PlatformActions.DoNothing;
/// whether or not this gameobject should be active on WSA
public PlatformActions UNITY_WSA = PlatformActions.DoNothing;
/// whether or not this gameobject should be active on Facebook
public PlatformActions UNITY_FACEBOOK = PlatformActions.DoNothing;
/// whether or not this gameobject should be active on Ads
public PlatformActions UNITY_ADS = PlatformActions.DoNothing;
/// whether or not this gameobject should be active on Analytics
public PlatformActions UNITY_ANALYTICS = PlatformActions.DoNothing;
[Header("Active in Editor")]
/// whether or not this gameobject should be active in Editor
public PlatformActions UNITY_EDITOR = PlatformActions.DoNothing;
/// whether or not this gameobject should be active in Editor on Windows
public PlatformActions UNITY_EDITOR_WIN = PlatformActions.DoNothing;
/// whether or not this gameobject should be active in Editor on OSX
public PlatformActions UNITY_EDITOR_OSX = PlatformActions.DoNothing;
/// whether or not this gameobject should be active in Editor on Linux
public PlatformActions UNITY_EDITOR_LINUX = PlatformActions.DoNothing;
/// <summary>
/// On Enable, processes the state if needed
/// </summary>
protected virtual void OnEnable()
{
if (ExecutionTime == ExecutionTimes.OnEnable)
{
Process();
}
}
/// <summary>
/// On Awake, processes the state if needed
/// </summary>
protected virtual void Awake()
{
if (ExecutionTime == ExecutionTimes.Awake)
{
Process();
}
}
/// <summary>
/// On Start, processes the state if needed
/// </summary>
protected virtual void Start()
{
if (ExecutionTime == ExecutionTimes.Start)
{
Process();
}
}
/// <summary>
/// Enables or disables the object based on current platform
/// </summary>
protected virtual void Process()
{
// DESKTOP ----------------------------------------------------------------------------------
#if UNITY_STANDALONE_WIN
DisableIfNeeded(UNITY_STANDALONE_WIN, "Windows");
#endif
#if UNITY_STANDALONE_OSX
DisableIfNeeded(UNITY_STANDALONE_OSX, "OSX");
#endif
#if UNITY_STANDALONE_LINUX
DisableIfNeeded(UNITY_STANDALONE_LINUX, "Linux");
#endif
#if UNITY_STANDALONE
DisableIfNeeded(UNITY_STANDALONE, "Standalone");
#endif
// MOBILE ----------------------------------------------------------------------------------
#if UNITY_IOS
DisableIfNeeded(UNITY_IOS, "iOS");
#endif
#if UNITY_IPHONE
DisableIfNeeded(UNITY_IPHONE, "iPhone");
#endif
#if UNITY_ANDROID
DisableIfNeeded(UNITY_ANDROID, "Android");
#endif
#if UNITY_TIZEN
DisableIfNeeded(UNITY_TIZEN, "Tizen");
#endif
// CONSOLE ----------------------------------------------------------------------------------
#if UNITY_WII
DisableIfNeeded(UNITY_WII, "Wii");
#endif
#if UNITY_PS4
DisableIfNeeded(UNITY_PS4, "PS4");
#endif
#if UNITY_XBOXONE
DisableIfNeeded(UNITY_XBOXONE, "XBoxOne");
#endif
// CONSOLE ----------------------------------------------------------------------------------
#if UNITY_WEBGL
DisableIfNeeded(UNITY_WEBGL, "WebGL");
#endif
#if UNITY_LUMIN
DisableIfNeeded(UNITY_LUMIN, "Lumin");
#endif
#if UNITY_TVOS
DisableIfNeeded(UNITY_TVOS, "TV OS");
#endif
#if UNITY_WSA
DisableIfNeeded(UNITY_WSA, "WSA");
#endif
#if UNITY_FACEBOOK
DisableIfNeeded(UNITY_FACEBOOK, "Facebook");
#endif
#if UNITY_ADS
DisableIfNeeded(UNITY_ADS, "Ads");
#endif
#if UNITY_ANALYTICS
DisableIfNeeded(UNITY_ANALYTICS, "Analytics");
#endif
// EDITOR ----------------------------------------------------------------------------------
#if UNITY_EDITOR
DisableIfNeeded(UNITY_EDITOR, "Editor");
#endif
#if UNITY_EDITOR_WIN
DisableIfNeeded(UNITY_EDITOR_WIN, "Editor Windows");
#endif
#if UNITY_EDITOR_OSX
DisableIfNeeded(UNITY_EDITOR_OSX, "Editor OSX");
#endif
#if UNITY_EDITOR_LINUX
DisableIfNeeded(UNITY_EDITOR_LINUX, "Editor Linux");
#endif
}
/// <summary>
/// Disables the object if needed, and outputs a debug log if requested
/// </summary>
/// <param name="platform"></param>
/// <param name="platformName"></param>
protected virtual void DisableIfNeeded(PlatformActions platform, string platformName)
{
if (this.gameObject.activeInHierarchy && (platform == PlatformActions.Disable))
{
this.gameObject.SetActive(false);
if (DebugToTheConsole)
{
Debug.LogFormat(this.gameObject.name + " got disabled via MMPlatformActivation, platform : " + platformName + ".");
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5a39fcd2b055db14184fbda2b333f40c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,253 @@
using UnityEngine;
using System.Collections;
using UnityEngine.Events;
using System.Collections.Generic;
namespace MoreMountains.Tools
{
/// <summary>
/// Add this component to an object and it'll be auto destroyed X seconds after its Start()
/// </summary>
[AddComponentMenu("More Mountains/Tools/Activation/MMTimedActivation")]
public class MMTimedActivation : MonoBehaviour
{
/// the possible activation modes
public enum TimedStatusChange { Enable, Disable, Destroy }
/// the possible trigger modes
public enum ActivationModes { Awake, Start, OnEnable, OnTriggerEnter, OnTriggerExit, OnTriggerEnter2D, OnTriggerExit2D, Script }
/// the possible ways to check if the collider matches
public enum TriggerModes { None, Tag, Layer }
/// the possible delay modes
public enum DelayModes { Time, Frames }
[Header("Trigger Mode")]
/// the moment you want the countdown to state change to start
public ActivationModes ActivationMode = ActivationModes.Start;
/// the target layer for activation if using OnTriggerEnter or OnTriggerExit
[MMEnumCondition("ActivationMode", (int)ActivationModes.OnTriggerEnter, (int)ActivationModes.OnTriggerExit)]
public TriggerModes TriggerMode;
/// the layer the target collider should be on
[MMEnumCondition("TriggerMode", (int)TriggerModes.Layer)]
public LayerMask TargetTriggerLayer;
/// the tag the target collider should have
[MMEnumCondition("TriggerMode", (int)TriggerModes.Tag)]
public string TargetTriggerTag;
[Header("Delay")]
/// the chosen delay mode, whether to wait in seconds or frames
public DelayModes DelayMode = DelayModes.Time;
/// The time (in seconds) before we destroy the object
[MMEnumCondition("DelayMode", (int)DelayModes.Time)]
public float TimeBeforeStateChange = 2;
/// the amount of frames to wait for when in Frames DelayMode
[MMEnumCondition("DelayMode", (int)DelayModes.Frames)]
public int FrameCount = 1;
[Header("Timed Activation")]
/// the possible targets you want the state to change
public List<GameObject> TargetGameObjects;
/// the possible targets you want the state to change
public List<MonoBehaviour> TargetBehaviours;
/// the destruction mode for this object : destroy or disable
public TimedStatusChange TimeDestructionMode = TimedStatusChange.Disable;
[Header("Actions")]
/// Unity events to trigger after the delay
public UnityEvent TimedActions;
/// <summary>
/// On awake, initialize our delay and trigger our change state countdown if needed
/// </summary>
protected virtual void Awake()
{
if (ActivationMode == ActivationModes.Awake)
{
StartChangeState();
}
}
/// <summary>
/// Call this method to start the countdown to activation
/// </summary>
public virtual void TriggerSequence()
{
StartChangeState();
}
/// <summary>
/// On start, trigger our change state countdown if needed
/// </summary>
protected virtual void Start()
{
if (ActivationMode == ActivationModes.Start)
{
StartChangeState();
}
}
/// <summary>
/// On enable, trigger our change state countdown if needed
/// </summary>
protected virtual void OnEnable()
{
if (ActivationMode == ActivationModes.OnEnable)
{
StartChangeState();
}
}
/// <summary>
/// On trigger enter, we start our countdown if needed
/// </summary>
/// <param name="collider"></param>
protected virtual void OnTriggerEnter(Collider collider)
{
if ((ActivationMode == ActivationModes.OnTriggerEnter) && (CorrectTagOrLayer(collider.gameObject)))
{
StartChangeState();
}
}
/// <summary>
/// On trigger exit, we start our countdown if needed
/// </summary>
/// <param name="collider"></param>
protected virtual void OnTriggerExit(Collider collider)
{
if ((ActivationMode == ActivationModes.OnTriggerExit) && (CorrectTagOrLayer(collider.gameObject)))
{
StartChangeState();
}
}
/// <summary>
/// On trigger enter 2D, we start our countdown if needed
/// </summary>
/// <param name="collider"></param>
protected virtual void OnTriggerEnter2D(Collider2D collider)
{
if ((ActivationMode == ActivationModes.OnTriggerEnter2D) && (CorrectTagOrLayer(collider.gameObject)))
{
StartChangeState();
}
}
/// <summary>
/// On trigger exit 2D, we start our countdown if needed
/// </summary>
/// <param name="collider"></param>
protected virtual void OnTriggerExit2D(Collider2D collider)
{
if ((ActivationMode == ActivationModes.OnTriggerExit2D) && (CorrectTagOrLayer(collider.gameObject)))
{
StartChangeState();
}
}
/// <summary>
/// Returns true if the target matches our settings, false otherwise
/// </summary>
/// <param name="target"></param>
/// <returns></returns>
protected virtual bool CorrectTagOrLayer(GameObject target)
{
switch (TriggerMode)
{
case TriggerModes.None:
return true;
case TriggerModes.Layer:
if (((1 << target.layer) & TargetTriggerLayer) != 0)
{
return true;
}
else
{
return false;
}
case TriggerModes.Tag:
return (target.CompareTag(TargetTriggerTag));
}
return false;
}
/// <summary>
/// On start change state, starts the timed activation
/// </summary>
protected virtual void StartChangeState()
{
StartCoroutine(TimedActivationSequence());
}
/// <summary>
/// Waits and triggers state change and events
/// </summary>
protected virtual IEnumerator TimedActivationSequence()
{
if (DelayMode == DelayModes.Time)
{
yield return MMCoroutine.WaitFor(TimeBeforeStateChange);
}
else
{
yield return StartCoroutine(MMCoroutine.WaitForFrames(FrameCount));
}
StateChange();
Activate();
}
/// <summary>
/// Triggers actions if needed
/// </summary>
protected virtual void Activate()
{
if (TimedActions != null)
{
TimedActions.Invoke();
}
}
/// <summary>
/// Changes the object's status or destroys it
/// </summary>
protected virtual void StateChange()
{
foreach(GameObject targetGameObject in TargetGameObjects)
{
switch (TimeDestructionMode)
{
case TimedStatusChange.Destroy:
Destroy(targetGameObject);
break;
case TimedStatusChange.Disable:
targetGameObject.SetActive(false);
break;
case TimedStatusChange.Enable:
targetGameObject.SetActive(true);
break;
}
}
foreach (MonoBehaviour targetBehaviour in TargetBehaviours)
{
switch (TimeDestructionMode)
{
case TimedStatusChange.Destroy:
Destroy(targetBehaviour);
break;
case TimedStatusChange.Disable:
targetBehaviour.enabled = false;
break;
case TimedStatusChange.Enable:
targetBehaviour.enabled = true;
break;
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 46840d8dc203908469ee327b591ae35f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,45 @@
using UnityEngine;
using System.Collections;
namespace MoreMountains.Tools
{
/// <summary>
/// Add this component to an object and it'll be auto destroyed X seconds after its Start()
/// </summary>
[AddComponentMenu("More Mountains/Tools/Activation/MMTimedDestruction")]
public class MMTimedDestruction : MonoBehaviour
{
/// the possible destruction modes
public enum TimedDestructionModes { Destroy, Disable }
/// the destruction mode for this object : destroy or disable
public TimedDestructionModes TimeDestructionMode = TimedDestructionModes.Destroy;
/// The time (in seconds) before we destroy the object
public float TimeBeforeDestruction=2;
/// <summary>
/// On Start(), we schedule the object's destruction
/// </summary>
protected virtual void Start ()
{
StartCoroutine(Destruction());
}
/// <summary>
/// Destroys the object after TimeBeforeDestruction seconds
/// </summary>
protected virtual IEnumerator Destruction()
{
yield return MMCoroutine.WaitFor(TimeBeforeDestruction);
if (TimeDestructionMode == TimedDestructionModes.Destroy)
{
Destroy(gameObject);
}
else
{
gameObject.SetActive(false);
}
}
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 9e71ad30bf1524741b90c1bd0354e1e0
timeCreated: 1523894079
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,39 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Tools
{
/// <summary>
/// This very simple class simply exposes a method to toggle the GameObject it's on (or a target one if left empty in the inspector) active or inactive
/// </summary>
public class MMToggleActive : MonoBehaviour
{
[Header("Target - leave empty for self")]
/// the target gameobject to toggle. Leave blank for auto grab
public GameObject TargetGameObject;
/// a test button
[MMInspectorButton("ToggleActive")]
public bool ToggleActiveButton;
/// <summary>
/// On awake, grabs self if needed
/// </summary>
protected virtual void Awake()
{
if (TargetGameObject == null)
{
TargetGameObject = this.gameObject;
}
}
/// <summary>
/// Toggles the target gameobject's active state
/// </summary>
public virtual void ToggleActive()
{
TargetGameObject.SetActive(!TargetGameObject.activeInHierarchy);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3aad8b45814dc6f4cab32abed0a152b8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,143 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using MoreMountains.Tools;
using UnityEngine.Events;
namespace MoreMountains.Tools
{
[AddComponentMenu("More Mountains/Tools/Activation/MMTriggerAndCollision")]
public class MMTriggerAndCollision : MonoBehaviour
{
public LayerMask CollisionLayerMask;
public UnityEvent OnCollisionEnterEvent;
public UnityEvent OnCollisionExitEvent;
public UnityEvent OnCollisionStayEvent;
public LayerMask TriggerLayerMask;
public UnityEvent OnTriggerEnterEvent;
public UnityEvent OnTriggerExitEvent;
public UnityEvent OnTriggerStayEvent;
public LayerMask Collision2DLayerMask;
public UnityEvent OnCollision2DEnterEvent;
public UnityEvent OnCollision2DExitEvent;
public UnityEvent OnCollision2DStayEvent;
public LayerMask Trigger2DLayerMask;
public UnityEvent OnTrigger2DEnterEvent;
public UnityEvent OnTrigger2DExitEvent;
public UnityEvent OnTrigger2DStayEvent;
// Collision 2D ------------------------------------------------------------------------------------
protected virtual void OnCollisionEnter2D (Collision2D collision)
{
if (Collision2DLayerMask.MMContains (collision.gameObject))
{
OnCollision2DEnterEvent.Invoke();
}
}
protected virtual void OnCollisionExit2D (Collision2D collision)
{
if (Collision2DLayerMask.MMContains (collision.gameObject))
{
OnCollision2DExitEvent.Invoke();
}
}
protected virtual void OnCollisionStay2D (Collision2D collision)
{
if (Collision2DLayerMask.MMContains (collision.gameObject))
{
OnCollision2DStayEvent.Invoke();
}
}
// Trigger 2D ------------------------------------------------------------------------------------
protected virtual void OnTriggerEnter2D (Collider2D collider)
{
if (Trigger2DLayerMask.MMContains (collider.gameObject))
{
OnTrigger2DEnterEvent.Invoke();
}
}
protected virtual void OnTriggerExit2D (Collider2D collider)
{
if (Trigger2DLayerMask.MMContains (collider.gameObject))
{
OnTrigger2DExitEvent.Invoke();
}
}
protected virtual void OnTriggerStay2D (Collider2D collider)
{
if (Trigger2DLayerMask.MMContains (collider.gameObject))
{
OnTrigger2DStayEvent.Invoke();
}
}
// Collision ------------------------------------------------------------------------------------
protected virtual void OnCollisionEnter(Collision c)
{
if (0 != (CollisionLayerMask.value & 1 << c.transform.gameObject.layer))
{
OnCollisionEnterEvent.Invoke();
}
}
protected virtual void OnCollisionExit(Collision c)
{
if (0 != (CollisionLayerMask.value & 1 << c.transform.gameObject.layer))
{
OnCollisionExitEvent.Invoke();
}
}
protected virtual void OnCollisionStay(Collision c)
{
if (0 != (CollisionLayerMask.value & 1 << c.transform.gameObject.layer))
{
OnCollisionStayEvent.Invoke();
}
}
// Trigger ------------------------------------------------------------------------------------
protected virtual void OnTriggerEnter (Collider collider)
{
if (TriggerLayerMask.MMContains (collider.gameObject))
{
OnTriggerEnterEvent.Invoke();
}
}
protected virtual void OnTriggerExit (Collider collider)
{
if (TriggerLayerMask.MMContains (collider.gameObject))
{
OnTriggerExitEvent.Invoke();
}
}
protected virtual void OnTriggerStay (Collider collider)
{
if (TriggerLayerMask.MMContains (collider.gameObject))
{
OnTriggerStayEvent.Invoke();
}
}
protected virtual void Reset()
{
Collision2DLayerMask = LayerMask.NameToLayer("Everything");
CollisionLayerMask = LayerMask.NameToLayer("Everything");
}
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 007ea1391362e4845aee91886eb0cda3
timeCreated: 1523908029
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,157 @@
using UnityEngine;
namespace MoreMountains.Tools
{
[System.Flags]
public enum TriggerAndCollisionMask
{
IgnoreAll = 0,
OnTriggerEnter = 1 << 0,
OnTriggerStay = 1 << 1,
OnTriggerExit = 1 << 2,
OnCollisionEnter = 1 << 3,
OnCollisionStay = 1 << 4,
OnCollisionExit = 1 << 5,
OnTriggerEnter2D = 1 << 6,
OnTriggerStay2D = 1 << 7,
OnTriggerExit2D = 1 << 8,
OnCollisionEnter2D = 1 << 9,
OnCollisionStay2D = 1 << 10,
OnCollisionExit2D = 1 << 11,
OnAnyTrigger3D = OnTriggerEnter | OnTriggerStay | OnTriggerExit,
OnAnyCollision3D = OnCollisionEnter | OnCollisionStay | OnCollisionExit,
OnAnyTrigger2D = OnTriggerEnter2D | OnTriggerStay2D | OnTriggerExit2D,
OnAnyCollision2D = OnCollisionEnter2D | OnCollisionStay2D | OnCollisionExit2D,
OnAnyTrigger = OnAnyTrigger3D | OnAnyTrigger2D,
OnAnyCollision = OnAnyCollision3D | OnAnyCollision2D,
All_3D = OnAnyTrigger3D | OnAnyCollision3D,
All_2D = OnAnyTrigger2D | OnAnyCollision2D,
All = All_3D | All_2D,
}
public abstract class MMTriggerAndCollisionFilter : MonoBehaviour
{
public TriggerAndCollisionMask TriggerAndCollisionFilter = TriggerAndCollisionMask.All;
// Tested to check if callback should be used or ignored
protected virtual bool UseEvent(TriggerAndCollisionMask value) => 0 != (TriggerAndCollisionFilter & value);
// Collision 2D ------------------------------------------------------------------------------------
protected abstract void OnCollisionEnter2D_(Collision2D collision);
void OnCollisionEnter2D (Collision2D collision)
{
if (UseEvent(TriggerAndCollisionMask.OnCollisionEnter2D))
{
OnCollisionEnter2D_(collision);
}
}
protected abstract void OnCollisionExit2D_(Collision2D collision);
void OnCollisionExit2D (Collision2D collision)
{
if (UseEvent(TriggerAndCollisionMask.OnCollisionExit2D))
{
OnCollisionExit2D_(collision);
}
}
protected abstract void OnCollisionStay2D_(Collision2D collision);
void OnCollisionStay2D (Collision2D collision)
{
if (UseEvent(TriggerAndCollisionMask.OnCollisionStay2D))
{
OnCollisionStay2D_(collision);
}
}
// Trigger 2D ------------------------------------------------------------------------------------
protected abstract void OnTriggerEnter2D_(Collider2D collider);
void OnTriggerEnter2D (Collider2D collider)
{
if (UseEvent(TriggerAndCollisionMask.OnTriggerEnter2D))
{
OnTriggerEnter2D_(collider);
}
}
protected abstract void OnTriggerExit2D_(Collider2D collider);
void OnTriggerExit2D (Collider2D collider)
{
if (UseEvent(TriggerAndCollisionMask.OnTriggerExit2D))
{
OnTriggerExit2D_(collider);
}
}
protected abstract void OnTriggerStay2D_ (Collider2D collider);
void OnTriggerStay2D (Collider2D collider)
{
if (UseEvent(TriggerAndCollisionMask.OnTriggerStay2D))
{
OnTriggerStay2D_(collider);
}
}
// Collision ------------------------------------------------------------------------------------
protected abstract void OnCollisionEnter_ (Collision c);
void OnCollisionEnter(Collision c)
{
if (UseEvent(TriggerAndCollisionMask.OnCollisionEnter))
{
OnCollisionEnter_(c);
}
}
protected abstract void OnCollisionExit_ (Collision c);
void OnCollisionExit(Collision c)
{
if (UseEvent(TriggerAndCollisionMask.OnCollisionExit))
{
OnCollisionExit_(c);
}
}
protected abstract void OnCollisionStay_ (Collision c);
void OnCollisionStay(Collision c)
{
if (UseEvent(TriggerAndCollisionMask.OnCollisionStay))
{
OnCollisionStay_(c);
}
}
// Trigger ------------------------------------------------------------------------------------
protected abstract void OnTriggerEnter_(Collider collider);
void OnTriggerEnter (Collider collider)
{
if (UseEvent(TriggerAndCollisionMask.OnTriggerEnter))
{
OnTriggerEnter_(collider);
}
}
protected abstract void OnTriggerExit_(Collider collider);
void OnTriggerExit (Collider collider)
{
if (UseEvent(TriggerAndCollisionMask.OnTriggerExit))
{
OnTriggerExit_(collider);
}
}
protected abstract void OnTriggerStay_(Collider collider);
void OnTriggerStay (Collider collider)
{
if (UseEvent(TriggerAndCollisionMask.OnTriggerStay))
{
OnTriggerStay_(collider);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5cc2d50cc470a8b448cb93411e66d069
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,78 @@
using System;
using System.Web;
using UnityEngine;
namespace MoreMountains.Tools
{
public abstract class MMTriggerFilter : MonoBehaviour
{
public TriggerAndCollisionMask TriggerFilter = TriggerAndCollisionMask.All;
protected virtual void OnValidate()
{
// Only allow trigger related bits
TriggerFilter &= TriggerAndCollisionMask.OnAnyTrigger;
}
protected virtual bool UseEvent(TriggerAndCollisionMask value) => 0 != (TriggerFilter & value);
// Trigger 2D ------------------------------------------------------------------------------------
protected abstract void OnTriggerEnter2D_(Collider2D collider);
void OnTriggerEnter2D (Collider2D collider)
{
if (UseEvent(TriggerAndCollisionMask.OnTriggerEnter2D))
{
OnTriggerEnter2D_(collider);
}
}
protected abstract void OnTriggerExit2D_(Collider2D collider);
void OnTriggerExit2D (Collider2D collider)
{
if (UseEvent(TriggerAndCollisionMask.OnTriggerExit2D))
{
OnTriggerExit2D_(collider);
}
}
protected abstract void OnTriggerStay2D_ (Collider2D collider);
void OnTriggerStay2D (Collider2D collider)
{
if (UseEvent(TriggerAndCollisionMask.OnTriggerStay2D))
{
OnTriggerStay2D_(collider);
}
}
// Trigger ------------------------------------------------------------------------------------
protected abstract void OnTriggerEnter_(Collider collider);
void OnTriggerEnter (Collider collider)
{
if (UseEvent(TriggerAndCollisionMask.OnTriggerEnter))
{
OnTriggerEnter_(collider);
}
}
protected abstract void OnTriggerExit_(Collider collider);
void OnTriggerExit (Collider collider)
{
if (UseEvent(TriggerAndCollisionMask.OnTriggerExit))
{
OnTriggerExit_(collider);
}
}
protected abstract void OnTriggerStay_(Collider collider);
void OnTriggerStay (Collider collider)
{
if (UseEvent(TriggerAndCollisionMask.OnTriggerStay))
{
OnTriggerStay_(collider);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8583d7ca8b7ea2c418257447cb3032f9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bcac673537fad024f8be0aea6ced689b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,57 @@
using UnityEngine;
using System.Collections;
namespace MoreMountains.Tools
{
/// <summary>
/// Add this script to an animation in Mecanim and you'll be able to control its start position and speed
/// </summary>
[AddComponentMenu("More Mountains/Tools/Animation/MMAnimationModifier")]
public class MMAnimationModifier : StateMachineBehaviour
{
[MMVectorAttribute("Min", "Max")]
/// the min and max values for the start position of the animation (between 0 and 1)
public Vector2 StartPosition = new Vector2(0, 0);
[MMVectorAttribute("Min", "Max")]
/// the min and max values for the animation speed (1 is normal)
public Vector2 AnimationSpeed = new Vector2(1, 1);
protected bool _enteredState = false;
protected float _initialSpeed;
/// <summary>
/// On state enter, we modify our speed and start position
/// </summary>
/// <param name="animator"></param>
/// <param name="stateInfo"></param>
/// <param name="layerIndex"></param>
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
base.OnStateEnter(animator, stateInfo, layerIndex);
// handle speed
_initialSpeed = animator.speed;
animator.speed = Random.Range(AnimationSpeed.x, AnimationSpeed.y);
// handle start position
if (!_enteredState)
{
animator.Play(stateInfo.fullPathHash, layerIndex, Random.Range(StartPosition.x, StartPosition.y));
}
_enteredState = !_enteredState;
}
/// <summary>
/// On state exit, we restore our speed
/// </summary>
/// <param name="animator"></param>
/// <param name="stateInfo"></param>
/// <param name="layerIndex"></param>
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
base.OnStateExit(animator, stateInfo, layerIndex);
animator.speed = _initialSpeed;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6ba4bd496d6656d4da1541ce7071ed10
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,68 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Tools
{
/// <summary>
/// A helper class that will hash a animation parameter and update it on demand
/// </summary>
[AddComponentMenu("More Mountains/Tools/Animation/MMAnimationParameter")]
public class MMAnimationParameter : MonoBehaviour
{
/// the name of the animation parameter to hash
public string ParameterName;
/// the animator to update
public Animator TargetAnimator;
protected int _parameter;
/// <summary>
/// On awake we initialize our class
/// </summary>
protected virtual void Awake()
{
Initialization();
}
/// <summary>
/// Hashes the parameter name into an int
/// </summary>
protected virtual void Initialization()
{
_parameter = Animator.StringToHash(ParameterName);
}
/// <summary>
/// Sets the trigger of the specified name
/// </summary>
public virtual void SetTrigger()
{
TargetAnimator.SetTrigger(_parameter);
}
/// <summary>
/// Sets the int of the specified name to the specified value
/// </summary>
public virtual void SetInt(int value)
{
TargetAnimator.SetInteger(_parameter, value);
}
/// <summary>
/// Sets the float of the specified name to the specified value
/// </summary>
public virtual void SetFloat(float value)
{
TargetAnimator.SetFloat(_parameter, value);
}
/// <summary>
/// Sets the bool of the specified name to the specified value
/// </summary>
public virtual void SetBool(bool value)
{
TargetAnimator.SetBool(_parameter, value);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5451e999c8f9dfb41aa3b2894ffc3d60
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,133 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Tools
{
/// <summary>
/// This class will let you mirror the behaviour of an Animator's parameters on a Source Animator onto the ones of a Target Animator.
/// Target will mirror Source.
/// Only the parameters existing on both Target and Source will be considered, you'll need to have the same on both before entering runtime.
/// </summary>
public class MMAnimatorMirror : MonoBehaviour
{
/// a struct used to store bindings
public struct MMAnimatorMirrorBind
{
public int ParameterHash;
public AnimatorControllerParameterType ParameterType;
}
[Header("Bindings")]
/// the animator to mirror
public Animator SourceAnimator;
/// the animator to mirror to
public Animator TargetAnimator;
protected AnimatorControllerParameter[] _sourceParameters;
protected AnimatorControllerParameter[] _targetParameters;
protected List<MMAnimatorMirrorBind> _updateParameters;
/// <summary>
/// On Awake we initialize
/// </summary>
protected virtual void Awake()
{
Initialization();
}
/// <summary>
/// Stores animation parameters hashes
/// </summary>
public virtual void Initialization()
{
if (TargetAnimator == null)
{
TargetAnimator = this.gameObject.GetComponent<Animator>();
}
if ((TargetAnimator == null) || (SourceAnimator == null))
{
return;
}
// we store our source parameters
int numberOfParameters = SourceAnimator.parameterCount;
_sourceParameters = new AnimatorControllerParameter[numberOfParameters];
for (int i = 0; i < numberOfParameters; i++)
{
_sourceParameters[i] = SourceAnimator.GetParameter(i);
}
// we store our target parameters
numberOfParameters = TargetAnimator.parameterCount;
_targetParameters = new AnimatorControllerParameter[numberOfParameters];
for (int i = 0; i < numberOfParameters; i++)
{
_targetParameters[i] = TargetAnimator.GetParameter(i);
}
// we store our matching parameters
_updateParameters = new List<MMAnimatorMirrorBind>();
foreach (AnimatorControllerParameter sourceParam in _sourceParameters)
{
foreach (AnimatorControllerParameter targetParam in _targetParameters)
{
if (sourceParam.name == targetParam.name)
{
MMAnimatorMirrorBind bind = new MMAnimatorMirrorBind();
bind.ParameterHash = sourceParam.nameHash;
bind.ParameterType = sourceParam.type;
_updateParameters.Add(bind);
}
}
}
}
/// <summary>
/// On Update we mirror our behaviours
/// </summary>
protected virtual void Update()
{
Mirror();
}
/// <summary>
/// Copies animation parameter states from one animator to the other
/// </summary>
protected virtual void Mirror()
{
if ((TargetAnimator == null) || (SourceAnimator == null))
{
return;
}
foreach (MMAnimatorMirrorBind bind in _updateParameters)
{
switch (bind.ParameterType)
{
case AnimatorControllerParameterType.Bool:
TargetAnimator.SetBool(bind.ParameterHash, SourceAnimator.GetBool(bind.ParameterHash));
break;
case AnimatorControllerParameterType.Float:
TargetAnimator.SetFloat(bind.ParameterHash, SourceAnimator.GetFloat(bind.ParameterHash));
break;
case AnimatorControllerParameterType.Int:
TargetAnimator.SetInteger(bind.ParameterHash, SourceAnimator.GetInteger(bind.ParameterHash));
break;
case AnimatorControllerParameterType.Trigger:
if (SourceAnimator.GetBool(bind.ParameterHash))
{
TargetAnimator.SetTrigger(bind.ParameterHash);
}
else
{
TargetAnimator.ResetTrigger(bind.ParameterHash);
}
break;
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e5d1374627ebc7d4491c7eb256713f69
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,74 @@
using UnityEngine;
using System.Collections;
namespace MoreMountains.Tools
{
/// <summary>
/// Use this class to offset an animation by a random range
/// </summary>
[RequireComponent(typeof(Animator))]
[AddComponentMenu("More Mountains/Tools/Animation/MMOffsetAnimation")]
public class MMOffsetAnimation : MonoBehaviour
{
/// the minimum amount (in seconds) by which to offset the animation
public float MinimumRandomRange = 0f;
/// the maximum amount (in seconds) by which to offset the animation
public float MaximumRandomRange = 1f;
/// the layer to affect
public int AnimationLayerID = 0;
/// whether or not to apply that offset on Start
public bool OffsetOnStart = true;
/// whether or not to offset animation on enable
public bool OffsetOnEnable = false;
/// whether or not to self disable after offsetting
public bool DisableAfterOffset = true;
protected Animator _animator;
protected AnimatorStateInfo _stateInfo;
/// <summary>
/// On awake we store our animator
/// </summary>
protected virtual void Awake()
{
_animator = this.gameObject.GetComponent<Animator>();
}
/// <summary>
/// On Start we offset our animation
/// </summary>
protected virtual void Start()
{
if (!OffsetOnStart)
{
return;
}
OffsetCurrentAnimation();
}
/// <summary>
/// On Enable we offset our animation if needed
/// </summary>
protected virtual void OnEnable()
{
if (!OffsetOnEnable)
{
return;
}
OffsetCurrentAnimation();
}
/// <summary>
/// offsets the target animation
/// </summary>
public virtual void OffsetCurrentAnimation()
{
_stateInfo = _animator.GetCurrentAnimatorStateInfo(AnimationLayerID);
_animator.Play(_stateInfo.fullPathHash, -1, Random.Range(MinimumRandomRange, MaximumRandomRange));
if (DisableAfterOffset)
{
this.enabled = false;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9c77c6d59898ea34989b338214db7de1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,326 @@
using UnityEngine;
using System.Collections.Generic;
namespace MoreMountains.Tools
{
/// <summary>
/// A class used to store ragdoll body parts informations
/// </summary>
public class RagdollBodyPart
{
public Transform BodyPartTransform;
public Vector3 StoredPosition;
public Quaternion StoredRotation;
}
/// <summary>
/// Use this class to pilot a ragdoll on a character that is usually driven by an animator and have it fall elegantly
/// If you have parts of your ragdoll that you don't want to be affected by this script (a weapon for example), just add a MMRagdollerIgnore component to them
/// </summary>
[AddComponentMenu("More Mountains/Tools/Animation/MMRagdoller")]
public class MMRagdoller : MonoBehaviour
{
/// <summary>
/// The possible states of the ragdoll :
/// - animated : driven by an animator controller, rigidbodies asleep
/// - ragdolling : full ragdoll mode, purely physics driven
/// - blending : transitioning between ragdolling and animated
/// </summary>
public enum RagdollStates
{
Animated,
Ragdolling,
Blending
}
[Header("Ragdoll")]
/// the current state of the ragdoll
public RagdollStates CurrentState = RagdollStates.Animated;
/// the duration in seconds it takes to blend from Ragdolling to Animated
public float RagdollToMecanimBlendDuration = 0.5f;
[Header("Rigidbodies")]
/// The rigidbody attached to the main body part of the ragdoll (usually the Pelvis)
public Rigidbody MainRigidbody;
/// if this is true, all rigidbodies will be forced to sleep every frame
public bool ForceSleep = true;
/// whether or not blending will occur when going from ragdolling to animated
public bool AllowBlending = true;
protected float _mecanimToGetUpTransitionTime = 0.05f;
protected float _ragdollingEndTimestamp = -float.MaxValue;
protected Vector3 _ragdolledHipPosition;
protected Vector3 _ragdolledHeadPosition;
protected Vector3 _ragdolledFeetPosition;
protected List<RagdollBodyPart> _bodyparts = new List<RagdollBodyPart>();
protected Animator _animator;
protected List<Component> _rigidbodiesTempList;
protected Component[] _rigidbodies;
protected HashSet<int> _animatorParameters;
protected const string _getUpFromBackAnimationParameterName = "GetUpFromBack";
protected int _getUpFromBackAnimationParameter;
protected const string _getUpFromBellyAnimationParameterName = "GetUpFromBelly";
protected int _getUpFromBellyAnimationParameter;
protected bool _initialized = false;
/// <summary>
/// Use this to get the current state of the ragdoll or to set a new one
/// </summary>
public bool Ragdolling
{
get
{
// if we're not animated, we're ragdolling
return CurrentState != RagdollStates.Animated;
}
set
{
if (value == true)
{
// if we're
if (CurrentState == RagdollStates.Animated)
{
SetIsKinematic(false);
_animator.enabled = false;
CurrentState = RagdollStates.Ragdolling;
MMAnimatorExtensions.UpdateAnimatorBool(_animator, _getUpFromBackAnimationParameter, false, _animatorParameters);
MMAnimatorExtensions.UpdateAnimatorBool(_animator, _getUpFromBellyAnimationParameter, false, _animatorParameters);
}
}
else
{
if (CurrentState == RagdollStates.Ragdolling)
{
SetIsKinematic(true);
_ragdollingEndTimestamp = Time.time;
_animator.enabled = true;
CurrentState = AllowBlending ? RagdollStates.Blending: RagdollStates.Animated;
foreach (RagdollBodyPart bodypart in _bodyparts)
{
bodypart.StoredRotation = bodypart.BodyPartTransform.rotation;
bodypart.StoredPosition = bodypart.BodyPartTransform.position;
}
_ragdolledFeetPosition = 0.5f * (_animator.GetBoneTransform(HumanBodyBones.LeftToes).position + _animator.GetBoneTransform(HumanBodyBones.RightToes).position);
_ragdolledHeadPosition = _animator.GetBoneTransform(HumanBodyBones.Head).position;
_ragdolledHipPosition = _animator.GetBoneTransform(HumanBodyBones.Hips).position;
if (_animator.GetBoneTransform(HumanBodyBones.Hips).forward.y > 0)
{
MMAnimatorExtensions.UpdateAnimatorBool(_animator, _getUpFromBackAnimationParameter, true, _animatorParameters);
}
else
{
MMAnimatorExtensions.UpdateAnimatorBool(_animator, _getUpFromBellyAnimationParameter, true, _animatorParameters);
}
}
}
}
}
/// <summary>
/// On start we initialize our ragdoller
/// </summary>
protected virtual void Start()
{
Initialization();
}
/// <summary>
/// Grabs rigidbodies, adds body parts and stores the animator
/// </summary>
protected virtual void Initialization()
{
// we grab all rigidbodies and set them to kinematic
_rigidbodies = GetComponentsInChildren(typeof(Rigidbody));
_rigidbodiesTempList = new List<Component>();
foreach (Component rigidbody in _rigidbodies)
{
if (rigidbody.gameObject.MMGetComponentNoAlloc<MMRagdollerIgnore>() == null)
{
_rigidbodiesTempList.Add(rigidbody);
}
}
_rigidbodies = null;
_rigidbodies = _rigidbodiesTempList.ToArray();
if (CurrentState == RagdollStates.Animated)
{
SetIsKinematic(true);
}
else
{
SetIsKinematic(false);
}
// we grab all transforms and add a RagdollBodyPart to them
Component[] transforms = GetComponentsInChildren(typeof(Transform));
foreach (Component component in transforms)
{
if (component.transform != this.transform)
{
RagdollBodyPart bodyPart = new RagdollBodyPart { BodyPartTransform = component as Transform };
_bodyparts.Add(bodyPart);
}
}
// we store our animator
_animator = this.gameObject.GetComponent<Animator>();
RegisterAnimatorParameters();
_initialized = true;
}
/// <summary>
/// Registers our animation parameters
/// </summary>
protected virtual void RegisterAnimatorParameters()
{
_animatorParameters = new HashSet<int>();
_getUpFromBackAnimationParameter = Animator.StringToHash(_getUpFromBackAnimationParameterName);
_getUpFromBellyAnimationParameter = Animator.StringToHash(_getUpFromBellyAnimationParameterName);
if (_animator == null)
{
return;
}
if (_animator.MMHasParameterOfType(_getUpFromBackAnimationParameterName, AnimatorControllerParameterType.Bool))
{
_animatorParameters.Add(_getUpFromBackAnimationParameter);
}
if (_animator.MMHasParameterOfType(_getUpFromBellyAnimationParameterName, AnimatorControllerParameterType.Bool))
{
_animatorParameters.Add(_getUpFromBellyAnimationParameter);
}
}
/// <summary>
/// Sets all rigidbodies in the ragdoll to kinematic and stops them from detecting collisions (or the other way around)
/// </summary>
/// <param name="isKinematic"></param>
protected virtual void SetIsKinematic(bool isKinematic)
{
foreach (Component rigidbody in _rigidbodies)
{
if (rigidbody.transform != this.transform)
{
(rigidbody as Rigidbody).detectCollisions = !isKinematic;
(rigidbody as Rigidbody).isKinematic = isKinematic;
}
}
}
/// <summary>
/// Forces all rigidbodies in the ragdoll to sleep
/// </summary>
public virtual void ForceRigidbodiesToSleep()
{
foreach (Component rigidbody in _rigidbodies)
{
if (rigidbody.transform != this.transform)
{
(rigidbody as Rigidbody).Sleep();
}
}
}
/// <summary>
/// On late update, we force our ragdoll elements to sleep and handle blending
/// </summary>
protected virtual void LateUpdate()
{
if ((CurrentState == RagdollStates.Animated) && ForceSleep)
{
ForceRigidbodiesToSleep();
}
HandleBlending();
}
/// <summary>
/// Blends between ragdolling and animated and switches to Animated at the end
/// </summary>
protected virtual void HandleBlending()
{
if (CurrentState == RagdollStates.Blending)
{
if (Time.time <= _ragdollingEndTimestamp + _mecanimToGetUpTransitionTime)
{
transform.position = GetRootPosition();
Vector3 ragdollingDirection = _ragdolledHeadPosition - _ragdolledFeetPosition;
ragdollingDirection.y = 0;
Vector3 meanFeetPosition = 0.5f * (_animator.GetBoneTransform(HumanBodyBones.LeftFoot).position + _animator.GetBoneTransform(HumanBodyBones.RightFoot).position);
Vector3 animatedDirection = _animator.GetBoneTransform(HumanBodyBones.Head).position - meanFeetPosition;
animatedDirection.y = 0;
transform.rotation *= Quaternion.FromToRotation(animatedDirection.normalized, ragdollingDirection.normalized);
}
float ragdollBlendAmount = 1.0f - (Time.time - _ragdollingEndTimestamp - _mecanimToGetUpTransitionTime) / RagdollToMecanimBlendDuration;
ragdollBlendAmount = Mathf.Clamp01(ragdollBlendAmount);
foreach (RagdollBodyPart bodypart in _bodyparts)
{
if (bodypart.BodyPartTransform != transform)
{
if (bodypart.BodyPartTransform == _animator.GetBoneTransform(HumanBodyBones.Hips))
{
bodypart.BodyPartTransform.position = Vector3.Lerp(bodypart.BodyPartTransform.position, bodypart.StoredPosition, ragdollBlendAmount);
}
bodypart.BodyPartTransform.rotation = Quaternion.Slerp(bodypart.BodyPartTransform.rotation, bodypart.StoredRotation, ragdollBlendAmount);
}
}
if (ragdollBlendAmount == 0)
{
CurrentState = RagdollStates.Animated;
return;
}
}
}
/// <summary>
/// Returns the current position of the ragdoll (technically the hips position)
/// </summary>
/// <returns></returns>
public Vector3 GetPosition()
{
if (!_initialized)
{
Initialization();
}
Vector3 newPosition = (_animator.GetBoneTransform(HumanBodyBones.Hips) == null) ? MainRigidbody.position : _animator.GetBoneTransform(HumanBodyBones.Hips).position;
return newPosition;
}
/// <summary>
/// Returns the offset root position
/// </summary>
/// <returns></returns>
protected Vector3 GetRootPosition()
{
Vector3 ragdollPosition = (_animator.GetBoneTransform(HumanBodyBones.Hips) == null) ? MainRigidbody.position : _animator.GetBoneTransform(HumanBodyBones.Hips).position;
Vector3 animatedToRagdolling = _ragdolledHipPosition - ragdollPosition;
Vector3 newRootPosition = transform.position + animatedToRagdolling;
RaycastHit[] hits = Physics.RaycastAll(new Ray(newRootPosition, Vector3.down));
newRootPosition.y = 0;
foreach (RaycastHit hit in hits)
{
if (!hit.transform.IsChildOf(transform))
{
newRootPosition.y = Mathf.Max(newRootPosition.y, hit.point.y);
}
}
return newRootPosition;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9687a46a55ccbca4f92cdff319b70844
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace MoreMountains.Tools
{
/// <summary>
/// Add this class to objects you'd like to be unaffected by the MMRagdoller (like weapons for example)
/// </summary>
[AddComponentMenu("More Mountains/Tools/Animation/MMRagdollerIgnore")]
public class MMRagdollerIgnore : MonoBehaviour
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 38f5f99a403324842b72d7bb5d781405
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,94 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MoreMountains.Tools
{
[AddComponentMenu("More Mountains/Tools/Animation/MMStopMotionAnimation")]
public class MMStopMotionAnimation : MonoBehaviour
{
public enum FramerateModes { Manual, Automatic }
[Header("General Settings")]
public bool StopMotionEnabled = true;
public int AnimationLayerID = 0;
[Header("Framerate")]
public FramerateModes FramerateMode = FramerateModes.Automatic;
[MMEnumCondition("FramerateMode", (int)FramerateModes.Automatic)]
public float FramesPerSecond = 4f;
[MMEnumCondition("FramerateMode", (int)FramerateModes.Automatic)]
public float PollFrequency = 1f;
[MMEnumCondition("FramerateMode", (int)FramerateModes.Manual)]
public float ManualTimeBetweenFrames = 0.125f;
[MMEnumCondition("FramerateMode", (int)FramerateModes.Manual)]
public float ManualAnimatorSpeed = 2;
public float timet = 0;
protected float _currentClipFPS = 0;
protected float _currentClipLength = 0f;
protected float _lastPollAt = -10f;
protected Animator _animator;
protected AnimationClip _currentClip;
protected virtual void Awake()
{
_animator = this.gameObject.GetComponent<Animator>();
}
protected virtual void Update()
{
StopMotion();
if (Time.time - _lastPollAt > PollFrequency)
{
Poll();
}
}
protected virtual void StopMotion()
{
if (!StopMotionEnabled)
{
return;
}
float timeBetweenFrames = 0f;
float animatorSpeed = 0f;
switch(FramerateMode)
{
case FramerateModes.Manual:
timeBetweenFrames = ManualTimeBetweenFrames;
animatorSpeed = ManualAnimatorSpeed;
break;
case FramerateModes.Automatic:
timeBetweenFrames = (1 / FramesPerSecond);
animatorSpeed = (1 / (FramesPerSecond - 1)) * 2f * _currentClipFPS;
break;
}
timet += Time.deltaTime;
if (timet > timeBetweenFrames)
{
timet -= timeBetweenFrames;
_animator.speed = animatorSpeed;
}
else
{
_animator.speed = 0;
}
}
protected virtual void Poll()
{
_currentClip = _animator.GetCurrentAnimatorClipInfo(AnimationLayerID)[0].clip;
_currentClipLength = _currentClip.length;
_currentClipFPS = _currentClip.frameRate;
_lastPollAt = Time.time;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 409ecbe35fc2afd4b82ade0142839256
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 35da110902fbc43f79f283baf2a738c6
folderAsset: yes
timeCreated: 1459528287
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,29 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
namespace MoreMountains.Tools
{
public enum MMBackgroundAttributeColor
{
Red,
Pink,
Orange,
Yellow,
Green,
Blue,
Violet,
White
}
public class MMBackgroundColorAttribute : PropertyAttribute
{
public MMBackgroundAttributeColor Color;
public MMBackgroundColorAttribute(MMBackgroundAttributeColor color = MMBackgroundAttributeColor.Yellow)
{
this.Color = color;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3d940d484781c4040921ce29789b1943
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
namespace MoreMountains.Tools
{
public class MMColorAttribute : PropertyAttribute
{
public Color color;
public MMColorAttribute(float red = 1, float green = 0, float blue = 0)
{
this.color = new Color(red, green, blue, 1);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 44a39707cf7142b45a78bb9d0e5ebfa5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,39 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace MoreMountains.Tools
{
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Struct, Inherited = true)]
public class MMConditionAttribute : PropertyAttribute
{
public string ConditionBoolean = "";
public bool Hidden = false;
public bool Negative = false;
public MMConditionAttribute(string conditionBoolean)
{
this.ConditionBoolean = conditionBoolean;
this.Hidden = false;
}
public MMConditionAttribute(string conditionBoolean, bool hideInInspector)
{
this.ConditionBoolean = conditionBoolean;
this.Hidden = hideInInspector;
this.Negative = false;
}
public MMConditionAttribute(string conditionBoolean, bool hideInInspector, bool negative)
{
this.ConditionBoolean = conditionBoolean;
this.Hidden = hideInInspector;
this.Negative = negative;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d99b1ef0840200a4ca8c98ee8b49e114
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More