Light









How do I use Light
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: HubGui.cs Copy
28     void OnGUI()
29     {
30         GUI.skin = this.Skin;
31         GUILayout.Space(10);
32
33         GUILayout.BeginHorizontal();
34         GUILayout.Space(10);
35         scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Width(320));
36
37         GUILayout.Label("Basics", m_Headline);
38         if (GUILayout.Button("Demo Boxes", GUILayout.Width(280)))
39         {
40             demoDescription = "Demo Boxes\n\nUses ConnectAndJoinRandom script.\n(joins a random room or creates one)\n\nInstantiates simple prefab.\nSynchronizes positions without smoothing.";
41             demoBtn = new DemoBtn() { Text = "Start", Link = "DemoBoxes-Scene" };
42         }
43         if (GUILayout.Button("Demo Worker", GUILayout.Width(280)))
44         {
45             demoDescription = "Demo Worker\n\nJoins the default lobby and shows existing rooms.\nLets you create or join a room.\nInstantiates an animated character.\nSynchronizes position and animation state of character with smoothing.\nImplements simple in-room Chat via RPC calls.";
46             demoBtn = new DemoBtn() { Text = "Start", Link = "DemoWorker-Scene" };
47         }
48         if (GUILayout.Button("Movement Smoothing", GUILayout.Width(280)))
49         {
50             demoDescription = "Movement Smoothing\n\nUses ConnectAndJoinRandom script.\nShows several basic ways to update positions of remote objects.";
51             demoBtn = new DemoBtn() { Text = "Start", Link = "DemoSynchronization-Scene" };
52         }
53
54         GUILayout.Label("Advanced", m_Headline);
55         if (GUILayout.Button("Ownership Transfer", GUILayout.Width(280)))
56         {
57             demoDescription = "Ownership Transfer\n\nShows how to transfer the ownership of a PhotonView.\nThe owner will send position updates of the GameObject.\nTransfer can be edited per PhotonView and set to Fixed (no transfer), Request (owner has to agree) or Takeover (owner can't object).";
58             this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoChangeOwner-Scene" };
59             this.webLink = new DemoBtn();
60         }
61         if (GUILayout.Button("Pickup, Teams, Scores", GUILayout.Width(280)))
62         {
63             demoDescription = "Pickup, Teams, Scores\n\nUses ConnectAndJoinRandom script.\nImplements item pickup with RPCs.\nUses Custom Properties for Teams.\nCounts score per player and team.\nUses PhotonPlayer extension methods for easy Custom Property access.";
64             this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoPickup-Scene" };
65             this.webLink = new DemoBtn();
66         }
67
68         GUILayout.Label("Feature Demos", m_Headline);
69         if (GUILayout.Button("Chat", GUILayout.Width(280)))
70         {
71             demoDescription = "Chat\n\nUses the Chat API (now part of PUN).\nSimple UI.\nYou can enter any User ID.\nAutomatically subscribes some channels.\nAllows simple commands via text.\n\nRequires configuration of Chat App ID in scene.";
72             this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoChat-Scene" };
73             this.webLink = new DemoBtn();
74         }
75         if (GUILayout.Button("RPG Movement", GUILayout.Width(280)))
76         {
77             demoDescription = "RPG Movement\n\nDemonstrates how to use the PhotonTransformView component to synchronize position updates smoothly using inter- and extrapolation.\n\nThis demo also shows how to setup a Mecanim Animator to update animations automatically based on received position updates (without sending explicit animation updates).";
78             this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoRPGMovement-Scene" };
79             this.webLink = new DemoBtn();
80         }
81         if (GUILayout.Button("Mecanim Animations", GUILayout.Width(280)))
82         {
83             demoDescription = "Mecanim Animations\n\nThis demo shows how to use the PhotonAnimatorView component to easily synchronize Mecanim animations.\n\nIt also demonstrates another feature of the PhotonTransformView component which gives you more control how position updates are inter-/extrapolated by telling the component how fast the object moves and turns using SetSynchronizedValues().";
84             this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoMecanim-Scene" };
85             this.webLink = new DemoBtn();
86         }
87         if (GUILayout.Button("2D Game", GUILayout.Width(280)))
88         {
89             demoDescription = "2D Game Demo\n\nSynchronizes animations, positions and physics in a 2D scene.";
90             this.demoBtn = new DemoBtn() { Text = "Start", Link = "Demo2DJumpAndRunWithPhysics-Scene" };
91             this.webLink = new DemoBtn();
92         }
93         if (GUILayout.Button("Friends & Authentication", GUILayout.Width(280)))
94         {
95             demoDescription = "Friends & Authentication\n\nShows connect with or without (server-side) authentication.\n\nAuthentication requires minor server-side setup (in Dashboard).\n\nOnce connected, you can find (made up) friends.\nJoin a room just to see how that gets visible in friends list.";
96             this.demoBtn = new DemoBtn() { Text = "Start", Link = "DemoFriends-Scene" };
97             this.webLink = new DemoBtn();
98         }
99
100         GUILayout.Label("Tutorial", m_Headline);
101         if (GUILayout.Button("Marco Polo Tutorial", GUILayout.Width(280)))
102         {
103             demoDescription = "Marco Polo Tutorial\n\nFinal result you could get when you do the Marco Polo Tutorial.\nSlightly modified to be more compatible with this package.";
104             this.demoBtn = new DemoBtn() { Text = "Start", Link = "MarcoPolo-Scene" };
105             this.webLink = new DemoBtn() { Text = "Open Tutorial (www)", Link = "http://tinyurl.com/nmylf44" };
106         }
107         GUILayout.EndScrollView();
108
109         GUILayout.BeginVertical(GUILayout.Width(Screen.width - 345));
110         GUILayout.Label(demoDescription);
111         GUILayout.Space(10);
112         if (!string.IsNullOrEmpty(this.demoBtn.Text))
113         {
114             if (GUILayout.Button(this.demoBtn.Text))
115             {
116                 Application.LoadLevel(this.demoBtn.Link);
117             }
118         }
119         if (!string.IsNullOrEmpty(this.webLink.Text))
120         {
121             if (GUILayout.Button(this.webLink.Text))
122             {
123                 Application.OpenURL(this.webLink.Link);
124             }
125         }
126         GUILayout.EndVertical();
127
128
129         GUILayout.EndHorizontal();
130     }
File name: PhotonEditor.cs Copy
543     protected virtual void OnGuiMainWizard()
544     {
545         GUILayout.BeginHorizontal();
546         GUILayout.FlexibleSpace();
547         GUILayout.Label(WizardIcon);
548         GUILayout.FlexibleSpace();
549         GUILayout.EndHorizontal();
550
551         EditorGUILayout.Separator();
552
553         GUILayout.Label(CurrentLang.PUNWizardLabel, EditorStyles.boldLabel);
554         if (isPunPlus)
555         {
556             GUILayout.Label(CurrentLang.MobilePunPlusExportNoteLabel);
557         }
558         else if (!InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.Android) || !InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.iOS))
559         {
560             GUILayout.Label(CurrentLang.MobileExportNoteLabel);
561         }
562         EditorGUILayout.Separator();
563
564
565         // settings button
566         GUILayout.BeginHorizontal();
567         GUILayout.Label(CurrentLang.SettingsButton, EditorStyles.boldLabel, GUILayout.Width(100));
568         if (GUILayout.Button(new GUIContent(CurrentLang.SetupButton, CurrentLang.SetupServerCloudLabel)))
569         {
570             this.InitPhotonSetupWindow();
571         }
572
573         GUILayout.EndHorizontal();
574         EditorGUILayout.Separator();
575
576
577         // find / select settings asset
578         GUILayout.BeginHorizontal();
579         GUILayout.Label(CurrentLang.SettingsFileLabel, EditorStyles.boldLabel, GUILayout.Width(100));
580         if (GUILayout.Button(new GUIContent(CurrentLang.LocateSettingsButton, CurrentLang.SettingsHighlightLabel)))
581         {
582             EditorGUIUtility.PingObject(PhotonEditor.Current);
583         }
584
585         GUILayout.EndHorizontal();
586
587
588         GUILayout.FlexibleSpace();
589
590         // converter
591         GUILayout.BeginHorizontal();
592         GUILayout.Label(CurrentLang.ConverterLabel, EditorStyles.boldLabel, GUILayout.Width(100));
593         if (GUILayout.Button(new GUIContent(CurrentLang.StartButton, CurrentLang.UNtoPUNLabel)))
594         {
595             PhotonConverter.RunConversion();
596         }
597
598         GUILayout.EndHorizontal();
599         EditorGUILayout.Separator();
600
601
602         // documentation
603         GUILayout.BeginHorizontal();
604         GUILayout.Label(CurrentLang.DocumentationLabel, EditorStyles.boldLabel, GUILayout.Width(100));
605         GUILayout.BeginVertical();
606         if (GUILayout.Button(new GUIContent(CurrentLang.OpenPDFText, CurrentLang.OpenPDFTooltip)))
607         {
608             EditorUtility.OpenWithDefaultApp(DocumentationLocation);
609         }
610
611         if (GUILayout.Button(new GUIContent(CurrentLang.OpenDevNetText, CurrentLang.OpenDevNetTooltip)))
612         {
613             EditorUtility.OpenWithDefaultApp(UrlDevNet);
614         }
615
616         if (GUILayout.Button(new GUIContent(CurrentLang.OpenCloudDashboardText, CurrentLang.OpenCloudDashboardTooltip)))
617         {
618             EditorUtility.OpenWithDefaultApp(UrlCloudDashboard + Uri.EscapeUriString(this.emailAddress));
619         }
620
621         if (GUILayout.Button(new GUIContent(CurrentLang.OpenForumText, CurrentLang.OpenForumTooltip)))
622         {
623             EditorUtility.OpenWithDefaultApp(UrlForum);
624         }
625
626         GUILayout.EndVertical();
627         GUILayout.EndHorizontal();
628     }
File name: ReorderableListResources.cs Copy
45         private static string[] s_LightSkin = {
46             "iVBORw0KGgoAAAANSUhEUgAAAB4AAAAQCAYAAAABOs/SAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAAW0lEQVRIS+3NywnAQAhF0anI4mzVCmzBBl7QEBgGE5JFhBAXd+OHM5gZZgYRKcktNxu+HRFF2e6qhtOjtQM7K/tZ+xY89wSbazg9eqOfw6oag4rcChjY8coAjA2l1RxFDY8IFAAAAABJRU5ErkJggg==",
47             "iVBORw0KGgoAAAANSUhEUgAAAB4AAAAQCAYAAAABOs/SAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAGlJREFUeNpiFBER+f/jxw8GNjY2BnqAX79+MXBwcDAwMQwQGHoWnzp1CoxHjo8pBSykBi8+MTMzs2HmY2QfwXxKii9HExdZgNwgHuFB/efPH7pZCLOL8f///wyioqL/6enbL1++MAIEGABvGSLA+9GPZwAAAABJRU5ErkJggg==",
48             "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAECAYAAABGM/VAAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAAMElEQVQYV2P4//8/Q1FR0X8YBvHBAp8+ffp/+fJlMA3igwUfPnwIFgDRYEFM7f8ZAG1EOYL9INrfAAAAAElFTkSuQmCC",
49             "iVBORw0KGgoAAAANSUhEUgAAAAkAAAAFCAYAAACXU8ZrAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAAIElEQVQYV2P49OnTf0KYobCw8D8hzPD/P2FMLesK/wMAs5yJpK+6aN4AAAAASUVORK5CYII=",
50             "iVBORw0KGgoAAAANSUhEUgAAAAgAAAACCAIAAADq9gq6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABVJREFUeNpiVFZWZsAGmBhwAIAAAwAURgBt4C03ZwAAAABJRU5ErkJggg==",
51             "iVBORw0KGgoAAAANSUhEUgAAAAgAAAACCAIAAADq9gq6AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABVJREFUeNpivHPnDgM2wMSAAwAEGAB8VgKYlvqkBwAAAABJRU5ErkJggg==",
52             "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAECAYAAABGM/VAAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAEFJREFUeNpi/P//P0NxcfF/BgRgZP78+fN/VVVVhpCQEAZjY2OGs2fPNrCApBwdHRkePHgAVwoWnDVrFgMyAAgwAAt4E1dCq1obAAAAAElFTkSuQmCC"
53         };
File name: ReorderableListResources.cs Copy
168         private static void LoadResourceAssets()
169         {
170             var skin = EditorGUIUtility.isProSkin ? s_DarkSkin : s_LightSkin;
171             s_Cached = new Texture2D[ skin.Length ];
172
173             for( int i = 0; i < s_Cached.Length; ++i )
174             {
175                 // Get image data (PNG) from base64 encoded strings.
176                 byte[] imageData = Convert.FromBase64String( skin[ i ] );
177
178                 // Gather image size from image data.
179                 int texWidth, texHeight;
180                 GetImageSize( imageData, out texWidth, out texHeight );
181
182                 // Generate texture asset.
183                 var tex = new Texture2D( texWidth, texHeight, TextureFormat.ARGB32, false, true );
184                 tex.hideFlags = HideFlags.HideAndDontSave;
185                 tex.name = "(Generated) ReorderableList:" + i;
186                 tex.filterMode = FilterMode.Point;
187                 tex.LoadImage( imageData );
188
189                 s_Cached[ i ] = tex;
190             }
191
192             s_LightSkin = null;
193             s_DarkSkin = null;
194         }
File name: Node.cs Copy
35  public void HighlightMove() {
36   if (renderer.sharedMaterial != origMaterial) return;
37   SetMaterial(GameManager.Instance.HighlightMoveMaterial);
38  }
File name: Node.cs Copy
40  public void HighlightEat() {
41   if (renderer.sharedMaterial != origMaterial) return;
42   SetMaterial(GameManager.Instance.HighlightEatMaterial);
43  }
File name: Node.cs Copy
45  public void HighlightCheck() {
46   if (renderer.sharedMaterial != origMaterial) return;
47   SetMaterial(GameManager.Instance.HighlightCheckMaterial);
48  }
File name: Node.cs Copy
50  public void UnhighlightMove() {
51   Unhiglight(GameManager.Instance.HighlightMoveMaterial);
52  }
File name: Node.cs Copy
54  public void UnhighlightEat() {
55   Unhiglight(GameManager.Instance.HighlightEatMaterial);
56  }
File name: Node.cs Copy
58  public void UnhighlightCheck() {
59   Unhiglight(GameManager.Instance.HighlightCheckMaterial);
60  }

Download file with original file name:Light

Light 119 lượt xem

Gõ tìm kiếm nhanh...