Skip to content
This repository was archived by the owner on May 29, 2023. It is now read-only.

RangeVariable

sophia daniels edited this page Oct 3, 2018 · 5 revisions

Implements: ScriptableObject > SavableVariable > SharedVariable, ISerializationCallbackReceiver

Description

Base abstract generic class for a range variable. Adds range limit utils

  • type param: <T> Type of value for the range variable

Properties

float MinValue

Lowest possible value

float MaxValue

Largest possible value

bool Descending

Inverts the percentage value of the range. MaxValue becomes 0% of the range

float FloatValue

Value used to calculate percentage of range.

  • Used to access RuntimeValue for percent calculations

float Percent

Where the Runtime value is between the min and max values of the range.

  • MinValue is 0% (0.0f) and Max Value is 100% (1.0f)
  • If Descending is true MinValue is 100% and MaxValue is 0%

SharedVariable Properties

T InitialValue

The default value for the variable

T RuntimeValue {get; set;}

Run time value for the variable

SavableVariable Properties

bool Loaded

Set to true if data has been loaded


Methods

void FitToRange

Ensures that the float value is within the min and max of the range.

void OnAfterDeserialize

Applies the default value to the run time value after deserialization.

  • This should happen after changing the default values in the inspector. It will also apply the default value when the game starts.
  • Required for ISerializationCallbackReceiver

void OnBeforeSerialize()

Does nothing

  • Required for ISerializationCallbackReceiver

void OnClearSave()

Clear the saved data

string OnSaveData()

Converts runtime data to a string to be saved

  • Returns: String of runtime data

void OnLoadData(string data)

Parses string of data into runtime data

  • Param: data - Data to be loaded
Clone this wiki locally