AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
SyncInteger.cs
Go to the documentation of this file.
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
// Licensed under the MIT License. See LICENSE in the project root for license information.
3
4
namespace
HoloToolkit
.Sharing.SyncModel
5
{
10
public
class
SyncInteger
:
SyncPrimitive
11
{
12
private
IntElement
element;
13
private
int
value;
14
15
#if UNITY_EDITOR
16
public
override
object
RawValue
17
{
18
get
{
return
value; }
19
}
20
#endif
21
22
public
int
Value
23
{
24
get
{
return
value; }
25
26
set
27
{
28
// Has the value actually changed?
29
if
(this.value != value)
30
{
31
// Change the value
32
this.value = value;
33
34
if
(element != null)
35
{
36
// Notify network that the value has changed
37
element.
SetValue
(value);
38
}
39
}
40
}
41
}
42
43
public
SyncInteger
(
string
field)
44
: base(field)
45
{
46
}
47
48
public
override
void
InitializeLocal
(
ObjectElement
parentElement)
49
{
50
element = parentElement.
CreateIntElement
(XStringFieldName, value);
51
NetworkElement = element;
52
}
53
54
public
void
AddFromLocal
(
ObjectElement
parentElement,
int
localValue)
55
{
56
InitializeLocal(parentElement);
57
Value = localValue;
58
}
59
60
public
override
void
AddFromRemote
(
Element
remoteElement)
61
{
62
NetworkElement = remoteElement;
63
element =
IntElement
.
Cast
(remoteElement);
64
value = element.
GetValue
();
65
}
66
67
public
override
void
UpdateFromRemote
(
int
remoteValue)
68
{
69
value = remoteValue;
70
}
71
}
72
}
HoloToolkit.Sharing.ObjectElement.CreateIntElement
virtual IntElement CreateIntElement(XString name, int value)
Definition:
ObjectElement.cs:54
HoloToolkit.Sharing.SyncModel.SyncInteger.SyncInteger
SyncInteger(string field)
Definition:
SyncInteger.cs:43
HoloToolkit.Sharing.ObjectElement
Definition:
ObjectElement.cs:13
HoloToolkit.Sharing.SyncModel.SyncInteger.AddFromLocal
void AddFromLocal(ObjectElement parentElement, int localValue)
Definition:
SyncInteger.cs:54
HoloToolkit.Sharing.IntElement.SetValue
virtual void SetValue(int newValue)
Definition:
IntElement.cs:53
HoloToolkit.Sharing.SyncModel.SyncPrimitive
Base primitive used to define an element within the data model. The primitive is defined by a field a...
Definition:
SyncPrimitive.cs:10
HoloToolkit.Sharing.SyncModel.SyncInteger.AddFromRemote
override void AddFromRemote(Element remoteElement)
Called when being remotely initialized.
Definition:
SyncInteger.cs:60
HoloToolkit.Sharing.Element
Definition:
Element.cs:13
HoloToolkit.Sharing.IntElement
Definition:
IntElement.cs:13
HoloToolkit.Sharing.SyncModel.SyncInteger
This class implements the integer primitive for the syncing system. It does the heavy lifting to make...
Definition:
SyncInteger.cs:10
HoloToolkit.Sharing.IntElement.GetValue
virtual int GetValue()
Definition:
IntElement.cs:48
HoloToolkit.Sharing.SyncModel.SyncInteger.UpdateFromRemote
override void UpdateFromRemote(int remoteValue)
Called when the primitive value has changed from a remote action.
Definition:
SyncInteger.cs:67
HoloToolkit.Sharing.IntElement.Cast
static IntElement Cast(Element element)
Definition:
IntElement.cs:42
HoloToolkit.Sharing.SyncModel.SyncInteger.InitializeLocal
override void InitializeLocal(ObjectElement parentElement)
Initializes this object for local use. Doesn't wait for network initialization.
Definition:
SyncInteger.cs:48
HoloToolkit
Assets
HoloToolkit
Sharing
Scripts
SyncModel
SyncInteger.cs
Generated by
1.8.12