Assembly









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

Featured Snippets


File name: PhotonEditor.cs Copy
975     public static System.Type[] GetAllSubTypesInScripts(System.Type aBaseClass)
976     {
977         var result = new System.Collections.Generic.List();
978         System.Reflection.Assembly[] AS = System.AppDomain.CurrentDomain.GetAssemblies();
979         foreach (var A in AS)
980         {
981             // this skips all but the Unity-scripted assemblies for RPC-list creation. You could remove this to search all assemblies in project
982             if (!A.FullName.StartsWith("Assembly-"))
983             {
984                 // Debug.Log("Skipping Assembly: " + A);
985                 continue;
986             }
987
988             //Debug.Log("Assembly: " + A.FullName);
989             System.Type[] types = A.GetTypes();
990             foreach (var T in types)
991             {
992                 if (T.IsSubclassOf(aBaseClass))
993                     result.Add(T);
994             }
995         }
996         return result.ToArray();
997     }
File name: NetworkingPeer.cs Copy
185     public NetworkingPeer(IPhotonPeerListener listener, string playername, ConnectionProtocol connectionProtocol) : base(listener, connectionProtocol)
186     {
187         #if !UNITY_EDITOR && (UNITY_WINRT)
188         // this automatically uses a separate assembly-file with Win8-style Socket usage (not possible in Editor)
189         Debug.LogWarning("Using PingWindowsStore");
190         PhotonHandler.PingImplementation = typeof(PingWindowsStore); // but for ping, we have to set the implementation explicitly to Win 8 Store/Phone
191         #endif
192
193         #pragma warning disable 0162 // the library variant defines if we should use PUN's SocketUdp variant (at all)
194         if (PhotonPeer.NoSocket)
195         {
196             #if !UNITY_EDITOR && (UNITY_PS3 || UNITY_ANDROID)
197             Debug.Log("Using class SocketUdpNativeDynamic");
198             this.SocketImplementation = typeof(SocketUdpNativeDynamic);
199             PhotonHandler.PingImplementation = typeof(PingNativeDynamic);
200             #elif !UNITY_EDITOR && UNITY_IPHONE
201             Debug.Log("Using class SocketUdpNativeStatic");
202             this.SocketImplementation = typeof(SocketUdpNativeStatic);
203             PhotonHandler.PingImplementation = typeof(PingNativeStatic);
204             #elif !UNITY_EDITOR && (UNITY_WINRT)
205             // this automatically uses a separate assembly-file with Win8-style Socket usage (not possible in Editor)
206             #else
207             this.SocketImplementation = typeof (SocketUdp);
208             PhotonHandler.PingImplementation = typeof(PingMonoEditor);
209             #endif
210
211             if (this.SocketImplementation == null)
212             {
213                 Debug.Log("No socket implementation set for 'NoSocket' assembly. Please contact Exit Games.");
214             }
215         }
216         #pragma warning restore 0162
217
218         if (PhotonHandler.PingImplementation == null)
219         {
220             PhotonHandler.PingImplementation = typeof(PingMono);
221         }
222
223         this.Listener = this;
224         this.lobby = TypedLobby.Default;
225         this.LimitOfUnreliableCommands = 40;
226
227         // don't set the field directly! the listener is passed on to other classes, which get updated by the property set method
228         this.externalListener = listener;
229         this.PlayerName = playername;
230         this.mLocalActor = new PhotonPlayer(true, -1, this.playername);
231         this.AddNewPlayer(this.mLocalActor.ID, this.mLocalActor);
232
233         // RPC shortcut lookup creation (from list of RPCs, which is updated by Editor scripts)
234         rpcShortcuts = new Dictionary(PhotonNetwork.PhotonServerSettings.RpcList.Count);
235         for (int index = 0; index < PhotonNetwork.PhotonServerSettings.RpcList.Count; index++)
236         {
237             var name = PhotonNetwork.PhotonServerSettings.RpcList[index];
238             rpcShortcuts[name] = index;
239         }
240
241         this.State = global::PeerState.PeerCreated;
242     }
File name: ChatClient.cs Copy
94         public bool Connect(string address, ConnectionProtocol protocol, string appId, string appVersion, string userId, AuthenticationValues authValues)
95         {
96             if (!this.HasPeer)
97             {
98                 this.chatPeer = new ChatPeer(this, protocol);
99             }
100             else
101             {
102                 this.Disconnect();
103                 if (this.chatPeer.UsedProtocol != protocol)
104                 {
105                     this.chatPeer = new ChatPeer(this, protocol);
106                 }
107             }
108
109#if UNITY
110#pragma warning disable 0162 // the library variant defines if we should use PUN's SocketUdp variant (at all)
111             if (PhotonPeer.NoSocket)
112             {
113#if !UNITY_EDITOR && (UNITY_PS3 || UNITY_ANDROID)
114                 UnityEngine.Debug.Log("Using class SocketUdpNativeDynamic");
115                 this.chatPeer.SocketImplementation = typeof(SocketUdpNativeDynamic);
116#elif !UNITY_EDITOR && UNITY_IPHONE
117                 UnityEngine.Debug.Log("Using class SocketUdpNativeStatic");
118                 this.chatPeer.SocketImplementation = typeof(SocketUdpNativeStatic);
119#elif !UNITY_EDITOR && (UNITY_WINRT)
120                 // this automatically uses a separate assembly-file with Win8-style Socket usage (not possible in Editor)
121#else
122                 Type udpSocket = Type.GetType("ExitGames.Client.Photon.SocketUdp, Assembly-CSharp");
123                 this.chatPeer.SocketImplementation = udpSocket;
124                 if (udpSocket == null)
125                 {
126                     UnityEngine.Debug.Log("ChatClient could not find a suitable C# socket class. The Photon3Unity3D.dll only supports native socket plugins.");
127                 }
128#endif
129                 if (this.chatPeer.SocketImplementation == null)
130                 {
131                     UnityEngine.Debug.Log("No socket implementation set for 'NoSocket' assembly. Please contact Exit Games.");
132                 }
133             }
134#pragma warning restore 0162
135#endif
136
137             this.chatPeer.TimePingInterval = 3000;
138             this.DisconnectedCause = ChatDisconnectCause.None;
139
140             this.CustomAuthenticationValues = authValues;
141             this.UserId = userId;
142             this.AppId = appId;
143             this.AppVersion = appVersion;
144             this.didAuthenticate = false;
145             this.msDeltaForServiceCalls = 100;
146
147
148             // clean all channels
149             this.PublicChannels.Clear();
150             this.PrivateChannels.Clear();
151
152             if (!address.Contains(":"))
153             {
154                 int port = 0;
155                 ProtocolToNameServerPort.TryGetValue(protocol, out port);
156                 address = string.Format("{0}:{1}", address, port);
157             }
158
159             bool isConnecting = this.chatPeer.Connect(address, "NameServer");
160             if (isConnecting)
161             {
162                 this.State = ChatState.ConnectingToNameServer;
163             }
164             return isConnecting;
165         }
File name: ReadmeEditor.cs Copy
37  static void LoadLayout()
38  {
39   var assembly = typeof(EditorApplication).Assembly;
40   var windowLayoutType = assembly.GetType("UnityEditor.WindowLayout", true);
41   var method = windowLayoutType.GetMethod("LoadWindowLayout", BindingFlags.Public | BindingFlags.Static);
42   method.Invoke(null, new object[]{Path.Combine(Application.dataPath, "TutorialInfo/Layout.wlt"), false});
43  }
File name: frmAbout.cs Copy
13         public frmAbout()
14         {
15             InitializeComponent();
16             this.Text = String.Format("About {0}", AssemblyTitle);
17             this.labelProductName.Text = AssemblyProduct;
18             this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion);
19             this.labelCopyright.Text = AssemblyCopyright;
20             this.labelCompanyName.Text = AssemblyCompany;
21             this.textBoxDescription.Text = AssemblyDescription;
22         }
File name: frmAbout.cs Copy
27         {
28             get
29             {
30                 object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
31                 if (attributes.Length > 0)
32                 {
33                     AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
34                     if (titleAttribute.Title != "")
35                     {
36                         return titleAttribute.Title;
37                     }
38                 }
39                 return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
40             }
41         }
File name: frmAbout.cs Copy
44         {
45             get
46             {
47                 return Assembly.GetExecutingAssembly().GetName().Version.ToString();
48             }
49         }
File name: frmAbout.cs Copy
52         {
53             get
54             {
55                 object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
56                 if (attributes.Length == 0)
57                 {
58                     return "";
59                 }
60                 return ((AssemblyDescriptionAttribute)attributes[0]).Description;
61             }
62         }
File name: frmAbout.cs Copy
65         {
66             get
67             {
68                 object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), false);
69                 if (attributes.Length == 0)
70                 {
71                     return "";
72                 }
73                 return ((AssemblyProductAttribute)attributes[0]).Product;
74             }
75         }
File name: frmAbout.cs Copy
78         {
79             get
80             {
81                 object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
82                 if (attributes.Length == 0)
83                 {
84                     return "";
85                 }
86                 return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
87             }
88         }

Download file with original file name:Assembly

Assembly 120 lượt xem

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