void OnGUI() { EditorGUILayout.BeginHorizontal(); EditorGUIEx.ObjectField <TextAsset>(ref assetToCompress, false); GUI.enabled = assetToCompress != null; if (GUILayout.Button("Compress")) { string src = AssetDatabase.GetAssetPath(assetToCompress); string dst = StringUtil.InsertSuffix(src, "_compress"); dst = AssetDatabase.GenerateUniqueAssetPath(dst); byte[] compressed = CLZF.Compress(assetToCompress.bytes); FileStream os = new FileStream(dst, FileMode.CreateNew); os.Write(compressed, 0, compressed.Length); os.Close(); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); } EditorGUILayout.EndHorizontal(); GUI.enabled = true; EditorGUILayout.BeginHorizontal(); EditorGUIEx.ObjectField <TextAsset>(ref assetToDecompress, false); GUI.enabled = assetToDecompress != null; if (GUILayout.Button("Decompress")) { string src = AssetDatabase.GetAssetPath(assetToDecompress); string dst = StringUtil.InsertSuffix(src, "_decompress"); dst = AssetDatabase.GenerateUniqueAssetPath(dst); byte[] decompressed = CLZF.Decompress(assetToCompress.bytes); FileStream os = new FileStream(dst, FileMode.CreateNew); os.Write(decompressed, 0, decompressed.Length); os.Close(); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); } EditorGUILayout.EndHorizontal(); GUI.enabled = true; }
public override void OnInspectorGUI() { if (nestedPrefab.GetPrefab() != null) { EditorGUILayout.ObjectField(nestedPrefab.GetPrefab(), typeof(GameObject), false); } if (AssetDatabase.IsMainAsset(nestedPrefab.gameObject) || AssetDatabase.IsSubAsset(nestedPrefab.gameObject)) { return; } if (nestedPrefab.IsLinked()) { if (GUILayout.Button("Unlink Prefabs")) { PrefabRestore restore = new PrefabRestore(); nestedPrefab.transform.DepthFirstTraversal(restore.Apply); restore.Destroy(); } } else { if (GUILayout.Button("Link Prefabs")) { Build(); } } GameObject rootPrefab = PrefabUtility.GetPrefabParent(nestedPrefab.gameObject) as GameObject; EditorGUILayout.BeginHorizontal(); EditorGUIEx.ObjectField <Object>("Folder", ref folder, false); GUI.enabled = folder != null; if (GUILayout.Button("Create Prefab")) { if (!nestedPrefab.IsLinked()) { Build(); } string dir = EditorAssetUtil.GetAssetFileFullPath(AssetDatabase.GetAssetPath(folder)); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); AssetDatabase.Refresh(ImportAssetOptions.Default); } string path = AssetDatabase.GenerateUniqueAssetPath(PathUtil.Combine(AssetDatabase.GetAssetPath(folder), nestedPrefab.name + ".prefab")); rootPrefab = PrefabUtility.CreatePrefab(path, nestedPrefab.gameObject); Selection.activeGameObject = rootPrefab; } EditorGUILayout.EndHorizontal(); GUI.enabled = true; if (rootPrefab != null) { if (GUILayout.Button("Disconnect Prefab")) { PrefabUtility.DisconnectPrefabInstance(nestedPrefab.gameObject); } } if (EditorGUIEx.Toggle("Instantiate On Start", ref nestedPrefab.instantiateOnStart)) { EditorUtil.SetDirty(nestedPrefab); } if (EditorGUIEx.Toggle("Destroy On Instantiation", ref nestedPrefab.destroyOnInstantiation)) { EditorUtil.SetDirty(nestedPrefab); } }
protected override void ValueGUIImpl() { typedDrawnValue = EditorGUIEx.ObjectField(TypedDrawingValue, true); }