Skip to content

error911/ReactVar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ReactVar

Reactive variables.
Переменные с поддержкой событий.

Free license: CC BY Murnik Roman
Tested in Unity 2019.2.X +

Входит в состав набора инструментов GGTools. Рекомендуемое расположение в проекте:
Included in the GGTools Toolkit. Recommended location in the project:
Assets/GGTools/ReactVar


Support types (Поддерживаемые типы)

  • Generic (any type of the following)
  • Int
  • UInt
  • Float
  • Double
  • Bool
  • Vector2
  • Vector3
  • Vector4
  • Vector2Int
  • Vector3Int
  • Color
  • Quaternion

Ways to declare a reactive variable (Способы объявления реактивной переменной)

    ReactVar<int> i = new ReactInt(3);
    ReactInt i2 = new ReactInt(7);

Usage example (Пимер использования)

using GGTools;
public class Test : MonoBehaviour
{
    // Declare an reactive variable
    // Объявляем реактивную переменную
    ReactVar<int> i = new ReactInt(3);
    
    void Start()
    {
        // Subscribe to the event of its change
        // Подписываемся на событие о ее изменении
        i.Subscribe(n=>Debug.Log("Test:" + n));
    }

    void Update()
    {
        // We try to change the variable and observe the given reaction
        // Пробуем изменить переменную и наблюдаем заданную реакцию
        if (Input.GetKeyDown(KeyCode.Space))
        {
            i.Value++;
        }
    }
}

About

Reactive variables. Переменные с поддержкой событий.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages