Skip to content

Instantly share code, notes, and snippets.

View Moe-Baker's full-sized avatar

Moe-Baker Moe-Baker

View GitHub Profile
[CreateAssetMenu]
public class ManagerScriptableObject : ScriptableObject
{
//variable will hold the instance value so we don't look for it everytime we need to access it
//access the Instance only via the Current Property
static ManagerScriptableObject _current;
public static ManagerScriptableObject Current
{
get
{
//gets called when the game loads using the argument gets it called before the startup scene is loaded
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
static void OnGameLoad()
{
if (Current)
Current.Configure();
else
throw new NullReferenceException("No Asset Instance Found, Please Make Sure An Asset Instance Exists Within A Resources Folder");
}
@Moe-Baker
Moe-Baker / Init.cs
Last active December 14, 2017 17:27
//gets called on the local instance from the OnGameLoad, will only be called once obviously
void Configure()
{
Debug.Log("Manager Configured, Called Once The Game Loads, Right Before The Scene Load");
SceneManager.sceneLoaded += OnSceneChanged;
}
//listener to scene change event, calls the Init method
private void OnSceneChanged(Scene scene, LoadSceneMode loadMode)
//abstract class the acts as the functionality implementation
public abstract class BaseImplementation : TypesData.ImplementationBase
{
void Start()
{
Method();
}
protected virtual void Method()
{
//implementation override
public partial class Implementation
{
[SerializeField]
[TextArea]
string tip = "Fields Can Be Added & Will Apear In The MonoBehaviour";
protected override void Method()
{
Debug.Log("Override Method");
public class BaseDataTypes
{
//declare an empty class that derived from the class we want to derive the implementation from
public class ImplementationBase : MonoBehaviour
{
}
}
public partial class DataTypes : BaseDataTypes
//override the implementation's base type
public partial class DataTypes
{
new public class ImplementationBase : NetworkBehaviour
{
}
}
using ARFC;
public class FPControllerAnimationSpeed : MonoBehaviour
{
public FPController controller;
void Update()
{
var value = controller.Movement.Speed.Magnitude / controller.Movement.Speed.MaxValue;
[RequireComponent(typeof(Rigidbody), typeof(CapsuleCollider))]
public abstract partial class FPControllerBase : MonoBehaviour
{
public const string MenuPath = "UFPC/";
FPController This { get { return this as FPController; } }
[SerializeField]
protected ControlConstraint control;
public Scrollbar scrollbar;
void Start()
{
scrollbar.onValueChanged.AddListener(onValueChanged);
}
void onValueChanged(float value)
{
Debug.Log("New Value is " + value)!