private static bool InjectProfilerSampling(string assemblyPath, string[] assemblyNames) { if (string.IsNullOrEmpty(assemblyPath)) { Debug.LogWarning("Assembly path is invalid."); return(false); } if (assemblyNames == null || assemblyNames.Length <= 0) { Debug.LogWarning("Assembly names are invalid."); return(false); } MethodDefinition beginSampleMethod = null; MethodDefinition endSampleMethod = null; if (!PrepareProfilerSamplingInjectionMethods(assemblyPath, out beginSampleMethod, out endSampleMethod)) { Debug.LogWarning("Prepare profiler sampling injection methods failure."); return(false); } try { Injection injection = new Injection(beginSampleMethod.Resolve(), endSampleMethod.Resolve()); injection.ProgressChanged += delegate(string assemblyName, float progress) { EditorUtility.DisplayProgressBar("Profiler Sampling Injection", string.Format("Injecting assembly {0}, {1} completed...", assemblyName, progress.ToString("P1")), progress); }; foreach (string assemblyName in assemblyNames) { injection.RunInject(assemblyPath, assemblyName); } } catch (Exception exception) { Debug.LogWarning(exception.ToString()); } finally { EditorUtility.ClearProgressBar(); } return(true); }