unsafe static PdbImportAttribute() { foreach (var field in GetFieldsWithAttribute <PdbImportAttribute>()) { if (!field.IsStatic) { Debug.LogErrorFormat("{0} must be static.", field.Name); continue; } var attr = field.GetCustomAttribute <PdbImportAttribute>(); if (ProgramDatabase.TryGetAddressForSymbol(attr.SymbolName, out IntPtr address)) { if (field.FieldType == typeof(IntPtr)) { field.SetValue(null, address); } else if (field.FieldType == typeof(UIntPtr)) { field.SetValue(null, new UIntPtr(address.ToPointer())); } else if (field.FieldType.IsSubclassOf(typeof(Delegate))) { field.SetValue(null, Marshal.GetDelegateForFunctionPointer(address, field.FieldType)); } else { Debug.LogErrorFormat("{0} must be of IntPtr, UIntPtr or delegate type.", field.Name); } } } }
private static bool CopyFile(string oldPath, string newPath) { bool created = false; if (!File.Exists(newPath)) { bool directoryExist = false; string newPathDirectory = Path.GetDirectoryName(newPath); if (Directory.Exists(newPathDirectory)) { directoryExist = true; } else { try { Directory.CreateDirectory(newPathDirectory); directoryExist = true; } catch (System.Exception e) { Debug.LogErrorFormat("[UIAtlasOptimizeTool.CopyFile]文件夹{0}创建失败:{1}", newPathDirectory, e); } } if (directoryExist) { created = AssetDatabase.CopyAsset(oldPath, newPath); } } return(created); }
public void OnPreprocessBuild(BuildReport report) { Debug.Log( $"[PlotBuildTools] OnPreprocessBuild for target {report.summary.platform} at path {report.summary.outputPath}"); #region Set Build Properties LastBuildTime - Reference: https: //answers.unity.com/questions/1425758/how-can-i-find-all-instances-of-a-scriptable-objec.html //FindAssets uses tags check documentation for more info string[] guids = AssetDatabase.FindAssets($"t:{typeof(BuildSettings)}"); if (guids.Length > 1) { Debug.LogErrorFormat("[PlotBuildTools] Found more than 1 Build Properties: {0}. Using first one!", guids.Length); } if (guids.Length > 0) { string path = AssetDatabase.GUIDToAssetPath(guids[0]); BuildSettings buildSettings = AssetDatabase.LoadAssetAtPath <BuildSettings>(path); buildSettings.LastBuildTime = DateTime.Now.ToString("yyyy/MM/dd-HH:mm:ss"); // case sensitive buildSettings.AndroidBundleVersionCode = BuildSettings.GetBundleVersionCode(); EditorUtility.SetDirty(buildSettings); Debug.LogFormat("[PlotBuildTools] Updated settings LastBuildDate to \"{0}\", bundle to \"{1}\". Settings Path: {2}", buildSettings.LastBuildTime, buildSettings.AndroidBundleVersionCode, path); } else { // TODO: AUTO-CREATE ONE! Debug.LogWarning("[PlotBuildTools] Couldn't find Build Settings, please create one!"); } #endregion }
public static void Generate() { try { Process process = new Process(); process.StartInfo.FileName = GENERATOR_TOOL_PATH; process.StartInfo.CreateNoWindow = true; process.StartInfo.UseShellExecute = false; process.StartInfo.Arguments = string.Format("--default --unityDllPath={0} --noShell", UNITY_DLL_PATH); process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.StartInfo.WorkingDirectory = GENERATOR_TOOL_DIR; process.OutputDataReceived += new DataReceivedEventHandler(OutputHandler); process.ErrorDataReceived += new DataReceivedEventHandler(ErrorHandler); Debug.LogFormat("{0} {1}", GENERATOR_TOOL_EXE, process.StartInfo.Arguments); process.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); } catch (Win32Exception ex) { Debug.LogErrorFormat("Cannot find file {0}", GENERATOR_TOOL_PATH); } }
private static bool UpdateVCSInfo(CocoVCSInfo vcsInfo, string output) { bool changed = false; // commit id string commitId = output.Substring(0, COMMIT_ID_LENGTH); if (!string.Equals(commitId, vcsInfo.CommitId)) { vcsInfo.CommitId = commitId; changed = true; } // load time try { string loadTime = DateTime.UtcNow.ToString(CocoVCSInfoDisplayer.INFO_TIME_FORMAT, CultureInfo.InvariantCulture); if (!string.Equals(loadTime, vcsInfo.LoadTime)) { vcsInfo.LoadTime = loadTime; changed = true; } } catch (Exception e) { Debug.LogErrorFormat("CocoVCSInfoRecorder->UpdateVCSInfo: load time read error! [{0}]", e.Message); } return(changed); }
private ITestRunnerCallbackReceiver[] TriggerBeforeTestRunEvent(IEnumerable <Type> classTypes) { List <ITestRunnerCallbackReceiver> result = new List <ITestRunnerCallbackReceiver>(); foreach (var classType in classTypes) { ITestRunnerCallbackReceiver callbackableInstance = null; try { callbackableInstance = (ITestRunnerCallbackReceiver)Activator.CreateInstance(classType); } catch (Exception ex) { Debug.LogErrorFormat("Can't instantiate class \"{0}\". Exception: \"{1}\"", classType.FullName, ex.Message); continue; } result.Add(callbackableInstance); callbackableInstance.OnBeforeTestsRunEvent(); } return(result.ToArray()); }
/// <summary> /// Install a copy of the specified Prototype to the specified Tile. /// </summary> /// <param name="proto">The Prototype Furniture to use to create an actual instance.</param> /// <param name="tile">The Tile to place the new Furniture onto.</param> /// <returns>The placed Furniture</returns> public static Furniture PlaceInstance(Furniture proto, Tile tile) { if (proto._funcPositionValidation(tile) == false) { Debug.LogErrorFormat("PlaceInstance position [{0},{1}] validity function for {2} returned false.", tile.X, tile.Y, proto.ObjectType); return(null); } var obj = proto.Clone(); obj.Tile = tile; if (tile.PlaceFurniture(obj) == false) { // Something prevented the object being placed. Don't return it, so it gets GC'd out at some point. return(null); } if (obj.LinksToNeighbour) { tile.UpdateNeighbours(); } return(obj); }
private IEnumerator InvokeTestMethod(object instance, MethodNode methodNode) { bool testFinished = false; RunMethod(instance, methodNode.TestSettings.MethodInfo, () => { testFinished = true; }); var currentTimer = 0f; var timeOut = methodNode.TestSettings.TimeOut / 1000; do { yield return(null); currentTimer += Time.unscaledDeltaTime; if (currentTimer >= timeOut) { Debug.LogErrorFormat("Method \"{0}\" failed by timeout.", methodNode.FullName); yield break; } // wait for done } while (!testFinished); yield return(null); //we need to skip one frame to make sure error pause is executed }
void CreateWindowTexture(bool force = false) { var w = width; var h = height; if (w <= 0 || h <= 0) { return; } if (force || !texture || texture.width != w || texture.height != h) { if (backTexture_) { Object.DestroyImmediate(backTexture_); } try { backTexture_ = new Texture2D(w, h, TextureFormat.BGRA32, false); Lib.SetWindowTexturePtr(id, backTexture_.GetNativeTexturePtr()); willTextureSizeChange_ = true; } catch (System.Exception e) { Debug.LogError(e.Message); Debug.LogErrorFormat("Width: {0}, Height: {1}", w, h); } } }
private IEnumerator GetScreenShot() { WaitForEndOfFrame waitForEndOfFrame = new WaitForEndOfFrame(); Texture2D shot = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); Rect area = new Rect(0, 0, Screen.width, Screen.height); screenCnt = 0; while (true) { yield return(waitForEndOfFrame); Profiler.BeginSample("Profiler.ScreenShotCoroutine"); if (NetworkServer.isConnected && NetworkServer.enableScreenShot && !NetworkServer.screenFlag) { if (width != Screen.width) { shot.Resize(Screen.width, Screen.height); width = Screen.width; height = Screen.height; area = new Rect(0, 0, Screen.width, Screen.height); yield return(waitForEndOfFrame); } try { shot.ReadPixels(area, 0, 0, false); shot.Apply(); #if UNITY_2018_2_OR_NEWER nativeRawBytes = shot.GetRawTextureData <byte>(); NetworkServer.SendMessage(nativeRawBytes, 0, width, height); #else rawBytes = shot.GetRawTextureData(); NetworkServer.SendMessage(rawBytes, 0, width, height); #endif NetworkServer.screenFlag = true; screenCnt++; } catch (Exception e) { NetworkServer.screenFlag = false; Debug.LogErrorFormat("[PACKAGE] Screenshot Error {0}\n{1}", e.Message, e.StackTrace); } } Profiler.EndSample(); if (NetworkServer.isConnected && !NetworkServer.sendDeviceInfo) { try { GetSystemDevice(); NetworkServer.sendDeviceInfo = true; } catch (Exception e) { Debug.LogErrorFormat("[PACKAGE] Send SystemDevice Error {0}\n{1}", e.Message, e.StackTrace); } } yield return(waitSeconds); } }
private static void AddCallbackInternal(Dictionary <CallbackType, CallbackCollection> collection, CallbackType type, Func <bool> callback) { if (!collection.ContainsKey(type)) { collection.Add(type, new CallbackCollection()); } NamedFunc namedFunc = new NamedFunc(); // We do PHASED_DEBUG instead of UNITY_EDITOR in case we connect profiler in debug build #if PHASED_DEBUG namedFunc.Name = callback.Target != null? callback.Target.GetType().ToString() + "." + callback.Method.ToString() : callback.Method.ToString(); #endif namedFunc.Func = callback; CallbackCollection callbackCollection = collection[type]; if (callbackCollection.FunctionsDictionary.ContainsKey(callback)) { Debug.LogErrorFormat("Failed to add callback '{0}' to CallbackEvent '{1}' because it is already added.", namedFunc.Name, type.ToString()); return; } callbackCollection.FunctionsList.Add(namedFunc); callbackCollection.FunctionsDictionary.Add(callback, namedFunc); }
private void OpenSelectImportPathDialog(BehaviorControlSetting setting) { var importFolderPath = Prefs.ImportDirectory; if (string.IsNullOrEmpty(importFolderPath)) { importFolderPath = setting.GetImportFolderPath(); } selectionDirectory = null; var directory = EditorUtility.OpenFolderPanel("Import", importFolderPath, string.Empty); if (string.IsNullOrEmpty(directory)) { return; } if (!Directory.Exists(directory)) { Debug.LogErrorFormat("Directory {0} not found.", importFolderPath); } selectionDirectory = directory; displayDirectory = GetRelativeUriFromAssetsFolder(directory); Prefs.ImportDirectory = directory; }
// Simple analog of the Linux/BSD "rmdir" command. public static bool RmDir(string path) { Debug.Log("Removing directory: " + path); if (!Directory.Exists(path)) { Debug.LogWarningFormat("Ignoring, directory not found: {0}", path); return(false); } try { Directory.Delete(path, true); if (string.IsNullOrEmpty(Path.GetFileName(path))) { path = Path.GetDirectoryName(path); } path += ".meta"; if (File.Exists(path)) { File.Delete(path); } } catch (Exception e) { Debug.LogErrorFormat("Exception while deleting '{0}': {1}", path, e); return(false); } return(true); }
public bool Build(BuildPathEnvironmentVariable buildEnvVar = null) { Log("Starting build process for {0}.", Name); try { var relativePath = GenerateRelativeBuildPath(); if (buildEnvVar == null) { buildEnvVar = BuildManagerWindow.LocalBuildRootEnvVar; } var buildRootFolder = buildEnvVar.Value; LocalBuild(relativePath, buildRootFolder); //CopyFolders(relativePath, buildRootFolder); CopyLocalFolders(relativePath, buildRootFolder); CopyLocalFiles(relativePath, buildRootFolder); Deploy(relativePath); } catch (Exception ex) { Debug.LogErrorFormat("Error during build, state unknown. Exception: {0}", ex); return(false); } Log("Ending build process for {0}.", Name); return(true); }
private void TryAddReference(Object asset) { switch (asset) { case GameObject gameObject: if (!PrefabReferences.Contains(gameObject)) { PrefabReferences.Add(gameObject); } break; case ScriptableObject scriptableObject: if (!ScriptableObjectReferences.Contains(scriptableObject)) { ScriptableObjectReferences.Add(scriptableObject); } break; case MonoBehaviour monoBehaviour: if (!SceneReferences.Contains(monoBehaviour)) { SceneReferences.Add(monoBehaviour); } break; default: Debug.LogErrorFormat($"Unexpected Type. Found Object [{asset}], is {asset.GetType()} with base Type {asset.GetType().BaseType}."); break; } }
private static string BuildInternal(BuildItem current) { if (current == null) { UDebug.LogErrorFormat("Cannot found build target config : {0} .", EditorUserBuildSettings.activeBuildTarget); return(null); } var path = current.OutputPath + PackageBuildConfig.Instance.PackageName + current.NamePrefix + DateTime.Now.ToString("_yyyyMMdd_HHmmss") + "." + current.ExtensionName; var report = BuildPipeline.BuildPlayer(Array.ConvertAll(current.Scenes, s => AssetDatabase.GetAssetOrScenePath(s)), path, current.BuildTarget, current.BuildOptions); if (report.summary.result != BuildResult.Succeeded) { return(null); } return(path); }
static Dictionary <string, List <string> > InitLocalResConfig() { Dictionary <string, List <string> > dic = new Dictionary <string, List <string> >(); if (!File.Exists(DataDir + MultiLngFile)) { return(dic); } TableHandler handler = TableHandler.OpenFromData(MultiLngFile); for (int row = 0; row < handler.GetRecordsNum(); row++) { string key = handler.GetValue(row, 0); if (dic.ContainsKey(key)) { Debug.LogErrorFormat("{0}中有重名的键,键名{1}", MultiLngFile, key); continue; } List <string> resNameList = new List <string>(); for (int i = 1; i < handler.GetFieldsNum(); i++) { resNameList.Add(handler.GetValue(row, i)); } dic.Add(key, resNameList); } return(dic); }
/// <summary> /// 搜集打包信息 /// </summary> public bool CollectBuildingAssets(bool isForceReCollect = false) { //初始化数据 this.AssetTypeList = new List <string>(); //1.生成BuildingAssetInfo信息 BuildingAssetInfos buildingCache = null; //获取缓存 if (!this.BuildParams.IsBuilding && !isForceReCollect) { buildingCache = EditorAssetInfosCache.GetBuildingAssetInfosCache(); } //获取buildingAssetinfo this.BuildingAssetInfos = this.GetBuildingAssetInfos(buildingCache); //保存 EditorAssetInfosCache.SaveBuildingAssetInfosCache(this.BuildingAssetInfos); //2.创建AssetRef foreach (var item in this.BuildingAssetInfos.AssetInfoMap) { var arf = AssetReference.CreateReference(item.Key); var ret = this.runtimeAssetsPathList.Contains(item.Key); if (ret) { //创建runtime资源 this.RuntimeAssetsList.Add(arf); } else { this.DependAssetList.Add(arf); } } //检测构造的数据 var count = this.RuntimeAssetsList.Count + this.DependAssetList.Count; if (BuildingAssetInfos.AssetInfoMap.Count != count) { Debug.LogErrorFormat("【初始化框架资源环境】出错! buildinfo:{0} output:{1}", BuildingAssetInfos.AssetInfoMap.Count, count); var tmpBuildAssetsInfo = BuildingAssetInfos.Clone(); foreach (var ra in this.RuntimeAssetsList) { tmpBuildAssetsInfo.AssetInfoMap.Remove(ra.importFrom); } foreach (var drf in this.DependAssetList) { tmpBuildAssetsInfo.AssetInfoMap.Remove(drf.importFrom); } Debug.Log(JsonMapper.ToJson(tmpBuildAssetsInfo.AssetInfoMap, true)); return(false); } return(true); }
static Dictionary <string, ResmapInfo> InitResmap(string resmapName) { Dictionary <string, ResmapInfo> dic = new Dictionary <string, ResmapInfo>(); if (!File.Exists(DataDir + resmapName)) { return(dic); } TableHandler handler = TableHandler.OpenFromData(resmapName); for (int row = 0; row < handler.GetRecordsNum(); row++) { string key = handler.GetValue(row, 0); if (dic.ContainsKey(key)) { Debug.LogErrorFormat("{0}中有重名的键,键名{1}", resmapName, key); continue; } ResmapInfo info = new ResmapInfo() { key = key, editorPath = handler.GetValue(row, 1), abName = handler.GetValue(row, 2), }; dic.Add(key, info); } return(dic); }
public static void E(string title, params object[] args) { #if !NO_DEBUG string[] stringData = Array.ConvertAll <object, string>(args, o => o.ToString()); Debug.LogErrorFormat(FORMAT, title.SetColor(COLOR_ERROR), string.Join(" ", stringData)); #endif }
/// <summary> /// Uninstalls the target application on the target device. /// </summary> /// <param name="packageFamilyName"></param> /// <param name="targetDevice"></param> /// <param name="showDialog"></param> /// <returns>True, if uninstall was a success.</returns> public static bool UninstallApp(string packageFamilyName, ConnectInfo targetDevice, bool showDialog = true) { AppDetails appDetails = QueryAppDetails(packageFamilyName, targetDevice); if (appDetails == null) { Debug.Log(string.Format("Application '{0}' not found", packageFamilyName)); return(false); } string query = string.Format("{0}?package={1}", string.Format(API_InstallQuery, FinalizeUrl(targetDevice.IP)), WWW.EscapeURL(appDetails.PackageFullName)); bool success = WebRequestDelete(query, GetBasicAuthHeader(targetDevice), showDialog); MachineName targetMachine = GetMachineName(targetDevice); if (success) { Debug.LogFormat("Successfully uninstalled {0} on {1}.", packageFamilyName, targetMachine.ComputerName); } else { Debug.LogErrorFormat("Failed to uninstall {0} on {1}", packageFamilyName, targetMachine.ComputerName); } return(success); }
private static bool AutoFetchChanges() { if (repository == null || !IsValidRepo || !Settings.AutoFetch) { return(false); } Remote remote = repository.Network.Remotes.FirstOrDefault(); if (remote == null) { return(false); } GitProfilerProxy.BeginSample("Git automatic fetching"); try { repository.Network.Fetch(remote, new FetchOptions() { CredentialsProvider = GitCredentialsManager.FetchChangesAutoCredentialHandler, OnTransferProgress = FetchTransferProgressHandler }); } catch (Exception e) { Debug.LogErrorFormat("Automatic Fetching from remote: {0} with URL: {1} Failed!", remote.Name, remote.Url); Debug.LogException(e); } finally { EditorUtility.ClearProgressBar(); } GitProfilerProxy.EndSample(); return(false); }
public static void LogWarningFormat(this string format, params object[] args) { if (debugable) { string message = string.Format(format, args); UnityDebug.LogErrorFormat(string.Format("<color=yellow>{0} {1}</color>", WarningFormat, message)); } }
public static void LogErrorFormat(this string format, params object[] args) { if (debugable) { string message = string.Format(format, args); UnityDebug.LogErrorFormat(string.Format("{0} {1}", ErrorFormat, message)); } }
static public void LogErrorFormat(string message, params object[] args) { if (EnableLog) { LogToFile(string.Format(message, args)); Debug.LogErrorFormat(message, args); } }
public UnityEngine.Sprite GetSprite(string atlasName, string spriteName) { if (_sprites.ContainsKey(atlasName) == false || _sprites[atlasName].Sprites.ContainsKey(spriteName) == false) { Debug.LogErrorFormat("No sprite with name {0} in atlas {1}!", spriteName, atlasName); return(null); } return(_sprites[atlasName].Sprites[spriteName].GetSprite()); }
public static void OpenCurrentCompiledShader(Shader shader) { if (!HasCodeSnippets(shader)) { Debug.LogErrorFormat("{0} is precompiled shader.", shader.name); return; } OpenCompiledShader(shader, ShaderInspectorPlatformsPopup.currentMode, ShaderInspectorPlatformsPopup.currentPlatformMask, ShaderInspectorPlatformsPopup.currentVariantStripping == 0); }
public static EditorTaskInfo DoEditorTask( String title, TaskActions _taskList, bool breakIfException = false ) { if ( _taskList == null || _taskList.Count == 0 ) { return null; } title = title ?? "unknown editor task"; var taskInfo = new EditorTaskInfo( title ); EditorApplication.CallbackFunction tick = null; // we handle task item from the end of list _taskList.Reverse(); int totalTaskCount = _taskList.Count; taskInfo._breakIfException = breakIfException; taskInfo._totalTaskCount = totalTaskCount; if ( totalTaskCount > 0 ) { taskInfo._taskList = _taskList; EditorTaskInfo._allTasks.Add( taskInfo ); tick = () => { if ( _taskList.Count > 0 ) { var item = _taskList[ _taskList.Count - 1 ]; _taskList.RemoveAt( _taskList.Count - 1 ); taskInfo._curTaskCount = _taskList.Count; taskInfo._curTask = item.name; Debug.LogFormat( "DoEditorTask: {0}", item.name ); if ( EditorUtility.DisplayCancelableProgressBar( title, item.name, ( totalTaskCount - _taskList.Count ) / ( float )totalTaskCount ) ) { _taskList.RemoveAll( _e => _e.breakAble ); return; } try { if ( item.action != null ) { item.action(); } } catch ( Exception e ) { if ( taskInfo._breakIfException ) { _taskList.RemoveAll( _e => _e.breakAble ); } Debug.LogErrorFormat( "Process {0} failed: {1}", item.name, e.ToString() ); } } else { EditorApplication.update -= tick; taskInfo._isWorking = false; taskInfo._totalTaskCount = 0; taskInfo._curTask = String.Empty; EditorUtility.ClearProgressBar(); if ( taskInfo._curTaskCount == 0 ) { Debug.LogFormat( title + " done. total: {0}", totalTaskCount ); } else { Debug.LogFormat( title + " canceled. total: {0}, done:{1}, remain: {2}", totalTaskCount, ( totalTaskCount - taskInfo._curTaskCount ), taskInfo._curTaskCount ); } taskInfo._done = true; taskInfo._curTaskCount = 0; EditorTaskInfo._allTasks.Remove( taskInfo ); } }; EditorApplication.update += tick; } return taskInfo; }
public T GetStateOrLogError <T>() where T : Peds.States.BaseScriptState { var state = this.GetState <T> (); if (null == state) { Debug.LogErrorFormat("Failed to find state: {0}", typeof(T)); } return(state); }
/// <summary> /// 从字典中获取对象 /// </summary> /// <param name="key"></param> /// <returns></returns> public T GetObject(string key) { T value = default(T); if (!_dictionary.TryGetValue(key, out value)) { Debug.LogErrorFormat("error: {0}", key); } return(value); }