AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
SyncFloat.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
SyncFloat
:
SyncPrimitive
11
{
12
private
FloatElement
element;
13
private
float
value;
14
15
#if UNITY_EDITOR
16
public
override
object
RawValue
17
{
18
get
{
return
value; }
19
}
20
#endif
21
22
public
float
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
SyncFloat
(
string
field) : base(field) { }
44
45
public
override
void
InitializeLocal
(
ObjectElement
parentElement)
46
{
47
element = parentElement.
CreateFloatElement
(XStringFieldName, value);
48
NetworkElement = element;
49
}
50
51
public
void
AddFromLocal
(
ObjectElement
parentElement,
float
localValue)
52
{
53
InitializeLocal(parentElement);
54
Value = localValue;
55
}
56
57
public
override
void
AddFromRemote
(
Element
remoteElement)
58
{
59
NetworkElement = remoteElement;
60
element =
FloatElement
.
Cast
(remoteElement);
61
value = element.
GetValue
();
62
}
63
64
public
override
void
UpdateFromRemote
(
float
remoteValue)
65
{
66
// Change the value
67
value = remoteValue;
68
}
69
}
70
}
HoloToolkit.Sharing.ObjectElement
Definition:
ObjectElement.cs:13
HoloToolkit.Sharing.SyncModel.SyncFloat
This class implements the float primitive for the syncing system. It does the heavy lifting to make a...
Definition:
SyncFloat.cs:10
HoloToolkit.Sharing.FloatElement.GetValue
virtual float GetValue()
Definition:
FloatElement.cs:48
HoloToolkit.Sharing.SyncModel.SyncFloat.AddFromRemote
override void AddFromRemote(Element remoteElement)
Called when being remotely initialized.
Definition:
SyncFloat.cs:57
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.Element
Definition:
Element.cs:13
HoloToolkit.Sharing.SyncModel.SyncFloat.UpdateFromRemote
override void UpdateFromRemote(float remoteValue)
Called when the primitive value has changed from a remote action.
Definition:
SyncFloat.cs:64
HoloToolkit.Sharing.SyncModel.SyncFloat.SyncFloat
SyncFloat(string field)
Definition:
SyncFloat.cs:43
HoloToolkit.Sharing.FloatElement.Cast
static FloatElement Cast(Element element)
Definition:
FloatElement.cs:42
HoloToolkit
HoloToolkit.Sharing.FloatElement.SetValue
virtual void SetValue(float newValue)
Definition:
FloatElement.cs:53
HoloToolkit.Sharing.ObjectElement.CreateFloatElement
virtual FloatElement CreateFloatElement(XString name, float value)
Definition:
ObjectElement.cs:66
HoloToolkit.Sharing.FloatElement
Definition:
FloatElement.cs:13
HoloToolkit.Sharing.SyncModel.SyncFloat.InitializeLocal
override void InitializeLocal(ObjectElement parentElement)
Initializes this object for local use. Doesn't wait for network initialization.
Definition:
SyncFloat.cs:45
HoloToolkit.Sharing.SyncModel.SyncFloat.AddFromLocal
void AddFromLocal(ObjectElement parentElement, float localValue)
Definition:
SyncFloat.cs:51
Assets
HoloToolkit
Sharing
Scripts
SyncModel
SyncFloat.cs
Generated by
1.8.12