コード例 #1
0
        private static void CreateItemFromTemplate(string template, string fileExtension, CustomTemplateWizard wizard)
        {
            try
            {
                string path = Path.ChangeExtension(Path.Combine(CustomAssetHelper.GetSelectedObjectFolder(), wizard.ItemName), fileExtension);

                if (File.Exists(path))
                {
                    if (!EditorUtility.DisplayDialog("File exists already!", "Do you want to overwrite the file?", "Yes", "No"))
                    {
                        return;
                    }
                }

                using (var writer = new StreamWriter(path, false))
                {
                    writer.Write(ReplaceTemplateTokens(template,
                                                       new[] { "$ItemName", wizard.ItemName },
                                                       new[] { "$User", wizard.ProgrammerName },
                                                       new[] { "$Namespace", wizard.Namespace },
                                                       new[] { "$Year", DateTime.Now.Year.ToString(CultureInfo.InvariantCulture) },
                                                       new[] { "$DateTime", DateTime.Now.ToShortDateString() },
                                                       new[] { "$EditingItemName", FindEditingItemName(wizard.ItemName) }));
                }

                AssetDatabase.ImportAsset(path);
            }
            catch (Exception exception)
            {
                Debug.LogException(exception);
            }
        }
コード例 #2
0
        private void Commit()
        {
            Signature signature = GitManager.Signature;

            try
            {
                if (!GitExternalManager.TakeCommit(commitMessage))
                {
                    GitManager.Repository.Commit(commitMessage, signature, signature, new CommitOptions()
                    {
                        AllowEmptyCommit = settings.emptyCommit, AmendPreviousCommit = settings.amendCommit, PrettifyMessage = settings.prettify
                    });
                    GitHistoryWindow.GetWindow(true);
                }
                GitManager.Update();
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
            finally
            {
                GUI.FocusControl("");
                commitMessage = string.Empty;
            }
        }
コード例 #3
0
ファイル: Requests.cs プロジェクト: mayzhengxi/xasset
 internal override void Load()
 {
     if (!string.IsNullOrEmpty(assetBundleName))
     {
         bundle = Assets.LoadBundle(assetBundleName);
         if (bundle != null)
         {
             SceneManager.LoadScene(sceneName, loadSceneMode);
         }
     }
     else
     {
         try
         {
             SceneManager.LoadScene(sceneName, loadSceneMode);
             loadState = LoadState.LoadAsset;
         }
         catch (Exception e)
         {
             Debug.LogException(e);
             error     = e.ToString();
             loadState = LoadState.Loaded;
         }
     }
 }
コード例 #4
0
        static Log()
        {
            try {
                string dir = Application.dataPath;
                LogFilePath = Path.Combine(dir, LOG_FILE_NAME);
                if (File.Exists(LogFilePath))
                {
                    File.Delete(LogFilePath); // delete old file to avoid confusion.
                }

                var args  = Environment.GetCommandLineArgs();
                int index = Array.IndexOf(args, "-logFile");
                if (index >= 0)
                {
                    dir         = args[index + 1];
                    dir         = Path.GetDirectoryName(dir); // drop output_log.txt
                    LogFilePath = Path.Combine(dir, LOG_FILE_NAME);
                    if (File.Exists(LogFilePath))
                    {
                        File.Delete(LogFilePath);
                    }
                }
            }
            catch (Exception e) {
                Debug.LogException(e);
            }
        }
コード例 #5
0
    /// <summary>
    /// Process all the events we received through Notify() last frame.
    /// </summary>
    private void Update()
    {
        // Cache our number of events to prevent a potentially infinite loop if one event triggers another.
        int initialCount = kEventsFromLastFrame.Count;

        for (int i = 0; i < initialCount; ++i)
        {
            // This is the most exception-safe way to execute this.
            // It grabs all the delegates from each event and executes them one-by-one, catching exceptions from each.

            Action e         = kEventsFromLastFrame.Dequeue();
            var    delegates = e.GetInvocationList();
            foreach (Delegate d in delegates)
            {
                try
                {
                    d.Method.Invoke(e.Target, null);
                }
                catch (Exception except)
                {
                    Debug.LogException(except);
                }
            }
        }
    }
コード例 #6
0
ファイル: WebResources.cs プロジェクト: RobboVariwn/VarBot
        protected virtual void SendFile(int id, FileInfo file, bool forceDownload = false)
        {
            new Thread(() => {
                try {
                    if (!file.Exists)
                    {
                        SendError(id, "<h2>File not found</h2>", 404);
                        return;
                    }

                    FileStream fileStream = null;
                    try {
                        fileStream = file.OpenRead();
                    } catch (Exception ex) {
                        Debug.LogException(ex);
                        SendError(id, "<h2>File unavailable</h2>", 500);
                        return;
                    }

                    string mimeType;
                    var ext = file.Extension;
                    if (ext.Length > 0)
                    {
                        ext = ext.Substring(1).ToLowerInvariant();
                    }
                    if (!extensionMimeTypes.TryGetValue(ext, out mimeType))
                    {
                        mimeType = extensionMimeTypes["*"];
                    }
                    //Debug.Log("response type: " + mimeType + " extension " + file.Extension);

                    var pre = new ResponsePreamble {
                        headers    = new Dictionary <string, string>(),
                        length     = (int)file.Length,
                        mimeType   = mimeType,
                        statusCode = 200,
                    };

                    if (forceDownload)
                    {
                        pre.headers["Content-Disposition"] = "attachment; filename=\"" + file.Name.Replace("\"", "\\\"") + "\"";
                    }

                    SendPreamble(id, pre);

                    int readCount = -1;
                    byte[] buffer = new byte[Math.Min(pre.length, 32 * 1024)];
                    while (readCount != 0)
                    {
                        readCount = fileStream.Read(buffer, 0, buffer.Length);
                        SendData(id, buffer, readCount);
                    }
                    SendEnd(id);

                    fileStream.Close();
                } catch (Exception ex) {
                    Debug.LogException(ex);
                }
            }).Start();
        }
コード例 #7
0
ファイル: LogUtils.cs プロジェクト: incoboggart/Yamly
 public static void Verbose(Exception e)
 {
     if (IsVerbose)
     {
         UnityDebug.LogException(e);
     }
 }
コード例 #8
0
        static RiderScriptEditor()
        {
            try
            {
                var projectGeneration = new ProjectGeneration();
                var editor            = new RiderScriptEditor(new Discovery(), projectGeneration);
                CodeEditor.Register(editor);

                var path = GetEditorRealPath(CodeEditor.CurrentEditorInstallation);
                if (IsRiderInstallation(path))
                {
                    if (!FileSystemUtil.EditorPathExists(path)) // previously used rider was removed
                    {
                        var newEditor = editor.Installations.Last().Path;
                        CodeEditor.SetExternalScriptEditor(newEditor);
                        path = newEditor;
                    }

                    editor.CreateSolutionIfDoesntExist();
                    if (ShouldLoadEditorPlugin(path))
                    {
                        editor.m_Initiliazer.Initialize(path);
                    }

                    InitProjectFilesWatcher();
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
コード例 #9
0
        private void Update()
        {
            var w             = Stopwatch.StartNew();
            var actionsAmount = Actions.Count;

            while (Actions.Count != 0)
            {
                if (!Actions.TryDequeue(out Action a))
                {
                    continue;
                }

                try
                {
                    a?.Invoke();
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }
            w.Stop();
            if (w.ElapsedMilliseconds > 30)
            {
                Debug.LogError($"WARNING!!! Main thread invoker took {w.ElapsedMilliseconds} milliseconds" +
                               $" in main thread for {actionsAmount} action(s).");
            }
        }
コード例 #10
0
        public static IEnumerable ExecuteSeq <T>(this MonoBehaviour mb, GameObject target, EventAction <T> functor) where T : IEventSystemHandler
        {
            var internalHandlers = s_HandlerListPool.Get();

            GetEventList <T>(target, internalHandlers);
            //	if (s_InternalHandlers.Count > 0)
            //		Debug.Log("Executing " + typeof (T) + " on " + target);

            for (var i = 0; i < internalHandlers.Count; i++)
            {
                T arg;
                try
                {
                    arg = (T)internalHandlers[i];
                }
                catch (Exception e)
                {
                    var temp = internalHandlers[i];
                    Debug.LogException(new Exception(string.Format("Type {0} expected {1} received.", typeof(T).Name, temp.GetType().Name), e));
                    continue;
                }

                if (arg == null || functor == null)
                {
                    Debug.LogError("EzMsg: Signature Type Incompatible or Functor not assigned");
                    yield break;
                }
                yield return(mb.StartCoroutine(functor(arg).GetEnumerator()));
            }

            //        var handlerCount = internalHandlers.Count;
            //        s_HandlerListPool.Release(internalHandlers);
            //        return handlerCount > 0;
        }
コード例 #11
0
    public static SyntaxTreeNode_Rule ResolveNode(SyntaxTreeNode_Rule node)
    {
        if (node == null)
        {
            return(null);
        }

        while (node.Parent != null)
        {
            switch (node.RuleName)
            {
            //case "primaryExpression":
            case "primaryExpressionStart":
            case "primaryExpressionPart":
            case "objectCreationExpression":
            case "objectOrCollectionInitializer":
            case "typeOrGeneric":
            case "namespaceOrTypeName":
            case "typeName":
            case "nonArrayType":
            //case "attribute":
            case "accessIdentifier":
            case "brackets":
            case "argumentList":
            case "attributeArgumentList":
            case "argumentName":
            case "attributeMemberName":
            case "argument":
            case "attributeArgument":
            case "attributeArguments":
            case "arrayCreationExpression":
            case "implicitArrayCreationExpression":
            case "arrayInitializer":
            case "arrayInitializerList":
            case "qidStart":
            case "qidPart":
            case "memberInitializer":
            case "globalNamespace":
                node = node.Parent;
                continue;
            }
            break;
        }

        try
        {
            var result = SymbolDefinition.ResolveNode(node, null, null, 0);//numTypeArgs);
            if (result == null)
            {
                ResolveChildren(node);
            }
        }
        catch (Exception e)
        {
            Debug.LogException(e);
            return(null);
        }

        return(node);
    }
コード例 #12
0
    private static void GenerateLog(StringBuilder stringBuilder)
    {
        Dictionary <int, RelLoger>        newRelLogers = new Dictionary <int, RelLoger>(relLogers.Count);
        Dictionary <int, JSMgr.JS_CS_Rel> dic1         = JSMgr.GetDict1();

        foreach (var item in dic1)
        {
            try
            {
                RelLoger relLoger;
                if (relLogers.TryGetValue(item.Key, out relLoger) == false)
                {
                    relLoger = new RelLoger(item.Key, item.Value.csObj);
                }
                relLoger.AddRelSurvival(item.Value.csObj, generateCount);
                newRelLogers.Add(item.Key, relLoger);
                //只输出已经Destroy的
                if (relLoger.isUnityObj && relLoger.list[relLoger.list.Count - 1].isDestroy)
                {
                    stringBuilder.AppendLine(relLoger.ToString());
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
        relLogers = newRelLogers;
    }
コード例 #13
0
        /// <summary>
        /// click event that saves the blueprint
        /// </summary>
        public void SaveBlueprint()
        {
            MessageController messageController = GameController.Instance.messageController;

            if (BlueprintMenu.blueprintObject == null)
            {
                messageController.WarningMessage("Cannot save a creation that doesn't exist.\nLoad one first.", 3);
                return;
            }

            //string blueprintDataStr = JsonConvert.SerializeObject(BlueprintLoader.blueprintObject.ToBlueprintData());
            messageController.YesNoMessage("Are you sure you want to save your creation to this blueprint?",
                                           yesAction: () =>
            {
                try
                {
                    SelectedBlueprintButton.BlueprintContextReference.Blueprint = BlueprintMenu.blueprintObject.ToBlueprintData();
                    SelectedBlueprintButton.BlueprintContextReference.SaveBlueprint();
                    messageController.WarningMessage("Creation successfully saved!");
                }
                catch (Exception e)
                {
                    messageController.WarningMessage("Something went wrong while saving your creation to this blueprint!\nCheck the log for more information", 5);
                    Debug.LogException(e, this);
                }
            },
                                           noAction: () =>
            {
                messageController.WarningMessage("Creation not saved.", 2);
            });
        }
コード例 #14
0
	public Func<bool> Update(int fromLine, int toLineInclusive)
	{
	//	var t = new Stopwatch();
	//	t.Start();

		var lastLine = textBuffer.formatedLines.Length - 1;
		try
		{
			if (this.parseTree != null)
				ParseLines(fromLine, lastLine);
		}
		catch (Exception e)
		{
			Debug.LogException(e);
		}
		//if (toLineInclusive < textBuffer.lines.Count)
		//{
		//    progressiveParseLine = toLineInclusive + 1;
		//    return ProgressiveParser;
		//}
		//else
		{
			// TODO: Temporary solution, discarding all unused invalid parse tree nodes
			if (parseTree != null && parseTree.root != null)
				parseTree.root.CleanUp();
		}
		//ParseAll(assetPath);

	//	t.Stop();
	//	Debug.Log("Updated parser for lines " + (fromLine + 1) + "-" + (toLineInclusive + 1) + " in " + t.ElapsedMilliseconds + " ms");
		return null;
	}
コード例 #15
0
ファイル: GitManager.cs プロジェクト: bp-bling/UniGit
        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);
        }
コード例 #16
0
        void ReceivedUDPPacket(IAsyncResult result)
        {
            try
            {
                receivedBytes = client.EndReceive(result, ref ipEndPoint);
                var len = receivedBytes.Length;

                // we only use the buffer until the end, should wrap around
                if (bufferIndex + len > bufferSize)
                {
                    Debug.LogError("Buffer finished, should fix this..");
                    return;
                }

                Buffer.BlockCopy(receivedBytes, 0, dump, bufferIndex, len);
                bufferIndex += len;
                if (bufferIndex - bufferFrameStart >= imageSize)
                {
                    frameIndex.Enqueue(bufferFrameStart);
                    frameBufferCount++;
                    bufferFrameStart += imageSize;
                }
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
            client.BeginReceive(AC, obj);
        }
コード例 #17
0
        /// <summary>
        /// Writes the specified path to the projects git ignore file located at the root of the repository.
        /// </summary>
        /// <param name="ignoredPath"></param>
        public static void WritePathToGitIgnore(string ignoredPath)
        {
            if (string.IsNullOrEmpty(ignoredPath))
            {
                Debug.LogError("You cannot pass null or empty parameter.");
                return;
            }

            var rootDir = RepositoryRootDir;

            ignoredPath = ignoredPath.Replace($"{rootDir.ToBackSlashes()}/", string.Empty);
            var directory = ignoredPath.Replace(Path.GetFileName(ignoredPath), Path.GetFileNameWithoutExtension(ignoredPath));

            directory = directory.Substring(0, directory.LastIndexOf("/", StringComparison.Ordinal));
            var gitIgnoreFilePath = $"{rootDir}\\.gitignore";

            if (File.Exists(gitIgnoreFilePath))
            {
                bool addPath = true;

                try
                {
                    // Create a new StreamReader, tell it which file to read and what encoding the file was saved as
                    // Immediately clean up the reader after this block of code is done.
                    using (var reader = new StreamReader(gitIgnoreFilePath))
                    {
                        // While there's lines left in the text file, do this:
                        string line;
                        do
                        {
                            line = reader.ReadLine();

                            if (!string.IsNullOrEmpty(line) &&
                                (line.Equals(ignoredPath) || line.Contains(directory)))
                            {
                                // Don't add the line if it already exists.
                                addPath = false;
                            }
                        }while (line != null);

                        // Done reading, close the reader and return true to broadcast success.
                        reader.Close();
                    }
                }
                // If anything broke in the try block, we throw an exception with information on what didn't work.
                catch (Exception e)
                {
                    Debug.LogException(e);
                }

                if (addPath)
                {
                    File.AppendAllText(gitIgnoreFilePath, $"{ignoredPath}{Environment.NewLine}", Encoding.UTF8);
                }
            }
            else
            {
                File.WriteAllText(gitIgnoreFilePath, $"{ignoredPath}{Environment.NewLine}", Encoding.UTF8);
            }
        }
コード例 #18
0
    /// <summary>
    /// 停止监听ADB
    /// </summary>
    void StopADB()
    {
        if (mADBProcess == null)
        {
            return;
        }

        try
        {
            if (mADBProcess != null && !mADBProcess.HasExited)
            {
                mADBProcess.CancelOutputRead();
                mADBProcess.CancelErrorRead();
                mADBProcess.Kill();
            }

            EditorApplication.update -= ParseADBMsg;
        }
        catch (Exception ex)
        {
            Debug.LogException(ex);
        }
        finally
        {
            mADBProcess = null;
        }
    }
コード例 #19
0
ファイル: Model.cs プロジェクト: mikeage/open-brush
        GameObject LoadGltf(List <string> warnings)
        {
            // This is intended to be identical to using GltfModelBuilder, except synchronous.
            GameObject go;
            bool       fromPoly      = (m_Location.GetLocationType() == Location.Type.PolyAssetId);
            string     localPath     = m_Location.AbsolutePath;
            string     assetLocation = Path.GetDirectoryName(localPath);
            // Synchronous, so don't use slow image loading
            var loader = new TiltBrushUriLoader(localPath, assetLocation, loadImages: false);

            try
            {
                ImportGltf.GltfImportResult result = ImportGltf.Import(
                    localPath, loader,
                    new ImportMaterialCollector(assetLocation, uniqueSeed: localPath),
                    fromPoly ? kPolyGltfImportOptions : kGltfImportOptions);
                go = result.root;
                m_ImportMaterialCollector = (ImportMaterialCollector)result.materialCollector;
            }
            catch (Exception ex)
            {
                m_LoadError   = new LoadError("Invalid data", ex.Message);
                go            = null;
                m_AllowExport = false;
                Debug.LogException(ex);
            }

            m_AllowExport = (go != null);
            return(go);
        }
コード例 #20
0
 private static void OnUpdate()
 {
     lock (new object())
     {
         try
         {
             if (_queue == null || _queue.Count <= 0)
             {
                 return;
             }
             _queue.ForEach(action =>
             {
                 if (action != null)
                 {
                     action();
                 }
             });
             _queue.Clear();
         }
         catch (Exception e)
         {
             Debug.LogException(e);
             if (_queue != null)
             {
                 _queue.Clear();
             }
         }
     }
 }
コード例 #21
0
        internal bool Update()
        {
            if (checkRequires)
            {
                UpdateRequires();
            }
            if (!isDone)
            {
                return(true);
            }
            if (completed == null)
            {
                return(false);
            }
            try
            {
                completed.Invoke(this);
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }

            completed = null;
            return(false);
        }
コード例 #22
0
        private static void LogToFile(string msg)
        {
            if (!_hasAttemptedOpen)
            {
                var logFilePath = PathUtility.GetLogFilePath();

                try
                {
                    _fileStream = File.Open(logFilePath, FileMode.Append, FileAccess.Write, FileShare.Read);
                    _logWriter  = new StreamWriter(_fileStream, Encoding.UTF8);
                }
                catch (Exception e)
                {
                    Debug.LogError("Error opening TypeSafe log file at " + logFilePath);
                    Debug.LogException(e);
                }

                _hasAttemptedOpen = true;
            }

            if (_logWriter == null)
            {
                return;
            }

            _logWriter.Write(DateTime.Now.ToString("s"));
            _logWriter.Write("\t");
            _logWriter.WriteLine(msg);

            _logWriter.Flush();
        }
コード例 #23
0
        public static Texture2D ConvertToTexture(byte[] bytes, string name)
        {
            try {
                var texture = new Texture2D(0, 0, TextureFormat.ARGB32, false, true)
                {
                    name      = name,
                    hideFlags = HideFlags.HideAndDontSave
                };

                //Texture2D.LoadImage changed to an extension method in Unity 2017
                //Compiling it with the old method will make the module stop working on 2017
                //Compiling it with the extension method will make the module stop working with older versions
                var imageConversionClass = typeof(Texture2D).Assembly.GetType("UnityEngine.ImageConversion", false);

                if (imageConversionClass == null)
                {
                    var loadMethod = typeof(Texture2D).GetMethod("LoadImage", new Type[] { typeof(byte[]) });
                    loadMethod.Invoke(texture, new object[] { bytes });
                }
                else
                {
                    var loadMethod = imageConversionClass.GetMethod("LoadImage", new Type[] { typeof(Texture2D), typeof(byte[]) });
                    loadMethod.Invoke(null, new object[] { texture, bytes });
                }

                return(texture);
            }
            catch (Exception e) {
                Debug.LogException(e);
                return(null);
            }
        }
コード例 #24
0
 public static void LogException(this System.Exception exception)
 {
     if (debugable)
     {
         UnityDebug.LogException(exception);
     }
 }
コード例 #25
0
 private static void ShowWarningOnUnexpectedScriptEditor(string path)
 {
     // Show warning, when Unity was started from Rider, but external editor is different https://github.com/JetBrains/resharper-unity/issues/1127
     try
     {
         var args = Environment.GetCommandLineArgs();
         var commandlineParser = new CommandLineParser(args);
         if (commandlineParser.Options.ContainsKey("-riderPath"))
         {
             var originRiderPath = commandlineParser.Options["-riderPath"];
             var originRealPath  = GetEditorRealPath(originRiderPath);
             var originVersion   = RiderPathLocator.GetBuildNumber(originRealPath);
             var version         = RiderPathLocator.GetBuildNumber(path);
             if (originVersion != null && originVersion != version)
             {
                 Debug.LogWarning("Unity was started by a version of Rider that is not the current default external editor. Advanced integration features cannot be enabled.");
                 Debug.Log($"Unity was started by Rider {originVersion}, but external editor is set to: {path}");
             }
         }
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
 }
コード例 #26
0
 static String _Md5Asset( String filePath,
     MD5CryptoServiceProvider md5Service,
     byte[] buffer, StringBuilder sb ) {
     try {
         int bytesRead = 0;
         using ( var file = FileOpenRead( filePath ) ) {
             while ( ( bytesRead = file.Read( buffer, 0, buffer.Length ) ) > 0 ) {
                 md5Service.TransformBlock( buffer, 0, bytesRead, buffer, 0 );
             }
         }
         var meta = filePath + ".meta";
         if ( File.Exists( meta ) ) {
             var lines = ReadFileLines( meta );
             var idx = lines.FindIndex( "timeCreated:", ( name, tag ) => name.StartsWith( tag ) );
             if ( idx != -1 ) {
                 var _lines = lines.ToList();
                 _lines.RemoveAt( idx );
                 lines = _lines.ToArray();
             }
             var content = String.Join( "\n", lines );
             var bytes = Encoding.ASCII.GetBytes( content );
             md5Service.TransformBlock( bytes, 0, bytes.Length, bytes, 0 );
         }
         md5Service.TransformFinalBlock( buffer, 0, 0 );
         var hashBytes = md5Service.Hash;
         for ( int i = 0; i < hashBytes.Length; i++ ) {
             sb.Append( hashBytes[ i ].ToString( "x2" ) );
         }
         return sb.ToString();
     } catch ( Exception e ) {
         Debug.LogException( e );
     }
     return String.Empty;
 }
コード例 #27
0
        private static object[] NotifyLocalListeners(string eventType, object[] data, bool notifyWildcard)
        {
            List <Func <string, object[], object> > handlers = null;
            var result = new object[0];

            if (s_Events.TryGetValue(eventType, out handlers))
            {
                try
                {
                    result = handlers.Select(handler => handler(eventType, data)).ToArray();
                }
                catch (Exception e)
                {
                    result = new object[] { e };
                    Console.WriteLine(e);
                }
            }

            if (notifyWildcard && s_Events.TryGetValue("*", out handlers))
            {
                try
                {
                    foreach (var handler in handlers)
                    {
                        handler(eventType, data);
                    }
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }
            }

            return(result);
        }
コード例 #28
0
ファイル: Requests.cs プロジェクト: Sarofc/com.saro.xasset
 internal override void Load()
 {
     if (!string.IsNullOrEmpty(m_AssetBundleName))
     {
         m_Bundle = XAsset.Get().LoadBundle(m_AssetBundleName);
         if (m_Bundle != null)
         {
             SceneManager.LoadScene(m_SceneName, m_LoadSceneMode);
         }
     }
     else
     {
         try
         {
             SceneManager.LoadScene(m_SceneName, m_LoadSceneMode);
             m_LoadState = ELoadState.LoadAsset;
         }
         catch (Exception e)
         {
             Debug.LogException(e);
             Error       = e.ToString();
             m_LoadState = ELoadState.Loaded;
         }
     }
 }
コード例 #29
0
        /// Update an existing file. Make sure mimetype and existing id are specified. file paramater will
        /// be altered during this function.
        public async Task UpdateFileAsync(DriveData.File file, Stream dataStream,
                                          CancellationToken token, IProgress <long> progress = null)
        {
            Debug.Assert(!string.IsNullOrEmpty(file.Id));
            Debug.Assert(!string.IsNullOrEmpty(file.MimeType));
            Debug.Assert(dataStream.CanSeek);
            string id = file.Id;

            file.Id      = null;
            file.Parents = null;
            var uploader = m_DriveService.Files.Update(file, id, dataStream, file.MimeType);

            if (progress != null)
            {
                uploader.ProgressChanged += (p) => progress.Report(p.BytesSent);
            }
            long position = dataStream.Position;
            var  result   = await Retry(() =>
            {
                dataStream.Seek(position, SeekOrigin.Begin);
                return(uploader.UploadAsync(token));
            });

            if (result.Status != UploadStatus.Completed && !token.IsCancellationRequested)
            {
                Debug.LogException(new DriveSync.DataTransferError("Google Drive file update failed.",
                                                                   result.Exception));
            }
            await RefreshFreeSpaceAsync(token);
        }
コード例 #30
0
        public static void EpicDebugLog(LogMessage message)
        {
            switch (message.Level)
            {
            case LogLevel.Info:
                Debug.Log($"<color=green> Epic Manager: Category - {message.Category} Message - {message.Message} </color>");
                break;

            case LogLevel.Error:
                Debug.LogError($"<color=orange> Epic Manager: Category - {message.Category} Message - {message.Message} </color>");
                break;

            case LogLevel.Warning:
                Debug.LogWarning($"<color=yellow> Epic Manager: Category - {message.Category} Message - {message.Message} </color>");
                break;

            case LogLevel.Fatal:
                Debug.LogException(
                    new Exception($"<color=red> Epic Manager: Category - {message.Category} Message - {message.Message} </color>"));
                break;

            default:
                Debug.Log(
                    $"<color=purple> Epic Manager: Unknown log processing. Category - {message.Category} Message - {message.Message} </color>");
                break;
            }
        }