-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathGUISkin.cs
More file actions
977 lines (899 loc) · 36.3 KB
/
Copy pathGUISkin.cs
File metadata and controls
977 lines (899 loc) · 36.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.Scripting.LifecycleManagement;
using UnityEngine.Scripting;
namespace UnityEngine
{
// Which platform to emulate.
internal enum PlatformSelection
{
// The behaviour matches the platform the end user is running on.
Native = 0,
// The behaviour matches a Mac OS X machine.
Mac = 1,
// The behaviour matches a Windows machine.
Windows = 2,
}
// General settings for how the GUI behaves
[Serializable]
public sealed partial class GUISettings
{
///<summary>Should double-clicking select words in text fields.</summary>
///<remarks>By default is set to true.</remarks>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// string str = "This is a string with \n two lines of text";
///
/// void OnGUI()
/// {
/// GUI.skin.settings.doubleClickSelectsWord = false;
/// str = GUILayout.TextArea(str);
/// }
///}
///]]></code>
///</example>
public bool doubleClickSelectsWord { get { return m_DoubleClickSelectsWord; } set { m_DoubleClickSelectsWord = value; } }
[SerializeField]
bool m_DoubleClickSelectsWord = true;
///<summary>Should triple-clicking select whole text in text fields.</summary>
///<remarks>Bu default is set to true.</remarks>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Disables line selecting with triple click on the text area
/// string str = "This is a string with \n two lines of text";
///
/// void OnGUI()
/// {
/// GUI.skin.settings.tripleClickSelectsLine = false;
/// str = GUILayout.TextArea(str);
/// }
///}
///]]></code>
///</example>
public bool tripleClickSelectsLine { get { return m_TripleClickSelectsLine; } set { m_TripleClickSelectsLine = value; } }
[SerializeField]
bool m_TripleClickSelectsLine = true;
///<summary>The color of the cursor in text fields.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Set the cursor color to Cyan.
/// string str = "This is a string with \n two lines of text";
///
/// void OnGUI()
/// {
/// GUI.skin.settings.cursorColor = Color.cyan;
/// str = GUILayout.TextArea(str);
/// }
///}
///]]></code>
///</example>
public Color cursorColor { get { return m_CursorColor; } set { m_CursorColor = value; } }
[SerializeField]
Color m_CursorColor = Color.white;
///<summary>The speed of text field cursor flashes.</summary>
///<remarks>This is how many flashes / second. If you set it to 0, flashing will be disabled. If you set it to -1, the flashing speed will match the system default of the end user.</remarks>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// string str = "This is a string with \n two lines of text";
///
/// void OnGUI()
/// {
/// GUI.skin.settings.cursorFlashSpeed = 3;
/// str = GUILayout.TextArea(str);
/// }
///}
///]]></code>
///</example>
public float cursorFlashSpeed
{
get
{
if (m_CursorFlashSpeed >= 0)
return m_CursorFlashSpeed;
else
{
return Internal_GetCursorFlashSpeed();
}
}
set { m_CursorFlashSpeed = value; }
}
[SerializeField]
float m_CursorFlashSpeed = -1;
///<summary>The color of the selection rect in text fields.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// string str = "This is a string with \n two lines of text";
///
/// void OnGUI()
/// {
/// GUI.skin.settings.selectionColor = Color.cyan;
/// str = GUILayout.TextArea(str);
/// }
///}
///]]></code>
///</example>
public Color selectionColor { get { return m_SelectionColor; } set { m_SelectionColor = value; } }
[SerializeField]
Color m_SelectionColor = new Color(.5f, .5f, 1f);
}
///<summary>Defines how GUI looks and behaves.</summary>
///<remarks>GUISkin contains GUI settings and a collection of <see cref="GUIStyle" /> objects that together specify GUI skin.
///
///Active GUI skin is get and set through <see cref="GUI.skin" />.</remarks>
[Serializable]
[ExecuteInEditMode]
[RequiredByNativeCode]
[AssetFileNameExtension("guiskin")]
public sealed partial class GUISkin : ScriptableObject
{
[SerializeField]
Font m_Font;
// *undocumented*
///<exclude />
public GUISkin()
{
m_CustomStyles = new GUIStyle[1];
}
internal void OnEnable()
{
Apply();
}
///<summary>The default font to use for all styles.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies the font only of the current GUISkin.
///
/// public Font font;
///
/// void OnGUI()
/// {
/// if (!font)
/// {
/// Debug.LogError("No font found, assign one in the inspector.");
/// return;
/// }
/// GUI.skin.font = font;
///
/// GUILayout.Label("This is a label with the font");
/// GUILayout.Button("And this is a button");
/// }
///}
///]]></code>
///</example>
public Font font { get { return m_Font; } set { m_Font = value; if (current == this) GUIStyle.SetDefaultFont(m_Font); Apply(); } }
[SerializeField] //yes the attribute applies to all fields on the line below.
GUIStyle m_box, m_button, m_toggle, m_label, m_textField, m_textArea, m_window;
///<summary>Style used by default for <see cref="GUI.Box" /> controls.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the box style of the current GUISkin
///
/// GUIStyle style;
///
/// void OnGUI()
/// {
/// GUI.skin.box = style;
/// GUILayout.Box("This is a box.");
/// }
///}
///]]></code>
///</example>
public GUIStyle box { get { return m_box; } set { m_box = value; Apply(); } }
///<summary>Style used by default for <see cref="GUI.Label" /> controls.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the label style of the current GUISkin
/// GUIStyle style;
///
/// void OnGUI()
/// {
/// GUI.skin.label = style;
/// GUILayout.Label("This is a label.");
/// }
///}
///]]></code>
///</example>
public GUIStyle label { get { return m_label; } set { m_label = value; Apply(); } }
///<summary>Style used by default for <see cref="GUI.TextField" /> controls.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the textField style of the current GUISkin
///
/// GUIStyle style;
/// string str = "A string...";
///
/// void OnGUI()
/// {
/// GUI.skin.textField = style;
/// str = GUILayout.TextField(str);
/// }
///}
///]]></code>
///</example>
public GUIStyle textField { get { return m_textField; } set { m_textField = value; Apply(); } }
///<summary>Style used by default for <see cref="GUI.TextArea" /> controls.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the textArea style of the current GUISkin
///
/// GUIStyle style;
/// string str = "A string...\nWith two lines.";
///
/// void OnGUI()
/// {
/// GUI.skin.textArea = style;
/// str = GUILayout.TextArea(str);
/// }
///}
///]]></code>
///</example>
public GUIStyle textArea { get { return m_textArea; } set { m_textArea = value; Apply(); } }
///<summary>Style used by default for <see cref="GUI.Button" /> controls.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the button style of the current GUISkin
///
/// GUIStyle style;
///
/// void OnGUI()
/// {
/// GUI.skin.box = style;
/// GUILayout.Button("This is a button.");
/// }
///}
///]]></code>
///</example>
public GUIStyle button { get { return m_button; } set { m_button = value; Apply(); } }
///<summary>Style used by default for <see cref="GUI.Toggle" /> controls.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the toggle style of the current GUISkin
///
/// GUIStyle style;
/// public bool val = false;
///
/// void OnGUI()
/// {
/// GUI.skin.toggle = style;
/// val = GUILayout.Toggle(val, "A Toggle control");
/// }
///}
///]]></code>
///</example>
public GUIStyle toggle { get { return m_toggle; } set { m_toggle = value; Apply(); } }
///<summary>Style used by default for Window controls ().</summary>
///<seealso cref="GUI.Window" />
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the window style of the current GUISkin
///
/// GUIStyle style;
/// Rect windowRect = new Rect(20, 20, 120, 50);
///
/// void OnGUI()
/// {
/// GUI.skin.window = style;
/// windowRect = GUILayout.Window(0, windowRect, DoMyWindow, "My Window");
/// }
///
/// // Make the contents of the window
/// void DoMyWindow(int windowID)
/// {
/// // This button will size to fit the window
/// if (GUILayout.Button("Hello World"))
/// print("Got a click");
/// }
///}
///]]></code>
///</example>
public GUIStyle window { get { return m_window; } set { m_window = value; Apply(); } }
[SerializeField]
GUIStyle m_horizontalSlider;
[SerializeField]
GUIStyle m_horizontalSliderThumb;
[NonSerialized]
GUIStyle m_horizontalSliderThumbExtent;
[SerializeField]
GUIStyle m_verticalSlider;
[SerializeField]
GUIStyle m_verticalSliderThumb;
[NonSerialized]
GUIStyle m_verticalSliderThumbExtent;
[NonSerialized]
GUIStyle m_SliderMixed;
///<summary>Style used by default for the background part of <see cref="GUI.HorizontalSlider" /> controls.</summary>
///<remarks>The padding property is used to determine the size of the area the thumb can be dragged within.</remarks>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the horizontal slider style of the current GUISkin
///
/// float hSliderValue = 0.0f;
/// GUIStyle style;
///
/// void OnGUI()
/// {
/// GUI.skin.horizontalSlider = style;
/// hSliderValue = GUILayout.HorizontalSlider(hSliderValue, 0.0f, 10.0f);
/// }
///}
///]]></code>
///</example>
public GUIStyle horizontalSlider { get { return m_horizontalSlider; } set { m_horizontalSlider = value; Apply(); } }
///<summary>Style used by default for the thumb that is dragged in <see cref="GUI.HorizontalSlider" /> controls.</summary>
///<remarks>The padding property is used to determine the size of the thumb.</remarks>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the horizontal slider style of the current GUISkin
///
/// float hSliderValue = 0.0f;
/// GUIStyle style;
///
/// void OnGUI()
/// {
/// GUI.skin.horizontalSliderThumb = style;
/// hSliderValue = GUILayout.HorizontalSlider(hSliderValue, 0.0f, 10.0f);
/// }
///}
///]]></code>
///</example>
public GUIStyle horizontalSliderThumb { get { return m_horizontalSliderThumb; } set { m_horizontalSliderThumb = value; Apply(); } }
// Style used by default for the extended region around the thumb in GUI::ref::HorizontalSlider controls.
internal GUIStyle horizontalSliderThumbExtent { get { return m_horizontalSliderThumbExtent; } set { m_horizontalSliderThumbExtent = value; Apply(); } }
//Style used for thumb and thumbextent when multiple objects are selected
internal GUIStyle sliderMixed { get { return m_SliderMixed; } set { m_SliderMixed = value; Apply(); } }
///<summary>Style used by default for the background part of <see cref="GUI.VerticalSlider" /> controls.</summary>
///<remarks>The padding property is used to determine the size of the area the thumb can be dragged within.</remarks>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the vertical slider style of the current GUISkin
///
/// float vSliderValue = 0.0f;
/// GUIStyle style;
///
/// void OnGUI()
/// {
/// GUI.skin.verticalSlider = style;
/// vSliderValue = GUILayout.VerticalSlider(vSliderValue, 10.0f, 0.0f);
/// }
///}
///]]></code>
///</example>
public GUIStyle verticalSlider { get { return m_verticalSlider; } set { m_verticalSlider = value; Apply(); } }
///<summary>Style used by default for the thumb that is dragged in <see cref="GUI.VerticalSlider" /> controls.</summary>
///<remarks>The padding property is used to determine the size of the thumb.</remarks>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the vertical slider thumb style of the current GUISkin
///
/// float vSliderValue = 0.0f;
/// GUIStyle style;
///
/// void OnGUI()
/// {
/// GUI.skin.verticalSliderThumb = style;
/// vSliderValue = GUILayout.VerticalSlider(vSliderValue, 10.0f, 0.0f);
/// }
///}
///]]></code>
///</example>
public GUIStyle verticalSliderThumb { get { return m_verticalSliderThumb; } set { m_verticalSliderThumb = value; Apply(); } }
// Style used by default for the extended region around the thumb in GUI::ref::VerticalSlider controls.
internal GUIStyle verticalSliderThumbExtent { get { return m_verticalSliderThumbExtent; } set { m_verticalSliderThumbExtent = value; Apply(); } }
[SerializeField]
GUIStyle m_horizontalScrollbar;
[SerializeField]
GUIStyle m_horizontalScrollbarThumb;
[SerializeField]
GUIStyle m_horizontalScrollbarLeftButton;
[SerializeField]
GUIStyle m_horizontalScrollbarRightButton;
///<summary>Style used by default for the background part of <see cref="GUI.HorizontalScrollbar" /> controls.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the default background of the
/// // horizontal scrollbar of the current GUISkin
///
/// float hSbarValue;
/// GUIStyle style;
///
/// void OnGUI()
/// {
/// GUI.skin.horizontalScrollbar = style;
/// hSbarValue = GUILayout.HorizontalScrollbar(hSbarValue, 1.0f, 0.0f, 10.0f);
/// }
///}
///]]></code>
///</example>
public GUIStyle horizontalScrollbar { get { return m_horizontalScrollbar; } set { m_horizontalScrollbar = value; Apply(); } }
///<summary>Style used by default for the thumb that is dragged in <see cref="GUI.HorizontalScrollbar" /> controls.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the horizontal scrollbar thumb of the current GUISkin
/// float hSbarValue;
/// GUIStyle style;
///
/// void OnGUI()
/// {
/// GUI.skin.horizontalScrollbarThumb = style;
/// hSbarValue = GUILayout.HorizontalScrollbar(hSbarValue, 1.0f, 0.0f, 10.0f);
/// }
///}
///]]></code>
///</example>
public GUIStyle horizontalScrollbarThumb { get { return m_horizontalScrollbarThumb; } set { m_horizontalScrollbarThumb = value; Apply(); } }
///<summary>Style used by default for the left button on <see cref="GUI.HorizontalScrollbar" /> controls.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the horizontal scrollbar
/// // left button of the current GUISkin
///
/// float hSbarValue;
/// GUIStyle style;
///
/// void OnGUI()
/// {
/// GUI.skin.horizontalScrollbarLeftButton = style;
/// hSbarValue = GUILayout.HorizontalScrollbar(hSbarValue, 1.0f, 0.0f, 10.0f);
/// }
///}
///]]></code>
///</example>
public GUIStyle horizontalScrollbarLeftButton { get { return m_horizontalScrollbarLeftButton; } set { m_horizontalScrollbarLeftButton = value; Apply(); } }
///<summary>Style used by default for the right button on <see cref="GUI.HorizontalScrollbar" /> controls.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the horizontal scrollbar
/// // left button of the current GUISkin
///
/// float hSbarValue;
/// GUIStyle style;
///
/// void OnGUI()
/// {
/// GUI.skin.horizontalScrollbarRightButton = style;
/// hSbarValue = GUILayout.HorizontalScrollbar(hSbarValue, 1.0f, 0.0f, 10.0f);
/// }
///}
///]]></code>
///</example>
public GUIStyle horizontalScrollbarRightButton { get { return m_horizontalScrollbarRightButton; } set { m_horizontalScrollbarRightButton = value; Apply(); } }
[SerializeField]
GUIStyle m_verticalScrollbar;
[SerializeField]
GUIStyle m_verticalScrollbarThumb;
[SerializeField]
GUIStyle m_verticalScrollbarUpButton;
[SerializeField]
GUIStyle m_verticalScrollbarDownButton;
///<summary>Style used by default for the background part of <see cref="GUI.VerticalScrollbar" /> controls.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the default background of the
/// // vertical scrollbar of the current GUISkin
///
/// float hSbarValue;
/// GUIStyle style;
///
/// void OnGUI()
/// {
/// GUI.skin.verticalScrollbar = style;
/// hSbarValue = GUILayout.VerticalScrollbar(hSbarValue, 1.0f, 0.0f, 10.0f);
/// }
///}
///]]></code>
///</example>
public GUIStyle verticalScrollbar { get { return m_verticalScrollbar; } set { m_verticalScrollbar = value; Apply(); } }
///<summary>Style used by default for the thumb that is dragged in <see cref="GUI.VerticalScrollbar" /> controls.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the vertical scrollbar thumb of the current GUISkin
///
/// float hSbarValue;
/// GUIStyle style;
///
/// void OnGUI()
/// {
/// GUI.skin.verticalScrollbarThumb = style;
/// hSbarValue = GUILayout.VerticalScrollbar(hSbarValue, 1.0f, 0.0f, 10.0f);
/// }
///}
///]]></code>
///</example>
public GUIStyle verticalScrollbarThumb { get { return m_verticalScrollbarThumb; } set { m_verticalScrollbarThumb = value; Apply(); } }
///<summary>Style used by default for the up button on <see cref="GUI.VerticalScrollbar" /> controls.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the vertical scrollbar
/// // up button of the current GUISkin
///
/// float hSbarValue;
/// GUIStyle style;
///
/// void OnGUI()
/// {
/// GUI.skin.verticalScrollbarUpButton = style;
/// hSbarValue = GUILayout.VerticalScrollbar(hSbarValue, 1.0f, 0.0f, 10.0f);
/// }
///}
///]]></code>
///</example>
public GUIStyle verticalScrollbarUpButton { get { return m_verticalScrollbarUpButton; } set { m_verticalScrollbarUpButton = value; Apply(); } }
///<summary>Style used by default for the down button on <see cref="GUI.VerticalScrollbar" /> controls.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the vertical scrollbar
/// // down button of the current GUISkin
///
/// float hSbarValue;
/// GUIStyle style;
///
/// void OnGUI()
/// {
/// GUI.skin.verticalScrollbarDownButton = style;
/// hSbarValue = GUILayout.VerticalScrollbar(hSbarValue, 1.0f, 0.0f, 10.0f);
/// }
///}
///]]></code>
///</example>
public GUIStyle verticalScrollbarDownButton { get { return m_verticalScrollbarDownButton; } set { m_verticalScrollbarDownButton = value; Apply(); } }
// Background style for scroll views.
[SerializeField]
GUIStyle m_ScrollView;
///<summary>Style used by default for the background of ScrollView controls (see <see cref="GUI.BeginScrollView" />).</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Modifies only the background of the ScrollView controls
/// // of the current GUISkin.
///
/// Vector2 scrollPosition = Vector2.zero;
/// public GUIStyle style;
///
/// void OnGUI()
/// {
/// GUI.skin.scrollView = style;
/// // rect and put it in a small rect on the screen.
/// scrollPosition = GUI.BeginScrollView(new Rect(10, 300, 100, 100),
/// scrollPosition, new Rect(0, 0, 220, 200));
///
/// // Make four buttons - one in each corner. The coordinate system is defined
/// // by the last parameter to BeginScrollView.
/// GUI.Button(new Rect(0, 0, 100, 20), "Top-left");
/// GUI.Button(new Rect(120, 0, 100, 20), "Top-right");
/// GUI.Button(new Rect(0, 180, 100, 20), "Bottom-left");
/// GUI.Button(new Rect(120, 180, 100, 20), "Bottom-right");
///
/// // End the scroll view that we began above.
/// GUI.EndScrollView();
/// }
///}
///]]></code>
///</example>
public GUIStyle scrollView { get { return m_ScrollView; } set { m_ScrollView = value; Apply(); } }
///<exclude />
[SerializeField]
internal GUIStyle[] m_CustomStyles;
///<summary>Array of GUI styles for specific needs.</summary>
public GUIStyle[] customStyles { get { return m_CustomStyles; } set { m_CustomStyles = value; Apply(); } }
[SerializeField]
private GUISettings m_Settings = new GUISettings();
///<summary>Generic settings for how controls should behave with this skin.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Sets the selection color to cyan
///
/// string str = "This is a string with\ntwo lines of text";
///
/// void OnGUI()
/// {
/// GUI.skin.settings.selectionColor = Color.cyan;
/// str = GUILayout.TextArea(str);
/// }
///}
///]]></code>
///</example>
public GUISettings settings { get { return m_Settings; } }
///<exclude />
[NoAutoStaticsCleanup] // lazy-cache sentinel GUIStyle; recreated on demand via null check; no user-assembly refs
internal static GUIStyle ms_Error;
internal static GUIStyle error
{
get
{
if (ms_Error == null)
{
ms_Error = new GUIStyle();
ms_Error.name = "StyleNotFoundError";
}
return ms_Error;
}
}
private Dictionary<string, GUIStyle> m_Styles = null;
internal void Apply()
{
if (m_CustomStyles == null)
Debug.Log("custom styles is null");
BuildStyleCache();
}
private void BuildStyleCache()
{
if (m_box == null) m_box = new GUIStyle();
if (m_button == null) m_button = new GUIStyle();
if (m_toggle == null) m_toggle = new GUIStyle();
if (m_label == null) m_label = new GUIStyle();
if (m_window == null) m_window = new GUIStyle();
if (m_textField == null) m_textField = new GUIStyle();
if (m_textArea == null) m_textArea = new GUIStyle();
if (m_horizontalSlider == null) m_horizontalSlider = new GUIStyle();
if (m_horizontalSliderThumb == null) m_horizontalSliderThumb = new GUIStyle();
if (m_verticalSlider == null) m_verticalSlider = new GUIStyle();
if (m_verticalSliderThumb == null) m_verticalSliderThumb = new GUIStyle();
if (m_horizontalScrollbar == null) m_horizontalScrollbar = new GUIStyle();
if (m_horizontalScrollbarThumb == null) m_horizontalScrollbarThumb = new GUIStyle();
if (m_horizontalScrollbarLeftButton == null) m_horizontalScrollbarLeftButton = new GUIStyle();
if (m_horizontalScrollbarRightButton == null) m_horizontalScrollbarRightButton = new GUIStyle();
if (m_verticalScrollbar == null) m_verticalScrollbar = new GUIStyle();
if (m_verticalScrollbarThumb == null) m_verticalScrollbarThumb = new GUIStyle();
if (m_verticalScrollbarUpButton == null) m_verticalScrollbarUpButton = new GUIStyle();
if (m_verticalScrollbarDownButton == null) m_verticalScrollbarDownButton = new GUIStyle();
if (m_ScrollView == null) m_ScrollView = new GUIStyle();
m_Styles = new Dictionary<string, GUIStyle>(StringComparer.OrdinalIgnoreCase);
m_Styles["box"] = m_box;
m_box.name = "box";
m_Styles["button"] = m_button;
m_button.name = "button";
m_Styles["toggle"] = m_toggle;
m_toggle.name = "toggle";
m_Styles["label"] = m_label;
m_label.name = "label";
m_Styles["window"] = m_window;
m_window.name = "window";
m_Styles["textfield"] = m_textField;
m_textField.name = "textfield";
m_Styles["textarea"] = m_textArea;
m_textArea.name = "textarea";
m_Styles["horizontalslider"] = m_horizontalSlider;
m_horizontalSlider.name = "horizontalslider";
m_Styles["horizontalsliderthumb"] = m_horizontalSliderThumb;
m_horizontalSliderThumb.name = "horizontalsliderthumb";
m_Styles["verticalslider"] = m_verticalSlider;
m_verticalSlider.name = "verticalslider";
m_Styles["verticalsliderthumb"] = m_verticalSliderThumb;
m_verticalSliderThumb.name = "verticalsliderthumb";
m_Styles["horizontalscrollbar"] = m_horizontalScrollbar;
m_horizontalScrollbar.name = "horizontalscrollbar";
m_Styles["horizontalscrollbarthumb"] = m_horizontalScrollbarThumb;
m_horizontalScrollbarThumb.name = "horizontalscrollbarthumb";
m_Styles["horizontalscrollbarleftbutton"] = m_horizontalScrollbarLeftButton;
m_horizontalScrollbarLeftButton.name = "horizontalscrollbarleftbutton";
m_Styles["horizontalscrollbarrightbutton"] = m_horizontalScrollbarRightButton;
m_horizontalScrollbarRightButton.name = "horizontalscrollbarrightbutton";
m_Styles["verticalscrollbar"] = m_verticalScrollbar;
m_verticalScrollbar.name = "verticalscrollbar";
m_Styles["verticalscrollbarthumb"] = m_verticalScrollbarThumb;
m_verticalScrollbarThumb.name = "verticalscrollbarthumb";
m_Styles["verticalscrollbarupbutton"] = m_verticalScrollbarUpButton;
m_verticalScrollbarUpButton.name = "verticalscrollbarupbutton";
m_Styles["verticalscrollbardownbutton"] = m_verticalScrollbarDownButton;
m_verticalScrollbarDownButton.name = "verticalscrollbardownbutton";
m_Styles["scrollview"] = m_ScrollView;
m_ScrollView.name = "scrollview";
if (m_CustomStyles != null)
{
for (int i = 0; i < m_CustomStyles.Length; i++)
{
if (m_CustomStyles[i] == null)
continue;
m_Styles[m_CustomStyles[i].name] = m_CustomStyles[i];
}
}
if (!m_Styles.TryGetValue("HorizontalSliderThumbExtent", out m_horizontalSliderThumbExtent))
{
m_horizontalSliderThumbExtent = new GUIStyle();
m_horizontalSliderThumbExtent.name = "horizontalsliderthumbextent";
m_Styles["HorizontalSliderThumbExtent"] = m_horizontalSliderThumbExtent;
}
if (!m_Styles.TryGetValue("SliderMixed", out m_SliderMixed))
{
m_SliderMixed = new GUIStyle();
m_SliderMixed.name = "SliderMixed";
m_Styles["SliderMixed"] = m_SliderMixed;
}
if (!m_Styles.TryGetValue("VerticalSliderThumbExtent", out m_verticalSliderThumbExtent))
{
m_verticalSliderThumbExtent = new GUIStyle();
m_Styles["VerticalSliderThumbExtent"] = m_verticalSliderThumbExtent;
m_verticalSliderThumbExtent.name = "verticalsliderthumbextent";
}
error.stretchHeight = true;
error.normal.textColor = Color.red;
}
///<summary>Get a named <see cref="GUIStyle" />.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// bool b;
///
/// void OnGUI()
/// {
/// b = GUILayout.Toggle(b, "A toggle button", GUI.skin.GetStyle("Button"));
/// }
///}
///]]></code>
///</example>
public GUIStyle GetStyle(string styleName)
{
GUIStyle s = FindStyle(styleName);
if (s != null)
return s;
Debug.LogWarning("Unable to find style '" + styleName + "' in skin '" + name + "' " + (Event.current != null ? Event.current.type.ToString() : "<called outside OnGUI>"));
return error;
}
///<summary>Try to search for a <see cref="GUIStyle" />. This functions returns NULL and does not give an error.</summary>
///<example>
/// <code><![CDATA[
///using UnityEngine;
///
///public class Example : MonoBehaviour
///{
/// // Checks if a style name exists
///
/// string aStyleName = "A Style I have";
///
/// void OnGUI()
/// {
/// if (GUI.skin.FindStyle(aStyleName) == null)
/// {
/// Debug.LogWarning("No style named \"" + aStyleName + "\" could be found");
/// }
/// }
///}
///]]></code>
///</example>
public GUIStyle FindStyle(string styleName)
{
if (m_Styles == null)
BuildStyleCache();
GUIStyle style;
if (m_Styles.TryGetValue(styleName, out style))
return style;
return null;
}
internal delegate void SkinChangedDelegate();
///<exclude />
[NoAutoStaticsCleanup] // wired once by EditorGUIUtility's static ctor (UnityEditor.dll, never reloaded); clearing on reload orphans it permanently
internal static SkinChangedDelegate m_SkinChanged;
///<summary>Make this the current skin used by the GUI.</summary>
[NoAutoStaticsCleanup] // active skin reference set each frame by MakeCurrent; stale ref after reload is overwritten before any GUI render
static internal GUISkin current;
internal void MakeCurrent()
{
current = this;
GUIStyle.SetDefaultFont(font);
if (m_SkinChanged != null)
m_SkinChanged();
}
//*undocumented* Documented separately
///<exclude />
public IEnumerator GetEnumerator()
{
if (m_Styles == null)
BuildStyleCache();
return m_Styles.Values.GetEnumerator();
}
}
}