private void Rotation(int r, int n, int x, int y, out int xp, out int yp) { switch (r) { case 0: xp = x; yp = y; break; case 1: xp = y; yp = n - 1 - x; break; case 2: xp = n - 1 - x; yp = n - 1 - y; break; case 3: xp = n - 1 - y; yp = x; break; default: xp = 0; yp = 0; Logger.LogError("HeightMipmap.Rotation: Something goes wrong!"); Debug.Break(); break; } }
private void SaveScreenshot(Texture2D screenShotTexture, string fileName = "Screenshot") { if (screenShotTexture != null) { var filePath = string.Format("{0}/{1}_{2:yy.MM.dd-hh.mm.ss}_{3}", Application.dataPath, fileName, DateTime.Now, (int)UnityEngine.Random.Range(0.0f, 100.0f)); switch (Format) { case ScreenshotFormat.JPG: File.WriteAllBytes(filePath + ".jpg", screenShotTexture.EncodeToJPG(100)); break; case ScreenshotFormat.PNG: File.WriteAllBytes(filePath + ".png", screenShotTexture.EncodeToPNG()); break; default: throw new ArgumentOutOfRangeException(); } Logger.Log(string.Format("ScreenshotHelper: Screenshot Saved. {0}", filePath)); #if UNITY_EDITOR AssetDatabase.Refresh(); #endif } else { Logger.LogError("ScreenshotHelper: screenShotTexture is null!"); } }
private void LoadAssembly(string path) { try { var assembly = Assembly.LoadFile(path); var attrbutes = assembly.GetCustomAttributes(typeof(SpaceAddonAssembly), false) as SpaceAddonAssembly[]; if (attrbutes == null || attrbutes.Length == 0) { Logger.LogError(string.Format("AssemblyLoader.LoadAssembly: This is not an adddon assembly! {0}", path)); } else { var addonAssembly = attrbutes[0]; var mb = GetAllSubclassesOf <Type, SpaceAddonMonoBehaviour, MonoBehaviour>(assembly); var aet = new AssemblyExternalTypes(typeof(MonoBehaviour), mb); var ae = new AssemblyExternal(path, addonAssembly.Name, addonAssembly.Version, assembly, aet); ExternalAssemblies.Add(ae); TotalLoaded++; FireHotPlugin(ae); } } catch (Exception ex) { Logger.LogError(string.Format("AssemblyLoader.LoadAssembly: LoadAssembly Exception: {0}", ex.Message)); } }
private void LoadDetectedAssemblies(List <string> allPaths) { if (allPaths == null) { DetectAssembies(out allPaths); Logger.LogError("Something wrong with path's array! Detecting assemblies again!"); } for (int i = 0; i < allPaths.Count; i++) { string path = allPaths[i]; //Delay(0.5f, () => { LoadAssembly(path); }); LoadAssembly(path); } }
private void DetectAssembies(out List <string> allPaths) { var path = PathGlobals.GlobalModFolderPath; allPaths = new List <string>(); try { allPaths.AddRange(Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories)); } catch (Exception ex) { Logger.LogError(string.Format("AssemblyLoader.DetectAssembies: Exception: {0}", ex.Message)); } TotalDetected = allPaths.Count; Logger.Log(string.Format("AssemblyLoader.DetectAssembies: Assembies Detected: {0}", allPaths.Count)); }