Skip to content

Commit 02c89d8

Browse files
committed
Fix formatting (replace tabs with spaces)
1 parent 9a6d78e commit 02c89d8

4 files changed

Lines changed: 124 additions & 124 deletions

File tree

Assets/Plugins/VolumeButtonsPlugin/VolumeButtons.cs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
public class VolumeButtons : MonoBehaviour
99
{
1010
#if !UNITY_ANDROID && !UNITY_IOS
11-
private readonly RuntimePlatform[] SupportedPlatforms = new RuntimePlatform[] { RuntimePlatform.Android, RuntimePlatform.IPhonePlayer};
11+
private readonly RuntimePlatform[] SupportedPlatforms = new RuntimePlatform[] { RuntimePlatform.Android, RuntimePlatform.IPhonePlayer};
1212
private readonly string UnsupportedError = "Unsupported platform '{0}'! At the moment we support only {1}";
1313
#endif
1414

@@ -32,39 +32,39 @@ public float SystemVolumeLevel
3232

3333
void Start()
3434
{
35-
#if UNITY_ANDROID
36-
_CallActivityVoid("addGameObjectListener", gameObject.name);
37-
#elif UNITY_IOS
38-
_AddGameObjectListener(gameObject.name, gameObject.name.Length);
39-
#else
40-
Debug.LogFormat(UnsupportedError, Application.platform, string.Join("", SupportedPlatforms));
41-
#endif
35+
#if UNITY_ANDROID
36+
_CallActivityVoid("addGameObjectListener", gameObject.name);
37+
#elif UNITY_IOS
38+
_AddGameObjectListener(gameObject.name, gameObject.name.Length);
39+
#else
40+
Debug.LogFormat(UnsupportedError, Application.platform, string.Join("", SupportedPlatforms));
41+
#endif
4242
}
4343

4444
void OnDisable()
4545
{
46-
#if UNITY_ANDROID
47-
_CallActivityVoid("removeGameObjectListener", gameObject.name);
48-
#elif UNITY_IOS
49-
_RemoveGameObjectListener(gameObject.name, gameObject.name.Length);
50-
#else
51-
Debug.LogFormat(UnsupportedError, Application.platform, string.Join("", SupportedPlatforms));
52-
#endif
46+
#if UNITY_ANDROID
47+
_CallActivityVoid("removeGameObjectListener", gameObject.name);
48+
#elif UNITY_IOS
49+
_RemoveGameObjectListener(gameObject.name, gameObject.name.Length);
50+
#else
51+
Debug.LogFormat(UnsupportedError, Application.platform, string.Join("", SupportedPlatforms));
52+
#endif
5353
}
5454

5555
private void _OnVolumeButtonEvent(string value)
5656
{
57-
if (OnVolumeButtonEvent != null)
58-
{
57+
if (OnVolumeButtonEvent != null)
58+
{
5959
#if DEBUG
6060
Debug.LogFormat("Volume event {0} delivered!", value);
6161
#endif
62-
this.OnVolumeButtonEvent.Invoke((VolumeButtonsEventType)Int32.Parse(value), this);
63-
}
64-
else
65-
{
66-
Debug.Log("No event subscribed!");
67-
}
62+
this.OnVolumeButtonEvent.Invoke((VolumeButtonsEventType)Int32.Parse(value), this);
63+
}
64+
else
65+
{
66+
Debug.Log("No event subscribed!");
67+
}
6868
}
6969

7070
#if UNITY_ANDROID
@@ -73,13 +73,13 @@ private float _CallActivityFloat(string methodName)
7373
{
7474
using (AndroidJavaClass unityPlayerClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
7575
{
76-
using (AndroidJavaObject activity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity"))
76+
using (AndroidJavaObject activity = unityPlayerClass.GetStatic<AndroidJavaObject>("currentActivity"))
7777
{
7878
#if DEBUG
79-
Debug.LogFormat("Call {0}()", methodName);
79+
Debug.LogFormat("Call {0}()", methodName);
8080
#endif
81-
return activity.Call<float>(methodName);
82-
}
81+
return activity.Call<float>(methodName);
82+
}
8383
}
8484
}
8585

Assets/Plugins/VolumeButtonsPlugin/iOS/VolumeButtonsPlugin.m

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
static _VBPAVAudioSessionObserver *observer = NULL;
1414

1515
@interface _VBPAVAudioSessionObserver : NSObject {
16-
float _currentVolumeLevel;
17-
NSMutableArray<NSString *> *_gameObjectNames;
18-
MPVolumeView *_volumeView;
16+
float _currentVolumeLevel;
17+
NSMutableArray<NSString *> *_gameObjectNames;
18+
MPVolumeView *_volumeView;
1919
}
2020

2121
-(void) addGameObject:(NSString *)objectName;
@@ -27,96 +27,96 @@ -(void) removeGameObject:(NSString *)objectName;
2727
@implementation _VBPAVAudioSessionObserver
2828

2929
-(id) init {
30-
if (self = [super init]) {
31-
_currentVolumeLevel = [[AVAudioSession sharedInstance] outputVolume];
32-
_gameObjectNames = [NSMutableArray new];
33-
}
30+
if (self = [super init]) {
31+
_currentVolumeLevel = [[AVAudioSession sharedInstance] outputVolume];
32+
_gameObjectNames = [NSMutableArray new];
33+
}
3434

35-
return self;
35+
return self;
3636
}
3737

3838
-(void) addGameObject:(NSString *)objectName {
39-
@synchronized(_gameObjectNames) {
40-
if (_gameObjectNames.count == 0) {
41-
AVAudioSession *session = [AVAudioSession sharedInstance];
42-
if (!session.isOtherAudioPlaying) {
43-
[session setActive:YES error:nil];
44-
}
45-
[session addObserver:self forKeyPath:@"outputVolume" options:NSKeyValueObservingOptionNew context:nil];
46-
}
47-
48-
[_gameObjectNames addObject:objectName];
39+
@synchronized(_gameObjectNames) {
40+
if (_gameObjectNames.count == 0) {
41+
AVAudioSession *session = [AVAudioSession sharedInstance];
42+
if (!session.isOtherAudioPlaying) {
43+
[session setActive:YES error:nil];
44+
}
45+
[session addObserver:self forKeyPath:@"outputVolume" options:NSKeyValueObservingOptionNew context:nil];
4946
}
47+
48+
[_gameObjectNames addObject:objectName];
49+
}
5050
}
5151

5252
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
53-
if ([@"outputVolume" isEqualToString:keyPath]) {
54-
float newVolumeLevel = [[AVAudioSession sharedInstance] outputVolume];
55-
@synchronized(_gameObjectNames) {
56-
for (NSString *gameObjectName in _gameObjectNames) {
57-
UnitySendMessage([gameObjectName cStringUsingEncoding:NSUTF8StringEncoding], kMessageName, (newVolumeLevel > _currentVolumeLevel ? kVolumeUp : kVolumeDown));
58-
}
59-
}
60-
61-
// https://forums.developer.apple.com/thread/107241
62-
if (newVolumeLevel > 0.999f) {
63-
_currentVolumeLevel = 0.9375f;
64-
[self hackSystemVolume:_currentVolumeLevel];
65-
} else if (newVolumeLevel < 0.001f) {
66-
_currentVolumeLevel = 0.0625f;
67-
[self hackSystemVolume:_currentVolumeLevel];
68-
} else {
69-
_currentVolumeLevel = newVolumeLevel;
70-
}
53+
if ([@"outputVolume" isEqualToString:keyPath]) {
54+
float newVolumeLevel = [[AVAudioSession sharedInstance] outputVolume];
55+
@synchronized(_gameObjectNames) {
56+
for (NSString *gameObjectName in _gameObjectNames) {
57+
UnitySendMessage([gameObjectName cStringUsingEncoding:NSUTF8StringEncoding], kMessageName, (newVolumeLevel > _currentVolumeLevel ? kVolumeUp : kVolumeDown));
58+
}
59+
}
60+
61+
// https://forums.developer.apple.com/thread/107241
62+
if (newVolumeLevel > 0.999f) {
63+
_currentVolumeLevel = 0.9375f;
64+
[self hackSystemVolume:_currentVolumeLevel];
65+
} else if (newVolumeLevel < 0.001f) {
66+
_currentVolumeLevel = 0.0625f;
67+
[self hackSystemVolume:_currentVolumeLevel];
7168
} else {
72-
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
69+
_currentVolumeLevel = newVolumeLevel;
7370
}
71+
} else {
72+
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
73+
}
7474
}
7575

7676
-(void) removeGameObject:(NSString *)objectName {
77-
@synchronized(_gameObjectNames) {
78-
[_gameObjectNames removeObject:objectName];
77+
@synchronized(_gameObjectNames) {
78+
[_gameObjectNames removeObject:objectName];
7979

80-
if (_gameObjectNames.count == 0) {
81-
AVAudioSession *session = [AVAudioSession sharedInstance];
82-
[session removeObserver:self forKeyPath:@"outputVolume"];
83-
}
80+
if (_gameObjectNames.count == 0) {
81+
AVAudioSession *session = [AVAudioSession sharedInstance];
82+
[session removeObserver:self forKeyPath:@"outputVolume"];
8483
}
84+
}
8585
}
8686

8787
-(void)hackSystemVolume:(float)volumeLevel {
88-
UISlider *view = [[[[MPVolumeView new] subviews] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"classForCoder == \"MPVolumeSlider\""]] firstObject];
89-
if ([view isKindOfClass:[UISlider class]]) {
90-
UISlider *slider = (UISlider *)view;
91-
[slider setValue:volumeLevel];
92-
}
88+
UISlider *view = [[[[MPVolumeView new] subviews] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"classForCoder == \"MPVolumeSlider\""]] firstObject];
89+
if ([view isKindOfClass:[UISlider class]]) {
90+
UISlider *slider = (UISlider *)view;
91+
[slider setValue:volumeLevel];
92+
}
9393
}
9494

9595
@end
9696

9797
void VBP_addGameObjectListener(const char *go_name, int go_name_length) {
98-
if (!observer) {
99-
observer = [_VBPAVAudioSessionObserver new];
100-
}
98+
if (!observer) {
99+
observer = [_VBPAVAudioSessionObserver new];
100+
}
101101

102-
// https://answers.unity.com/questions/363476/how-to-pass-unicode-text-from-c-to-objective-c.html
103-
NSString* gon = [[NSString alloc]
104-
initWithBytes:go_name
105-
length:sizeof(__CHAR16_TYPE__) * go_name_length
106-
encoding:NSUTF16LittleEndianStringEncoding];
102+
// https://answers.unity.com/questions/363476/how-to-pass-unicode-text-from-c-to-objective-c.html
103+
NSString* gon = [[NSString alloc]
104+
initWithBytes:go_name
105+
length:sizeof(__CHAR16_TYPE__) * go_name_length
106+
encoding:NSUTF16LittleEndianStringEncoding];
107107

108-
[observer addGameObject:gon];
108+
[observer addGameObject:gon];
109109
}
110110

111111
void VBP_removeGameObjectListener(const char *go_name, int go_name_length) {
112-
NSString* gon = [[NSString alloc]
113-
initWithBytes:go_name
114-
length:sizeof(__CHAR16_TYPE__) * go_name_length
115-
encoding:NSUTF16LittleEndianStringEncoding];
112+
NSString* gon = [[NSString alloc]
113+
initWithBytes:go_name
114+
length:sizeof(__CHAR16_TYPE__) * go_name_length
115+
encoding:NSUTF16LittleEndianStringEncoding];
116116

117-
[observer removeGameObject:gon];
117+
[observer removeGameObject:gon];
118118
}
119119

120120
float VBP_getSystemVolumeLevel(void) {
121-
return [[AVAudioSession sharedInstance] outputVolume];
121+
return [[AVAudioSession sharedInstance] outputVolume];
122122
}

Assets/Scripts/Blink.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,29 @@
77

88
public class Blink : MonoBehaviour
99
{
10-
private readonly float Delay = 0.05f;
10+
private readonly float Delay = 0.05f;
1111

12-
public VolumeButtonsEventType InterestingEvent;
12+
public VolumeButtonsEventType InterestingEvent;
1313

14-
public void DoBlink(VolumeButtonsEventType e, VolumeButtons ctrl)
15-
{
16-
if (InterestingEvent == e)
17-
{
18-
Debug.LogFormat("DoBlink for {0} event", InterestingEvent.ToString());
19-
StartCoroutine(Flash(2));
20-
}
21-
}
14+
public void DoBlink(VolumeButtonsEventType e, VolumeButtons ctrl)
15+
{
16+
if (InterestingEvent == e)
17+
{
18+
Debug.LogFormat("DoBlink for {0} event", InterestingEvent.ToString());
19+
StartCoroutine(Flash(2));
20+
}
21+
}
2222

2323
IEnumerator Flash(int flashCount)
24-
{
25-
Image image = gameObject.GetComponent<Image>();
24+
{
25+
Image image = gameObject.GetComponent<Image>();
2626

27-
for (int i = 0; i < flashCount; i++)
28-
{
29-
image.color = Color.white;
30-
yield return new WaitForSeconds(Delay);
31-
image.color = Color.clear;
32-
yield return new WaitForSeconds(Delay);
33-
}
34-
}
27+
for (int i = 0; i < flashCount; i++)
28+
{
29+
image.color = Color.white;
30+
yield return new WaitForSeconds(Delay);
31+
image.color = Color.clear;
32+
yield return new WaitForSeconds(Delay);
33+
}
34+
}
3535
}

Assets/Scripts/VolumeText.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@
77

88
public class VolumeText : MonoBehaviour
99
{
10-
private Text volumeLevel;
10+
private Text volumeLevel;
1111

12-
void Start()
12+
void Start()
1313
{
14-
_UpdateText(gameObject.GetComponent<VolumeButtons>());
14+
_UpdateText(gameObject.GetComponent<VolumeButtons>());
1515
}
1616

17-
public void OnVolumeUpdated(VolumeButtonsEventType e, VolumeButtons ctrl)
18-
{
19-
_UpdateText(ctrl);
20-
}
17+
public void OnVolumeUpdated(VolumeButtonsEventType e, VolumeButtons ctrl)
18+
{
19+
_UpdateText(ctrl);
20+
}
2121

22-
private void _UpdateText(VolumeButtons ctrl)
23-
{
24-
Text volumeLevel = gameObject.GetComponent<UnityEngine.UI.Text>();
25-
string value = ctrl.SystemVolumeLevel.ToString("N2");
22+
private void _UpdateText(VolumeButtons ctrl)
23+
{
24+
Text volumeLevel = gameObject.GetComponent<UnityEngine.UI.Text>();
25+
string value = ctrl.SystemVolumeLevel.ToString("N2");
2626

27-
Debug.LogFormat("Volume updated {0} of 1.0", value);
27+
Debug.LogFormat("Volume updated {0} of 1.0", value);
2828

29-
volumeLevel.text = value;
30-
}
29+
volumeLevel.text = value;
30+
}
3131
}

0 commit comments

Comments
 (0)