public static UndoRedoPerformed ( UnityEngine current ) : bool | ||
current | UnityEngine | |
Результат | bool |
override public void OnInspectorGUI() { bool multi = serializedObject.isEditingMultipleObjects; DrawInspectorGUI(multi); HandleSkinChange(); if (serializedObject.ApplyModifiedProperties() || SpineInspectorUtility.UndoRedoPerformed(Event.current) || AreAnyMaskMaterialsMissing()) { if (!Application.isPlaying) { foreach (var o in targets) { SpineEditorUtilities.ReinitializeComponent((SkeletonRenderer)o); } SceneView.RepaintAll(); } } if (!isInspectingPrefab) { if (requireRepaint) { UnityEditorInternal.InternalEditorUtility.RepaintAllViews(); requireRepaint = false; } } }
override public void OnInspectorGUI() { bool multi = serializedObject.isEditingMultipleObjects; DrawInspectorGUI(multi); HandleSkinChange(); if (serializedObject.ApplyModifiedProperties() || SpineInspectorUtility.UndoRedoPerformed(Event.current) || AreAnyMaskMaterialsMissing()) { if (!Application.isPlaying) { if (multi) { foreach (var o in targets) { EditorForceInitializeComponent((SkeletonRenderer)o); } } else { EditorForceInitializeComponent((SkeletonRenderer)target); } SceneView.RepaintAll(); } } }
override public void OnInspectorGUI() { bool multi = serializedObject.isEditingMultipleObjects; DrawInspectorGUI(multi); if (serializedObject.ApplyModifiedProperties() || SpineInspectorUtility.UndoRedoPerformed(Event.current) || AreAnyMaskMaterialsMissing()) { if (!Application.isPlaying) { if (multi) { foreach (var o in targets) { EditorForceInitializeComponent((SkeletonRenderer)o); } } else { EditorForceInitializeComponent((SkeletonRenderer)target); } SceneView.RepaintAll(); } } if (!Application.isPlaying && Event.current.type == EventType.Layout) { bool mismatchDetected = false; if (multi) { foreach (var o in targets) { mismatchDetected |= UpdateIfSkinMismatch((SkeletonRenderer)o); } } else { mismatchDetected |= UpdateIfSkinMismatch(target as SkeletonRenderer); } if (mismatchDetected) { mismatchDetected = false; SceneView.RepaintAll(); } } }
override public void OnInspectorGUI() { //serializedObject.Update(); bool multi = serializedObject.isEditingMultipleObjects; DrawInspectorGUI(multi); if (serializedObject.ApplyModifiedProperties() || SpineInspectorUtility.UndoRedoPerformed(Event.current)) { if (!Application.isPlaying) { if (multi) { foreach (var o in targets) { ((SkeletonRenderer)o).Initialize(true); } } else { ((SkeletonRenderer)target).Initialize(true); } } } }
override public void OnInspectorGUI() { serializedObject.Update(); atlasAsset = atlasAsset ?? (AtlasAsset)target; EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(atlasFile); EditorGUILayout.PropertyField(materials, true); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); atlasAsset.Clear(); atlasAsset.GetAtlas(); } if (materials.arraySize == 0) { EditorGUILayout.LabelField(new GUIContent("Error: Missing materials", SpineEditorUtilities.Icons.warning)); return; } for (int i = 0; i < materials.arraySize; i++) { SerializedProperty prop = materials.GetArrayElementAtIndex(i); Material mat = (Material)prop.objectReferenceValue; if (mat == null) { EditorGUILayout.LabelField(new GUIContent("Error: Materials cannot be null", SpineEditorUtilities.Icons.warning)); return; } } EditorGUILayout.Space(); if (atlasFile.objectReferenceValue != null) { if (SpineInspectorUtility.LargeCenteredButton(SpriteSlicesLabel)) { var atlas = atlasAsset.GetAtlas(); foreach (var m in atlasAsset.materials) { UpdateSpriteSlices(m.mainTexture, atlas); } } } #if REGION_BAKING_MESH if (atlasFile.objectReferenceValue != null) { Atlas atlas = asset.GetAtlas(); FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.NonPublic); List <AtlasRegion> regions = (List <AtlasRegion>)field.GetValue(atlas); EditorGUILayout.LabelField(new GUIContent("Region Baking", SpineEditorUtilities.Icons.unityIcon)); EditorGUI.indentLevel++; AtlasPage lastPage = null; for (int i = 0; i < regions.Count; i++) { if (lastPage != regions[i].page) { if (lastPage != null) { EditorGUILayout.Separator(); EditorGUILayout.Separator(); } lastPage = regions[i].page; Material mat = ((Material)lastPage.rendererObject); if (mat != null) { GUILayout.BeginHorizontal(); { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.ObjectField(mat, typeof(Material), false, GUILayout.Width(250)); EditorGUI.EndDisabledGroup(); } GUILayout.EndHorizontal(); } else { EditorGUILayout.LabelField(new GUIContent("Page missing material!", SpineEditorUtilities.Icons.warning)); } } GUILayout.BeginHorizontal(); { //EditorGUILayout.ToggleLeft(baked[i] ? "" : regions[i].name, baked[i]); bool result = baked[i] ? EditorGUILayout.ToggleLeft("", baked[i], GUILayout.Width(24)) : EditorGUILayout.ToggleLeft(" " + regions[i].name, baked[i]); if (baked[i]) { EditorGUILayout.ObjectField(bakedObjects[i], typeof(GameObject), false, GUILayout.Width(250)); } if (result && !baked[i]) { //bake baked[i] = true; bakedObjects[i] = SpineEditorUtilities.BakeRegion(atlasAsset, regions[i]); EditorGUIUtility.PingObject(bakedObjects[i]); } else if (!result && baked[i]) { //unbake bool unbakeResult = EditorUtility.DisplayDialog("Delete Baked Region", "Do you want to delete the prefab for " + regions[i].name, "Yes", "Cancel"); switch (unbakeResult) { case true: //delete string atlasAssetPath = AssetDatabase.GetAssetPath(atlasAsset); string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath); string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name); string bakedPrefabPath = Path.Combine(bakedDirPath, SpineEditorUtilities.GetPathSafeRegionName(regions[i]) + ".prefab").Replace("\\", "/"); AssetDatabase.DeleteAsset(bakedPrefabPath); baked[i] = false; break; case false: //do nothing break; } } } GUILayout.EndHorizontal(); } EditorGUI.indentLevel--; #if BAKE_ALL_BUTTON // Check state bool allBaked = true; bool allUnbaked = true; for (int i = 0; i < regions.Count; i++) { allBaked &= baked[i]; allUnbaked &= !baked[i]; } if (!allBaked && GUILayout.Button("Bake All")) { for (int i = 0; i < regions.Count; i++) { if (!baked[i]) { baked[i] = true; bakedObjects[i] = SpineEditorUtilities.BakeRegion(atlasAsset, regions[i]); } } } else if (!allUnbaked && GUILayout.Button("Unbake All")) { bool unbakeResult = EditorUtility.DisplayDialog("Delete All Baked Regions", "Are you sure you want to unbake all region prefabs? This cannot be undone.", "Yes", "Cancel"); switch (unbakeResult) { case true: //delete for (int i = 0; i < regions.Count; i++) { if (baked[i]) { string atlasAssetPath = AssetDatabase.GetAssetPath(atlasAsset); string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath); string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name); string bakedPrefabPath = Path.Combine(bakedDirPath, SpineEditorUtilities.GetPathSafeRegionName(regions[i]) + ".prefab").Replace("\\", "/"); AssetDatabase.DeleteAsset(bakedPrefabPath); baked[i] = false; } } break; case false: //do nothing break; } } #endif } #else if (atlasFile.objectReferenceValue != null) { EditorGUILayout.LabelField("Atlas Regions", EditorStyles.boldLabel); int baseIndent = EditorGUI.indentLevel; var regions = AtlasAssetInspector.GetRegions(atlasAsset.GetAtlas()); AtlasPage lastPage = null; for (int i = 0; i < regions.Count; i++) { if (lastPage != regions[i].page) { if (lastPage != null) { EditorGUILayout.Separator(); EditorGUILayout.Separator(); } lastPage = regions[i].page; Material mat = ((Material)lastPage.rendererObject); if (mat != null) { EditorGUI.indentLevel = baseIndent; using (new GUILayout.HorizontalScope()) using (new EditorGUI.DisabledGroupScope(true)) EditorGUILayout.ObjectField(mat, typeof(Material), false, GUILayout.Width(250)); EditorGUI.indentLevel = baseIndent + 1; } else { EditorGUILayout.HelpBox("Page missing material!", MessageType.Warning); } } EditorGUILayout.LabelField(new GUIContent(regions[i].name, SpineEditorUtilities.Icons.image)); } EditorGUI.indentLevel = baseIndent; } #endif if (serializedObject.ApplyModifiedProperties() || SpineInspectorUtility.UndoRedoPerformed(Event.current)) { atlasAsset.Clear(); } }
override public void OnInspectorGUI() { if (serializedObject.isEditingMultipleObjects) { DrawDefaultInspector(); return; } serializedObject.Update(); atlasAsset = (atlasAsset == null) ? (SpineAtlasAsset)target : atlasAsset; EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(atlasFile); EditorGUILayout.PropertyField(materials, true); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); atlasAsset.Clear(); atlasAsset.GetAtlas(); } if (materials.arraySize == 0) { EditorGUILayout.HelpBox("No materials", MessageType.Error); return; } for (int i = 0; i < materials.arraySize; i++) { SerializedProperty prop = materials.GetArrayElementAtIndex(i); var material = (Material)prop.objectReferenceValue; if (material == null) { EditorGUILayout.HelpBox("Materials cannot be null.", MessageType.Error); return; } } EditorGUILayout.Space(); if (SpineInspectorUtility.LargeCenteredButton(SpineInspectorUtility.TempContent("Set Mipmap Bias to " + SpinePreferences.DEFAULT_MIPMAPBIAS, tooltip: "This may help textures with mipmaps be less blurry when used for 2D sprites."))) { foreach (var m in atlasAsset.materials) { var texture = m.mainTexture; string texturePath = AssetDatabase.GetAssetPath(texture.GetInstanceID()); var importer = (TextureImporter)TextureImporter.GetAtPath(texturePath); importer.mipMapBias = SpinePreferences.DEFAULT_MIPMAPBIAS; EditorUtility.SetDirty(texture); } Debug.Log("Texture mipmap bias set to " + SpinePreferences.DEFAULT_MIPMAPBIAS); } EditorGUILayout.Space(); if (atlasFile.objectReferenceValue != null) { if (SpineInspectorUtility.LargeCenteredButton(SpriteSlicesLabel)) { var atlas = atlasAsset.GetAtlas(); foreach (var m in atlasAsset.materials) { UpdateSpriteSlices(m.mainTexture, atlas); } } } EditorGUILayout.Space(); #if REGION_BAKING_MESH if (atlasFile.objectReferenceValue != null) { Atlas atlas = asset.GetAtlas(); FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.NonPublic); List <AtlasRegion> regions = (List <AtlasRegion>)field.GetValue(atlas); EditorGUILayout.LabelField(new GUIContent("Region Baking", SpineEditorUtilities.Icons.unityIcon)); EditorGUI.indentLevel++; AtlasPage lastPage = null; for (int i = 0; i < regions.Count; i++) { if (lastPage != regions[i].page) { if (lastPage != null) { EditorGUILayout.Separator(); EditorGUILayout.Separator(); } lastPage = regions[i].page; Material mat = ((Material)lastPage.rendererObject); if (mat != null) { GUILayout.BeginHorizontal(); { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.ObjectField(mat, typeof(Material), false, GUILayout.Width(250)); EditorGUI.EndDisabledGroup(); } GUILayout.EndHorizontal(); } else { EditorGUILayout.LabelField(new GUIContent("Page missing material!", SpineEditorUtilities.Icons.warning)); } } GUILayout.BeginHorizontal(); { //EditorGUILayout.ToggleLeft(baked[i] ? "" : regions[i].name, baked[i]); bool result = baked[i] ? EditorGUILayout.ToggleLeft("", baked[i], GUILayout.Width(24)) : EditorGUILayout.ToggleLeft(" " + regions[i].name, baked[i]); if (baked[i]) { EditorGUILayout.ObjectField(bakedObjects[i], typeof(GameObject), false, GUILayout.Width(250)); } if (result && !baked[i]) { //bake baked[i] = true; bakedObjects[i] = SpineEditorUtilities.BakeRegion(atlasAsset, regions[i]); EditorGUIUtility.PingObject(bakedObjects[i]); } else if (!result && baked[i]) { //unbake bool unbakeResult = EditorUtility.DisplayDialog("Delete Baked Region", "Do you want to delete the prefab for " + regions[i].name, "Yes", "Cancel"); switch (unbakeResult) { case true: //delete string atlasAssetPath = AssetDatabase.GetAssetPath(atlasAsset); string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath); string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name); string bakedPrefabPath = Path.Combine(bakedDirPath, SpineEditorUtilities.GetPathSafeRegionName(regions[i]) + ".prefab").Replace("\\", "/"); AssetDatabase.DeleteAsset(bakedPrefabPath); baked[i] = false; break; case false: //do nothing break; } } } GUILayout.EndHorizontal(); } EditorGUI.indentLevel--; #if BAKE_ALL_BUTTON // Check state bool allBaked = true; bool allUnbaked = true; for (int i = 0; i < regions.Count; i++) { allBaked &= baked[i]; allUnbaked &= !baked[i]; } if (!allBaked && GUILayout.Button("Bake All")) { for (int i = 0; i < regions.Count; i++) { if (!baked[i]) { baked[i] = true; bakedObjects[i] = SpineEditorUtilities.BakeRegion(atlasAsset, regions[i]); } } } else if (!allUnbaked && GUILayout.Button("Unbake All")) { bool unbakeResult = EditorUtility.DisplayDialog("Delete All Baked Regions", "Are you sure you want to unbake all region prefabs? This cannot be undone.", "Yes", "Cancel"); switch (unbakeResult) { case true: //delete for (int i = 0; i < regions.Count; i++) { if (baked[i]) { string atlasAssetPath = AssetDatabase.GetAssetPath(atlasAsset); string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath); string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name); string bakedPrefabPath = Path.Combine(bakedDirPath, SpineEditorUtilities.GetPathSafeRegionName(regions[i]) + ".prefab").Replace("\\", "/"); AssetDatabase.DeleteAsset(bakedPrefabPath); baked[i] = false; } } break; case false: //do nothing break; } } #endif } #else if (atlasFile.objectReferenceValue != null) { int baseIndent = EditorGUI.indentLevel; var regions = SpineAtlasAssetInspector.GetRegions(atlasAsset.GetAtlas()); int regionsCount = regions.Count; using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("Atlas Regions", EditorStyles.boldLabel); EditorGUILayout.LabelField(string.Format("{0} regions total", regionsCount)); } AtlasPage lastPage = null; for (int i = 0; i < regionsCount; i++) { if (lastPage != regions[i].page) { if (lastPage != null) { EditorGUILayout.Separator(); EditorGUILayout.Separator(); } lastPage = regions[i].page; Material mat = ((Material)lastPage.rendererObject); if (mat != null) { EditorGUI.indentLevel = baseIndent; using (new GUILayout.HorizontalScope()) using (new EditorGUI.DisabledGroupScope(true)) EditorGUILayout.ObjectField(mat, typeof(Material), false, GUILayout.Width(250)); EditorGUI.indentLevel = baseIndent + 1; } else { EditorGUILayout.HelpBox("Page missing material!", MessageType.Warning); } } string regionName = regions[i].name; Texture2D icon = SpineEditorUtilities.Icons.image; if (regionName.EndsWith(" ")) { regionName = string.Format("'{0}'", regions[i].name); icon = SpineEditorUtilities.Icons.warning; EditorGUILayout.LabelField(SpineInspectorUtility.TempContent(regionName, icon, "Region name ends with whitespace. This may cause errors. Please check your source image filenames.")); } else { EditorGUILayout.LabelField(SpineInspectorUtility.TempContent(regionName, icon)); } } EditorGUI.indentLevel = baseIndent; } #endif if (serializedObject.ApplyModifiedProperties() || SpineInspectorUtility.UndoRedoPerformed(Event.current)) { atlasAsset.Clear(); } }
override public void OnInspectorGUI() { if (serializedObject.isEditingMultipleObjects) { DrawDefaultInspector(); return; } serializedObject.Update(); atlasAsset = atlasAsset ?? (SpineSpriteAtlasAsset)target; if (atlasAsset.RegionsNeedLoading) { if (GUILayout.Button(SpineInspectorUtility.TempContent("Load regions by entering Play mode"), GUILayout.Height(20))) { EditorApplication.isPlaying = true; } } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(atlasFile); EditorGUILayout.PropertyField(materials, true); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); atlasAsset.Clear(); atlasAsset.GetAtlas(); atlasAsset.updateRegionsInPlayMode = true; } if (materials.arraySize == 0) { EditorGUILayout.HelpBox("No materials", MessageType.Error); return; } for (int i = 0; i < materials.arraySize; i++) { SerializedProperty prop = materials.GetArrayElementAtIndex(i); var material = (Material)prop.objectReferenceValue; if (material == null) { EditorGUILayout.HelpBox("Materials cannot be null.", MessageType.Error); return; } } if (atlasFile.objectReferenceValue != null) { int baseIndent = EditorGUI.indentLevel; var regions = SpineSpriteAtlasAssetInspector.GetRegions(atlasAsset.GetAtlas()); int regionsCount = regions.Count; using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("Atlas Regions", EditorStyles.boldLabel); EditorGUILayout.LabelField(string.Format("{0} regions total", regionsCount)); } AtlasPage lastPage = null; for (int i = 0; i < regionsCount; i++) { if (lastPage != regions[i].page) { if (lastPage != null) { EditorGUILayout.Separator(); EditorGUILayout.Separator(); } lastPage = regions[i].page; Material mat = ((Material)lastPage.rendererObject); if (mat != null) { EditorGUI.indentLevel = baseIndent; using (new GUILayout.HorizontalScope()) using (new EditorGUI.DisabledGroupScope(true)) EditorGUILayout.ObjectField(mat, typeof(Material), false, GUILayout.Width(250)); EditorGUI.indentLevel = baseIndent + 1; } else { EditorGUILayout.HelpBox("Page missing material!", MessageType.Warning); } } string regionName = regions[i].name; Texture2D icon = SpineEditorUtilities.Icons.image; if (regionName.EndsWith(" ")) { regionName = string.Format("'{0}'", regions[i].name); icon = SpineEditorUtilities.Icons.warning; EditorGUILayout.LabelField(SpineInspectorUtility.TempContent(regionName, icon, "Region name ends with whitespace. This may cause errors. Please check your source image filenames.")); } else { EditorGUILayout.LabelField(SpineInspectorUtility.TempContent(regionName, icon)); } } EditorGUI.indentLevel = baseIndent; } if (serializedObject.ApplyModifiedProperties() || SpineInspectorUtility.UndoRedoPerformed(Event.current)) { atlasAsset.Clear(); } }