OLD_STEP_LIST_EDITOR
Documentation for the Unity C# Library
Loading...
Searching...
No Matches
StatesService.cs
Go to the documentation of this file.
1
using
System;
2
using
PixoVR.Event
;
3
using
PixoVR.Audio
;
4
using
System.Collections.Generic;
5
using
UnityEngine;
6
7
namespace
PixoVR.Event
8
{
12
public
static
class
StatesService
13
{
14
private
static
readonly Dictionary<Type, object>
_states
=
new
Dictionary<Type, object>();
15
16
public
static
void
SaveState<T>
(T data)
17
{
18
if
(
_states
.ContainsKey(typeof(T)))
19
{
20
_states
[typeof(T)] = data;
21
}
22
23
else
24
{
25
_states
.Add(typeof(T), data);
26
}
27
}
28
29
public
static
T
GetState<T>
(
bool
isCreateInstance =
false
) where T : class, new()
30
{
31
if
(
_states
.TryGetValue(typeof(T), out
object
value))
32
{
33
return
value as T;
34
}
35
36
Debug.LogWarning(
"State does not exist"
);
37
38
if
(isCreateInstance)
39
{
40
var intance =
new
T();
41
42
SaveState(intance);
43
44
return
intance;
45
}
46
47
return
null
;
48
}
49
}
50
}
PixoVR.Event.StatesService
Logic for saving and unloading states during project execution.
Definition
StatesService.cs:13
PixoVR.Event.StatesService.GetState< T >
static T GetState< T >(bool isCreateInstance=false)
Definition
StatesService.cs:29
PixoVR.Event.StatesService.SaveState< T >
static void SaveState< T >(T data)
Definition
StatesService.cs:16
PixoVR.Event.StatesService._states
static readonly Dictionary< Type, object > _states
Definition
StatesService.cs:14
PixoVR.Audio
Definition
AudioService.cs:7
PixoVR.Event
Definition
ItemIDAttribute.cs:5
com.pixovr.eventunitysdk
Runtime
Sdk
Scripts
Services
StatesService.cs
Generated
Wed Oct 9 2024 19:24:03
by Doxygen version
1.10.0