//#define UNITY_5 //#define DEVELOPER using System; using System.Collections.Generic; using System.IO; using System.Linq; using UnityEditor; using UnityEngine; using Object = UnityEngine.Object; namespace P4Connect { #if DEVELOPER public class PackageIcons { private static string _p4ConnectBundle = "P4Connect"; private static string _iconAssetPath = Path.GetFullPath(Main.RootPath + "Assets/P4Connect/Editor"); [MenuItem("Assets/CopyIcons")] static void CopyIconsIntoAssets() { string sourceIconsPath = Path.GetFullPath(Main.RootPath + "../src/Icons/"); string assetIconsPath = Path.GetFullPath(Main.RootPath + "Assets/Icons/"); Debug.Log("fromDir: " + sourceIconsPath); Debug.Log("toDir: " + assetIconsPath); Directory.CreateDirectory(assetIconsPath); var files = Directory.GetFiles(sourceIconsPath); foreach (var file in files) { var filename = Path.GetFileName(file); var newfile = System.IO.Path.Combine(assetIconsPath, filename); if (System.IO.File.Exists(newfile)) // Make sure I can overwrite the file. { System.IO.File.SetAttributes(newfile, FileAttributes.Normal); } System.IO.File.Copy(file, newfile, true); } } // This code is only used to package icons into an asset to be included in the distribution // It only runs under unity 4.X, Tha AssetBundle code has changed under unity 5.X // We build p4connect in Unity 4.X so it is portable to either 4.X or 5.X [MenuItem("Assets/PackageIcons")] static void DoPackageIcons() { // Build the resource file from the images in the p4connect/main/src/Icons directory Debug.Log("running 5.X asset packager"); IList<string> names = new List<string>(); IList<Object> objs = new List<Object>(); string assetIconsPath = Path.GetFullPath(Main.RootPath + "Assets/Icons/"); Debug.Log("srcdir: " + assetIconsPath); var files = Directory.GetFiles(assetIconsPath); foreach (string f in files) { string assetPath = Utils.FullPathToAssetPath(f); var textureName = Path.GetFileNameWithoutExtension(assetPath); var extension = Path.GetExtension(assetPath); if (string.Equals(extension, ".jpg", StringComparison.InvariantCultureIgnoreCase) || string.Equals(extension, ".png", StringComparison.InvariantCultureIgnoreCase)) { Debug.Log("processing: " + textureName); //#if UNITY_5 var importer = AssetImporter.GetAtPath(assetPath); importer.assetBundleName = _p4ConnectBundle; names.Add(assetPath); //#else // Object thisobj = AssetDatabase.LoadAssetAtPath(assetPath, typeof (Object)); // Unity4 // if (thisobj == null) // { // Debug.Log("failed to load asset at: " + assetPath); // } // else // { // objs.Add(thisobj); // names.Add(assetPath); // } //#endif } else { Debug.Log("skipping non texture: " + f); } } //#if UNITY_5 var build = new AssetBundleBuild { assetBundleName = _p4ConnectBundle, assetNames = names.ToArray() }; BuildPipeline.BuildAssetBundles(_iconAssetPath, new[]{ build }, BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.StandaloneWindows); //#else // BuildPipeline.BuildAssetBundleExplicitAssetNames(objs.ToArray(), names.ToArray(), // "Assets/P4Connect/Editor/P4Connect1.icons", BuildAssetBundleOptions.UncompressedAssetBundle); //#endif } } // PackageIcons public class XYZZY : EditorWindow { static XYZZY() { } // Add menu named "Styles" to the Window menu [MenuItem("Window/Styles", false, 1000)] public static void ShowWindow() { // Get existing open window or if none, make a new one: XYZZY window = EditorWindow.GetWindow(typeof(XYZZY), false, "Styles") as XYZZY; window.titleContent = new GUIContent("Styles"); window.name = "Styles"; } static Vector2 _scrollPosition = new Vector2(); void OnGUI() { EditorGUILayout.BeginVertical(); _scrollPosition = GUILayout.BeginScrollView(_scrollPosition, false, true, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, GUI.skin.box); ShowStyles(GUI.skin); GUILayout.EndScrollView(); EditorGUILayout.EndVertical(); } public static void ShowStyles(GUISkin skin) { foreach (GUIStyle style in skin.customStyles) { GUILayout.Button(style.name, style); } } } #endif // DEVELOPER }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 22026 | prizkall |
Populate -o //guest/perforce_software/p4connect/... //guest/prizkall/p4connect/.... |
||
//guest/perforce_software/p4connect/main/src/P4Connect/P4Connect/P4Connect.PackageIcons.cs | |||||
#4 | 20275 | Norman Morse |
Update source to match 2016.2 patch 2 release Much thrashing of source during refactor. Proper caching of asset statuses, reducing fstats issued. Some bug fixes by Liz Lam Cleanup of Pending changes, rework of initialization and play/stop play transitions |
||
#3 | 18462 | Norman Morse |
Final Changes needed for 2016.1 release New Icons. New Icon Packaging. Unity 4 compatibility changes. |
||
#2 | 18436 | Norman Morse |
A lot of clean up. PackageIcons was a mess Needed to remove GUIStyle Saving because textures are getting lost. |
||
#1 | 18418 | Norman Morse |
Many changes from the dev branch. Icons are packaged differently. Style Sheet is created / used New ConnectionWizard Dialog New PasswordDialog Generate -a tickets Update version to 2016.1.0.0 |
||
//guest/norman_morse/p4connect/main/src/P4Connect/P4Connect/P4Connect.PackageIcons.cs | |||||
#1 | 18385 | Norman Morse |
Mostly working, friday before release. Password needs styling. Debug Code needs to be disabled |