Skip to content
This repository was archived by the owner on Jul 16, 2020. It is now read-only.

Commit 0721c0d

Browse files
authored
Merge pull request #56 from mixer/support-key-accelerators-for-buttons
Label control and setting button properties
2 parents 68f1bcc + 23c4595 commit 0721c0d

File tree

6 files changed

+221
-0
lines changed

6 files changed

+221
-0
lines changed

Source/InteractiveSDK/Assets/MixerInteractive/Source/Scripts/InteractiveControl.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,30 @@ public void SetDisabled(bool disabled)
8181
0);
8282
}
8383

84+
/// <summary>
85+
/// This function allows you to set any property on a control.
86+
/// </summary>
87+
/// <param name="name">The name of the control property.</param>
88+
/// <param name="value">The value of the control property.</param>
89+
public void SetProperty(InteractiveControlProperty name, object value)
90+
{
91+
SetPropertyImpl(
92+
InteractivityManager.SingletonInstance.InteractiveControlPropertyToString(name),
93+
value
94+
);
95+
}
96+
8497
/// <summary>
8598
/// This function allows you to set any property on a control.
8699
/// </summary>
87100
/// <param name="name">The name of the control property.</param>
88101
/// <param name="value">The value of the control property.</param>
89102
public void SetProperty(string name, object value)
103+
{
104+
SetPropertyImpl(name, value);
105+
}
106+
107+
private void SetPropertyImpl(string name, object value)
90108
{
91109
InteractivityManager.SingletonInstance.QueuePropertyUpdate(SceneID, ControlID, name, value);
92110
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Mixer Unity SDK
3+
*
4+
* Copyright (c) Microsoft Corporation
5+
* All rights reserved.
6+
*
7+
* MIT License
8+
*
9+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
10+
* software and associated documentation files (the "Software"), to deal in the Software
11+
* without restriction, including without limitation the rights to use, copy, modify, merge,
12+
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
13+
* to whom the Software is furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in all copies or
16+
* substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
19+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
20+
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
21+
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
* DEALINGS IN THE SOFTWARE.
24+
*/
25+
using System;
26+
27+
namespace Microsoft.Mixer
28+
{
29+
/// <summary>
30+
/// The known values for control properties.
31+
/// </summary>
32+
public enum InteractiveControlProperty
33+
{
34+
/// <summary>
35+
/// The display test of the control.
36+
/// </summary>
37+
Text,
38+
39+
/// <summary>
40+
/// The background color of the control.
41+
/// </summary>
42+
BackgroundColor,
43+
44+
/// <summary>
45+
/// The background image of the control.
46+
/// </summary>
47+
BackgroundImage,
48+
49+
/// <summary>
50+
/// The text color of the display text for the control.
51+
/// </summary>
52+
TextColor,
53+
54+
/// <summary>
55+
/// The text size of the display text for the control.
56+
/// </summary>
57+
TextSize,
58+
59+
/// <summary>
60+
/// The border color of the control.
61+
/// </summary>
62+
BorderColor,
63+
64+
/// <summary>
65+
/// The focus color of the control.
66+
/// </summary>
67+
FocusColor,
68+
69+
/// <summary>
70+
/// The accent color. Where this color shows up will depend on the control.
71+
/// </summary>
72+
AccentColor
73+
}
74+
}

Source/InteractiveSDK/Assets/MixerInteractive/Source/Scripts/InteractiveControlProperty.cs.meta

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Mixer Unity SDK
3+
*
4+
* Copyright (c) Microsoft Corporation
5+
* All rights reserved.
6+
*
7+
* MIT License
8+
*
9+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
10+
* software and associated documentation files (the "Software"), to deal in the Software
11+
* without restriction, including without limitation the rights to use, copy, modify, merge,
12+
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
13+
* to whom the Software is furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in all copies or
16+
* substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
19+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
20+
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
21+
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
* DEALINGS IN THE SOFTWARE.
24+
*/
25+
using System;
26+
using System.Collections.Generic;
27+
28+
namespace Microsoft.Mixer
29+
{
30+
/// <summary>
31+
/// Represents an interactive label control. All controls are created and
32+
/// configured using Interactive Studio.
33+
/// </summary>
34+
#if !WINDOWS_UWP
35+
[System.Serializable]
36+
#endif
37+
public class InteractiveLabelControl : InteractiveControl
38+
{
39+
/// <summary>
40+
/// Text displayed on this control.
41+
/// </summary>
42+
public string Text
43+
{
44+
get;
45+
private set;
46+
}
47+
48+
/// <summary>
49+
/// Function to update the text for the label control.
50+
/// </summary>
51+
/// <param name="text">String to display on the label.</param>
52+
public void SetText(string text)
53+
{
54+
InteractivityManager interactivityManager = InteractivityManager.SingletonInstance;
55+
interactivityManager.QueuePropertyUpdate(
56+
SceneID,
57+
ControlID,
58+
interactivityManager.InteractiveControlPropertyToString(InteractiveControlProperty.Text),
59+
text);
60+
}
61+
62+
public InteractiveLabelControl(string controlID, InteractiveEventType type, string text, string sceneID) : base(controlID, InteractivityManager.CONTROL_TYPE_BUTTON, type, false, "", "", sceneID)
63+
{
64+
Text = text;
65+
}
66+
}
67+
}

Source/InteractiveSDK/Assets/MixerInteractive/Source/Scripts/InteractiveLabelControl.cs.meta

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/InteractiveSDK/Assets/MixerInteractive/Source/Scripts/InteractivityManager.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3762,6 +3762,42 @@ internal void RegisterControlForValueUpdates(string controlTypeName, List<string
37623762
}
37633763
}
37643764
}
3765+
3766+
internal string InteractiveControlPropertyToString(InteractiveControlProperty property)
3767+
{
3768+
string controlPropertyString = string.Empty;
3769+
switch (property)
3770+
{
3771+
case InteractiveControlProperty.Text:
3772+
controlPropertyString = "text";
3773+
break;
3774+
case InteractiveControlProperty.BackgroundColor:
3775+
controlPropertyString = "backgroundColor";
3776+
break;
3777+
case InteractiveControlProperty.BackgroundImage:
3778+
controlPropertyString = "backgroundImage";
3779+
break;
3780+
case InteractiveControlProperty.TextColor:
3781+
controlPropertyString = "textColor";
3782+
break;
3783+
case InteractiveControlProperty.TextSize:
3784+
controlPropertyString = "textSize";
3785+
break;
3786+
case InteractiveControlProperty.BorderColor:
3787+
controlPropertyString = "borderColor";
3788+
break;
3789+
case InteractiveControlProperty.FocusColor:
3790+
controlPropertyString = "focusColor";
3791+
break;
3792+
case InteractiveControlProperty.AccentColor:
3793+
controlPropertyString = "accentColor";
3794+
break;
3795+
default:
3796+
// No-op: Unexpected property.
3797+
break;
3798+
}
3799+
return controlPropertyString;
3800+
}
37653801
}
37663802

37673803
internal struct InternalButtonCountState

0 commit comments

Comments
 (0)