123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732 |
- /*
- http://www.cgsoso.com/forum-211-1.html
- CG搜搜 Unity3d 每日Unity3d插件免费更新 更有VIP资源!
- CGSOSO 主打游戏开发,影视设计等CG资源素材。
- 插件如若商用,请务必官网购买!
- daily assets update for try.
- U should buy the asset from home store if u use it in your project!
- */
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Reflection;
- using UnityEditor;
- using UnityEngine;
- using UnityEngine.UI;
- namespace Paroxe.PdfRenderer.Internal.Viewer
- {
- [CustomEditor(typeof (PDFViewer), true)]
- public class PDFViewerEditor : Editor
- {
- GUIStyle m_Background1;
- GUIStyle m_Background2;
- GUIStyle m_Background3;
- Texture2D m_Logo;
- PDFViewer pdfViewer = null;
- PRParoxeBanner m_ParoxeBanner;
- public override void OnInspectorGUI()
- {
- if (pdfViewer != null)
- {
- Undo.RecordObject(pdfViewer, "PDFViewer");
- if (pdfViewer.m_Internal != null)
- Undo.RecordObject(pdfViewer.m_Internal, "PDFViewer_Internal");
- }
- if (m_Logo != null)
- {
- Rect rect = GUILayoutUtility.GetRect(m_Logo.width, m_Logo.height);
- GUI.DrawTexture(rect, m_Logo, ScaleMode.ScaleToFit);
- }
- if (pdfViewer.m_Internal == null && IsPrefabGhost(pdfViewer.transform))
- {
- return;
- }
- pdfViewer.m_Internal.m_BannerIsOpened = m_ParoxeBanner.DoOnGUI(pdfViewer.m_Internal.m_BannerIsOpened);
- if (pdfViewer.m_Internal == null || pdfViewer.m_Internal.m_Version != PDFLibrary.CurrentVersion)
- {
- GUILayout.BeginVertical("Box");
- GUILayout.Label("UPDATE TO VERSION " + PDFLibrary.CurrentVersion, EditorStyles.boldLabel);
- GUILayout.Space(10.0f);
- if (pdfViewer.m_Internal != null)
- {
- EditorGUILayout.HelpBox(
- "\n\rThe update process won't overwrite UI customizations made by developpers as long as theses changes are minors. Please make a backup before updating your PDFViewer prefab.\n\r",
- MessageType.Info);
- string[] newFeatures = PDFViewerBuilder.GetNewFeatures(pdfViewer.gameObject);
- foreach (string feature in newFeatures)
- {
- GUILayout.Label(feature, EditorStyles.boldLabel);
- }
- GUILayout.Space(10.0f);
- }
- Color oc = GUI.color;
- GUI.color = Color.green;
- if (GUILayout.Button("\n\rUPDATE\n\r"))
- {
- if (pdfViewer.m_Internal == null)
- {
- string filePath = pdfViewer.FilePath;
- string password = pdfViewer.Password;
- PDFViewerBuilder.BuildPDFViewerWithin(pdfViewer.gameObject, null);
- pdfViewer.FileSource = PDFViewer.FileSourceType.FilePath;
- pdfViewer.FilePath = filePath;
- pdfViewer.Password = password;
- }
- else
- {
- PDFViewerBuilder.UpdateToLatestVersion(pdfViewer.gameObject);
- }
- }
- GUI.color = oc;
- GUILayout.Space(10.0f);
- GUILayout.EndVertical();
- if (pdfViewer.m_Internal == null)
- {
- return;
- }
- }
- GUILayout.BeginVertical("Box");
- pdfViewer.m_Internal.m_UiShowLoadOptions = PRHelper.GroupHeader("Load Options", pdfViewer.m_Internal.m_UiShowLoadOptions);
- if (pdfViewer.m_Internal.m_UiShowLoadOptions)
- {
- pdfViewer.FileSource = (PDFViewer.FileSourceType)EditorGUILayout.EnumPopup("Source", pdfViewer.FileSource);
- if (pdfViewer.FileSource == PDFViewer.FileSourceType.Resources
- || pdfViewer.FileSource == PDFViewer.FileSourceType.StreamingAssets)
- {
- EditorGUI.indentLevel++;
- pdfViewer.Folder = EditorGUILayout.TextField("Folder", pdfViewer.Folder);
- pdfViewer.FileName = EditorGUILayout.TextField("File Name", pdfViewer.FileName);
- if (pdfViewer.FileSource == PDFViewer.FileSourceType.Resources)
- {
- if (File.Exists(Application.dataPath + "/Resources/" + pdfViewer.GetFileLocation())
- &&
- !File.Exists(Application.dataPath + "/Resources/" +
- pdfViewer.GetFileLocation().Replace(".bytes", "") + ".bytes"))
- {
- EditorGUILayout.HelpBox(
- "PDF file in resources folder need to have .bytes extension to allow PDFViewer to access it correctly. \n\r For example => pdf_sample.pdf.bytes",
- MessageType.Warning);
- GUILayout.Space(10.0f);
- }
- }
- EditorGUI.indentLevel--;
- }
- else if (pdfViewer.FileSource == PDFViewer.FileSourceType.Web)
- {
- EditorGUI.indentLevel++;
- pdfViewer.FileURL = EditorGUILayout.TextField("Url", pdfViewer.FileURL);
- EditorGUI.indentLevel--;
- }
- else if (pdfViewer.FileSource == PDFViewer.FileSourceType.FilePath)
- {
- EditorGUI.indentLevel++;
- pdfViewer.FilePath = EditorGUILayout.TextField("File Path", pdfViewer.FilePath);
- #if ((UNITY_4_6 || UNITY_4_7) && UNITY_WINRT)
- EditorGUILayout.HelpBox(
- "File Path for Windows Phone 8.1 is only supported on Unity 5+", MessageType.Warning);
- #endif
- EditorGUI.indentLevel--;
- }
- if (pdfViewer.FileSource != PDFViewer.FileSourceType.Bytes
- && pdfViewer.FileSource != PDFViewer.FileSourceType.None)
- {
- #if UNITY_IOS
- if (pdfViewer.FileSource == PDFViewer.FileSourceType.Web)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PrefixLabel(" ");
- EditorGUILayout.HelpBox(
- "You may need to add NSAppTransportSecurity entry in info.plist of the XCode project to allow PDFViewer to download pdf from web:\n\r\n\r" +
- "<key>NSAppTransportSecurity</key>\n\r" +
- " <dict>\n\r" +
- " <key>NSAllowsArbitraryLoads</key>\n\r" +
- " <true/>\n\r" +
- "</dict>", MessageType.Info);
- EditorGUILayout.EndHorizontal();
- GUILayout.Space(10.0f);
- }
- #endif
- if (pdfViewer.FileSource == PDFViewer.FileSourceType.StreamingAssets
- || pdfViewer.FileSource == PDFViewer.FileSourceType.Resources
- || pdfViewer.FileSource == PDFViewer.FileSourceType.FilePath)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PrefixLabel(" ");
- GUI.color = Color.green;
- if (GUILayout.Button("Browse"))
- {
- string baseDirectory = Application.streamingAssetsPath;
- if (pdfViewer.FileSource == PDFViewer.FileSourceType.Resources)
- baseDirectory = "Assets/Resources";
- else if (pdfViewer.FileSource == PDFViewer.FileSourceType.FilePath)
- {
- string projectRoot = System.IO.Path.GetFullPath(System.IO.Path.Combine(Application.dataPath, ".."));
- projectRoot = projectRoot.Replace('\\', '/');
- baseDirectory = projectRoot;
- }
- if (!Directory.Exists(baseDirectory))
- {
- Directory.CreateDirectory(baseDirectory);
- AssetDatabase.Refresh();
- }
- string folder = "";
- string fileName = "";
- string filePath = "";
- bool useStreamingAssets = false;
- bool useResources = false;
- bool useFilePath = false;
- if (Browse(baseDirectory, ref fileName, ref folder, ref filePath, ref useStreamingAssets, ref useResources, ref useFilePath))
- {
- if (useStreamingAssets)
- pdfViewer.FileSource = PDFViewer.FileSourceType.StreamingAssets;
- else if (useResources)
- pdfViewer.FileSource = PDFViewer.FileSourceType.Resources;
- else if (useFilePath)
- pdfViewer.FileSource = PDFViewer.FileSourceType.FilePath;
- if (pdfViewer.FileSource != PDFViewer.FileSourceType.FilePath)
- {
- pdfViewer.Folder = folder;
- pdfViewer.FileName = fileName;
- }
- else
- {
- pdfViewer.FilePath = filePath;
- }
- }
- }
- GUI.color = Color.white;
- EditorGUILayout.EndHorizontal();
- }
- #if UNITY_EDITOR_WIN
- if (pdfViewer.FileSource != PDFViewer.FileSourceType.Asset && pdfViewer.FileSource != PDFViewer.FileSourceType.DocumentObject)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PrefixLabel(" ");
- GUI.color = Color.cyan;
- if (GUILayout.Button("Reveal File"))
- {
- string filePath = "";
- if (pdfViewer.FileSource == PDFViewer.FileSourceType.Resources)
- {
- filePath = Application.dataPath + "/Resources/" + pdfViewer.GetFileLocation();
- }
- else
- {
- filePath = pdfViewer.GetFileLocation();
- }
- if (pdfViewer.FileSource != PDFViewer.FileSourceType.Web)
- {
- if (!File.Exists(filePath))
- {
- if (pdfViewer.FileSource == PDFViewer.FileSourceType.Resources &&
- File.Exists(filePath + ".bytes"))
- {
- ShowInExplorer(filePath + ".bytes");
- }
- else
- {
- EditorUtility.DisplayDialog("Error",
- "The file path is badly formed, contains invalid characters or doesn't exists:\r\n\r\n" +
- filePath, "Ok");
- }
- }
- else
- {
- ShowInExplorer(filePath);
- }
- }
- else
- {
- try
- {
- System.Diagnostics.Process.Start(filePath);
- }
- catch
- {
- EditorUtility.DisplayDialog("Error",
- "The URL is badly formed or contains invalid characters:\r\n\r\n" + filePath, "Ok");
- }
- }
- }
- GUI.color = Color.white;
- EditorGUILayout.EndHorizontal();
- }
- #endif
- }
- if (pdfViewer.FileSource == PDFViewer.FileSourceType.Bytes)
- {
- EditorGUI.indentLevel++;
- serializedObject.Update();
- GameObject oldObject = pdfViewer.BytesSupplierObject;
- var bytesSupplierObject = serializedObject.FindProperty("m_BytesSupplierObject");
- EditorGUILayout.PropertyField(bytesSupplierObject, new GUIContent("Supplier Object"));
- serializedObject.ApplyModifiedProperties();
- int selectedIndex = 0;
- if (pdfViewer.BytesSupplierObject != null)
- {
- try
- {
- List<BytesSupplierInfo> possibleSuppliers = new List<BytesSupplierInfo>();
- possibleSuppliers.Add(new BytesSupplierInfo(null, null, ""));
- Component[] components = pdfViewer.BytesSupplierObject.GetComponents(typeof(Component));
- foreach (Component component in components)
- {
- Type type = component.GetType();
- MethodInfo[] methods = type.GetMethods();
- if (methods.Length == 0)
- {
- continue;
- }
- foreach (MethodInfo method in methods)
- {
- if ((method.GetParameters() == null || method.GetParameters().Length == 0)
- && method.ReturnType == typeof(byte[]))
- {
- possibleSuppliers.Add(new BytesSupplierInfo(pdfViewer.BytesSupplierObject, component,
- method.Name));
- if (oldObject == pdfViewer.BytesSupplierObject
- && method.Name == pdfViewer.BytesSupplierFunctionName
- && component == pdfViewer.BytesSupplierComponent)
- {
- selectedIndex = possibleSuppliers.Count - 1;
- }
- }
- }
- }
- string[] supplierTitles = new string[possibleSuppliers.Count];
- for (int i = 0; i < supplierTitles.Length; ++i)
- {
- if (i == 0)
- {
- supplierTitles[0] = "No Function";
- continue;
- }
- supplierTitles[i] = possibleSuppliers[i].m_Behaviour.name + "." +
- possibleSuppliers[i].m_MethodName;
- }
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PrefixLabel("Supplier Function");
- var choiceIndex = EditorGUILayout.Popup(selectedIndex, supplierTitles);
- if (choiceIndex == 0)
- {
- pdfViewer.BytesSupplierComponent = null;
- pdfViewer.BytesSupplierFunctionName = "";
- }
- else
- {
- pdfViewer.BytesSupplierComponent = possibleSuppliers[choiceIndex].m_Behaviour;
- pdfViewer.BytesSupplierFunctionName = possibleSuppliers[choiceIndex].m_MethodName;
- }
- EditorGUILayout.EndHorizontal();
- }
- catch (Exception)
- {
- pdfViewer.BytesSupplierComponent = null;
- pdfViewer.BytesSupplierFunctionName = "";
- }
- }
- #if ((UNITY_4_6 || UNITY_4_7) && UNITY_WINRT)
- EditorGUILayout.HelpBox(
- "Bytes source for Windows Phone 8.1 is only supported on Unity 5+", MessageType.Warning);
- #endif
- EditorGUI.indentLevel--;
- }
- if (pdfViewer.FileSource == PDFViewer.FileSourceType.Asset)
- {
- pdfViewer.PDFAsset =
- (PDFAsset)EditorGUILayout.ObjectField("PDF Asset", pdfViewer.PDFAsset, typeof(PDFAsset), true);
- }
- //if (pdfViewer.FileSource != PDFViewer.FileSourceType.None)
- {
- pdfViewer.LoadOnEnable = EditorGUILayout.Toggle("Load On Enable", pdfViewer.LoadOnEnable);
- pdfViewer.UnloadOnDisable = EditorGUILayout.Toggle("Unload On Disable", pdfViewer.UnloadOnDisable);
- }
- if (pdfViewer.FileSource == PDFViewer.FileSourceType.Asset)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PrefixLabel("");
- EditorGUILayout.HelpBox(
- "To convert pdf file to .asset right click on pdf and select \"PDF Renderer\\Convert to .asset\"",
- MessageType.Info);
- EditorGUILayout.EndHorizontal();
- GUILayout.Space(10.0f);
- }
- GUILayout.Space(10.0f);
- }
- GUILayout.EndVertical();
- GUILayout.BeginVertical("Box");
- pdfViewer.m_Internal.m_UiShowPasswordOptions = PRHelper.GroupHeader("Password Options", pdfViewer.m_Internal.m_UiShowPasswordOptions);
- if (pdfViewer.m_Internal.m_UiShowPasswordOptions)
- {
- EditorGUI.indentLevel++;
- pdfViewer.Password = EditorGUILayout.PasswordField("Password", pdfViewer.Password);
- EditorGUI.indentLevel--;
- GUILayout.Space(10.0f);
- }
- GUILayout.EndVertical();
- GUILayout.BeginVertical("Box");
- pdfViewer.m_Internal.m_UiShowViewerSettings = PRHelper.GroupHeader("Viewer Settings", pdfViewer.m_Internal.m_UiShowViewerSettings);
- if (pdfViewer.m_Internal.m_UiShowViewerSettings)
- {
- pdfViewer.PageFitting = (PDFViewer.PageFittingType)EditorGUILayout.EnumPopup("Page Fitting", pdfViewer.PageFitting);
- if (pdfViewer.PageFitting == PDFViewer.PageFittingType.Zoom || Application.isPlaying)
- {
- EditorGUI.indentLevel++;
- pdfViewer.ZoomFactor = EditorGUILayout.FloatField("Zoom", pdfViewer.ZoomFactor,
- GUILayout.ExpandWidth(false));
- EditorGUI.indentLevel--;
- }
- pdfViewer.VerticalMarginBetweenPages = EditorGUILayout.FloatField("Page Margins (px)",
- pdfViewer.VerticalMarginBetweenPages, GUILayout.ExpandWidth(false));
- pdfViewer.MinZoomFactor = EditorGUILayout.FloatField("Minimum Zoom", pdfViewer.MinZoomFactor,
- GUILayout.ExpandWidth(false));
- pdfViewer.MaxZoomFactor = EditorGUILayout.FloatField("Maximum Zoom", pdfViewer.MaxZoomFactor,
- GUILayout.ExpandWidth(false));
- pdfViewer.ZoomStep = EditorGUILayout.FloatField("Zoom Step", pdfViewer.ZoomStep,
- GUILayout.ExpandWidth(false));
- pdfViewer.ScrollSensitivity = EditorGUILayout.FloatField("Scroll Sensitivity (px)",
- pdfViewer.ScrollSensitivity, GUILayout.ExpandWidth(false));
- pdfViewer.ShowTopBar = EditorGUILayout.Toggle("Show Top Bar", pdfViewer.ShowTopBar);
- pdfViewer.ShowVerticalScrollBar = EditorGUILayout.Toggle("Show VScrollBar", pdfViewer.ShowVerticalScrollBar);
- pdfViewer.ShowHorizontalScrollBar = EditorGUILayout.Toggle("Show HScrollBar",
- pdfViewer.ShowHorizontalScrollBar);
- if (pdfViewer.m_Internal.m_LeftPanel != null)
- {
- pdfViewer.ShowBookmarksViewer = EditorGUILayout.Toggle("Show Bookmarks Viewer", pdfViewer.ShowBookmarksViewer);
- pdfViewer.ShowThumbnailsViewer = EditorGUILayout.Toggle("Show Thumbnails Viewer", pdfViewer.ShowThumbnailsViewer);
- }
- pdfViewer.AllowOpenURL = EditorGUILayout.Toggle("Allow Open URL", pdfViewer.AllowOpenURL);
- Color oldColor = pdfViewer.BackgroundColor;
- pdfViewer.BackgroundColor = EditorGUILayout.ColorField("Viewer BG Color", pdfViewer.BackgroundColor);
- if (oldColor != pdfViewer.BackgroundColor)
- {
- EditorUtility.SetDirty(pdfViewer.m_Internal.m_Viewport.GetComponent<Image>());
- }
- GUILayout.Space(10.0f);
- }
- GUILayout.EndVertical();
- if (pdfViewer.m_Internal.m_SearchPanel != null)
- {
- GUILayout.BeginVertical("Box");
- pdfViewer.m_Internal.m_UiShowSearchSettings = PRHelper.GroupHeader("Search Settings", pdfViewer.m_Internal.m_UiShowSearchSettings);
- if (pdfViewer.m_Internal.m_UiShowSearchSettings)
- {
- pdfViewer.SearchResultColor = EditorGUILayout.ColorField("Result Color", pdfViewer.SearchResultColor);
- pdfViewer.SearchResultPadding = EditorGUILayout.Vector2Field("Result Padding",
- pdfViewer.SearchResultPadding);
- pdfViewer.SearchTimeBudgetPerFrame = EditorGUILayout.Slider("Time (% per frame)",
- pdfViewer.SearchTimeBudgetPerFrame, 0.0f, 1.0f);
- GUILayout.Space(10.0f);
- }
- GUILayout.EndVertical();
- }
- GUILayout.BeginVertical("Box");
- pdfViewer.m_Internal.m_UiShowOtherSettings = PRHelper.GroupHeader("Other Settings", pdfViewer.m_Internal.m_UiShowOtherSettings);
- if (pdfViewer.m_Internal.m_UiShowOtherSettings)
- {
- pdfViewer.ParagraphZoomingEnable = EditorGUILayout.Toggle("Paragraph Zooming", pdfViewer.ParagraphZoomingEnable, GUILayout.ExpandWidth(false));
- if (pdfViewer.ParagraphZoomingEnable)
- {
- pdfViewer.ParagraphZoomFactor = EditorGUILayout.FloatField(" Zoom Factor", pdfViewer.ParagraphZoomFactor, GUILayout.ExpandWidth(false));
- pdfViewer.ParagraphDetectionThreshold = EditorGUILayout.FloatField(" Detection Threshold (px)", pdfViewer.ParagraphDetectionThreshold, GUILayout.ExpandWidth(false));
- }
- pdfViewer.PageTileTexture = (Texture2D)EditorGUILayout.ObjectField("Page Tile Texture", pdfViewer.PageTileTexture, typeof(Texture2D), true);
- pdfViewer.PageColor = EditorGUILayout.ColorField("Page Color", pdfViewer.PageColor);
- GUILayout.Space(10.0f);
- }
- GUILayout.EndVertical();
- GUILayout.BeginVertical("Box");
- pdfViewer.m_Internal.m_UiShowRenderSettings = PRHelper.GroupHeader("Render Settings", pdfViewer.m_Internal.m_UiShowRenderSettings);
- if (pdfViewer.m_Internal.m_UiShowRenderSettings)
- {
- pdfViewer.MaxZoomFactorTextureQuality = EditorGUILayout.FloatField("Maximum Quality",
- pdfViewer.MaxZoomFactorTextureQuality, GUILayout.ExpandWidth(false));
- pdfViewer.RenderAnnotations = EditorGUILayout.Toggle("Render Annotations", pdfViewer.RenderAnnotations,
- GUILayout.ExpandWidth(false));
- pdfViewer.RenderGrayscale = EditorGUILayout.Toggle("Render Grayscale", pdfViewer.RenderGrayscale,
- GUILayout.ExpandWidth(false));
- GUILayout.Space(10.0f);
- }
- GUILayout.EndVertical();
- GUILayout.BeginVertical("Box");
- pdfViewer.m_Internal.m_UiShowDebugSettings = PRHelper.GroupHeader("Debug Settings", pdfViewer.m_Internal.m_UiShowDebugSettings);
- if (pdfViewer.m_Internal.m_UiShowDebugSettings)
- {
- pdfViewer.m_Internal.m_DrawDefaultInspector = EditorGUILayout.Toggle("Default Inspector", pdfViewer.m_Internal.m_DrawDefaultInspector);
- if (pdfViewer.m_Internal.m_DrawDefaultInspector)
- {
- GUILayout.Space(10.0f);
- DrawDefaultInspector();
- }
- GUILayout.Space(10.0f);
- }
- GUILayout.EndVertical();
- if (GUI.changed)
- {
- EditorUtility.SetDirty(pdfViewer);
- EditorUtility.SetDirty(pdfViewer.m_Internal);
- }
- }
- protected virtual void OnDisable()
- {
- DestroyImmediate(m_Background1.normal.background);
- DestroyImmediate(m_Background2.normal.background);
- DestroyImmediate(m_Background3.normal.background);
- }
- protected virtual void OnEnable()
- {
- pdfViewer = (PDFViewer) target;
- m_Background1 = new GUIStyle();
- m_Background1.normal.background = MakeTex(600, 1, new Color(1.0f, 1.0f, 1.0f, 0.1f));
- m_Background2 = new GUIStyle();
- m_Background2.normal.background = MakeTex(600, 1, new Color(1.0f, 1.0f, 1.0f, 0.0f));
- m_Background3 = new GUIStyle();
- m_Background3.normal.background = MakeTex(600, 1, new Color(1.0f, 1.0f, 1.0f, 0.05f));
- MonoScript script = MonoScript.FromScriptableObject(this);
- string scriptPath = AssetDatabase.GetAssetPath(script);
- m_Logo =
- (Texture2D)
- AssetDatabase.LoadAssetAtPath(Path.GetDirectoryName(scriptPath) + "/logo_pv.png", typeof (Texture2D));
- if (m_ParoxeBanner == null)
- m_ParoxeBanner = new PRParoxeBanner(Path.GetDirectoryName(scriptPath));
- }
- private static bool IsPrefabGhost(Transform This)
- {
- var TempObject = new GameObject();
- try
- {
- TempObject.transform.parent = This.parent;
- var OriginalIndex = This.GetSiblingIndex();
- This.SetSiblingIndex(int.MaxValue);
- if (This.GetSiblingIndex() == 0)
- {
- return true;
- }
- This.SetSiblingIndex(OriginalIndex);
- return false;
- }
- finally
- {
- UnityEngine.Object.DestroyImmediate(TempObject);
- }
- }
- private static void ShowInExplorer(string filePath)
- {
- filePath = Path.GetFullPath(filePath.Replace(@"/", @"\"));
- if (File.Exists(filePath))
- {
- System.Diagnostics.Process.Start("explorer.exe", "/select," + filePath);
- }
- }
- private static bool Browse(string startPath, ref string filename, ref string folder, ref string filePath, ref bool isStreamingAsset, ref bool isResourcesAsset, ref bool isFilePath)
- {
- bool result = false;
- string path = UnityEditor.EditorUtility.OpenFilePanel("Browse video file", startPath, "*");
- if (!string.IsNullOrEmpty(path) && !path.EndsWith(".meta"))
- {
- string projectRoot = System.IO.Path.GetFullPath(System.IO.Path.Combine(Application.dataPath, ".."));
- projectRoot = projectRoot.Replace('\\', '/');
- if (path.StartsWith(projectRoot))
- {
- if (path.StartsWith(Application.streamingAssetsPath))
- {
- path = path.Remove(0, Application.streamingAssetsPath.Length);
- filename = System.IO.Path.GetFileName(path);
- path = System.IO.Path.GetDirectoryName(path);
- if (path.StartsWith(System.IO.Path.DirectorySeparatorChar.ToString()) || path.StartsWith(System.IO.Path.AltDirectorySeparatorChar.ToString()))
- {
- path = path.Remove(0, 1);
- }
- folder = path;
- isStreamingAsset = true;
- isResourcesAsset = false;
- isFilePath = false;
- }
- else if (path.StartsWith(Application.dataPath + "/Resources"))
- {
- path = path.Remove(0, (Application.dataPath + "/Resources").Length);
- filename = System.IO.Path.GetFileName(path);
- path = System.IO.Path.GetDirectoryName(path);
- if (path.StartsWith(System.IO.Path.DirectorySeparatorChar.ToString()) || path.StartsWith(System.IO.Path.AltDirectorySeparatorChar.ToString()))
- {
- path = path.Remove(0, 1);
- }
- folder = path;
- isStreamingAsset = false;
- isResourcesAsset = true;
- isFilePath = false;
- }
- else
- {
- path = path.Remove(0, projectRoot.Length + 1);
- filePath = path;
- isStreamingAsset = false;
- isResourcesAsset = false;
- isFilePath = true;
- }
- }
- else
- {
- filePath = path;
- isStreamingAsset = false;
- isResourcesAsset = false;
- isFilePath = true;
- }
- result = true;
- }
- return result;
- }
- private Texture2D MakeTex(int width, int height, Color col)
- {
- Color[] pix = new Color[width*height];
- for (int i = 0; i < pix.Length; i++)
- {
- pix[i] = col;
- }
- Texture2D result = new Texture2D(width, height);
- result.hideFlags = HideFlags.HideAndDontSave;
- result.SetPixels(pix);
- result.Apply();
- return result;
- }
- private class BytesSupplierInfo
- {
- public Component m_Behaviour;
- public GameObject m_GameObject;
- public string m_MethodName;
- public BytesSupplierInfo(GameObject gameObject, Component component, string methodName)
- {
- m_GameObject = gameObject;
- m_Behaviour = component;
- m_MethodName = methodName;
- }
- }
- }
- }
|