public static PropertyFieldWideLabel ( SerializedProperty property, GUIContent label = null, float minimumLabelWidth = 150 ) : void | ||
property | SerializedProperty | |
label | GUIContent | |
minimumLabelWidth | float | |
Résultat | void |
void OnInspectorGUIMulti() { // Skeleton data file field. using (new SpineInspectorUtility.BoxScope()) { EditorGUILayout.LabelField("SkeletonData", EditorStyles.boldLabel); EditorGUILayout.PropertyField(skeletonJSON, SpineInspectorUtility.TempContent(skeletonJSON.displayName, Icons.spine)); EditorGUILayout.PropertyField(scale); } // Texture source field. using (new SpineInspectorUtility.BoxScope()) { EditorGUILayout.LabelField("Atlas", EditorStyles.boldLabel); #if !SPINE_TK2D EditorGUILayout.PropertyField(atlasAssets, true); #else using (new EditorGUI.DisabledGroupScope(spriteCollection.objectReferenceValue != null)) { EditorGUILayout.PropertyField(atlasAssets, true); } EditorGUILayout.LabelField("spine-tk2d", EditorStyles.boldLabel); EditorGUILayout.PropertyField(spriteCollection, true); #endif } // Mix settings. using (new SpineInspectorUtility.BoxScope()) { EditorGUILayout.LabelField("Mix Settings", EditorStyles.boldLabel); SpineInspectorUtility.PropertyFieldWideLabel(defaultMix, DefaultMixLabel, 160); EditorGUILayout.Space(); } }
void DrawAnimationStateInfo() { showAnimationStateData = EditorGUILayout.Foldout(showAnimationStateData, "Animation State Data"); if (!showAnimationStateData) { return; } EditorGUI.BeginChangeCheck(); SpineInspectorUtility.PropertyFieldWideLabel(defaultMix, DefaultMixLabel, 160); var animations = new string[m_skeletonData.Animations.Count]; for (int i = 0; i < animations.Length; i++) { animations[i] = m_skeletonData.Animations.Items[i].Name; } for (int i = 0; i < fromAnimation.arraySize; i++) { SerializedProperty from = fromAnimation.GetArrayElementAtIndex(i); SerializedProperty to = toAnimation.GetArrayElementAtIndex(i); SerializedProperty durationProp = duration.GetArrayElementAtIndex(i); using (new EditorGUILayout.HorizontalScope()) { from.stringValue = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, from.stringValue), 0), animations)]; to.stringValue = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, to.stringValue), 0), animations)]; durationProp.floatValue = EditorGUILayout.FloatField(durationProp.floatValue); if (GUILayout.Button("Delete")) { duration.DeleteArrayElementAtIndex(i); toAnimation.DeleteArrayElementAtIndex(i); fromAnimation.DeleteArrayElementAtIndex(i); } } } using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.Space(); if (GUILayout.Button("Add Mix")) { duration.arraySize++; toAnimation.arraySize++; fromAnimation.arraySize++; } EditorGUILayout.Space(); } if (EditorGUI.EndChangeCheck()) { m_skeletonDataAsset.FillStateData(); EditorUtility.SetDirty(m_skeletonDataAsset); serializedObject.ApplyModifiedProperties(); needToSerialize = true; } }
void DrawAnimationStateInfo() { using (new SpineInspectorUtility.IndentScope()) showAnimationStateData = EditorGUILayout.Foldout(showAnimationStateData, "Animation State Data"); if (!showAnimationStateData) { return; } EditorGUI.BeginChangeCheck(); using (new SpineInspectorUtility.IndentScope()) SpineInspectorUtility.PropertyFieldWideLabel(defaultMix, DefaultMixLabel, 160); // Do not use EditorGUIUtility.indentLevel. It will add spaces on every field. for (int i = 0; i < fromAnimation.arraySize; i++) { SerializedProperty from = fromAnimation.GetArrayElementAtIndex(i); SerializedProperty to = toAnimation.GetArrayElementAtIndex(i); SerializedProperty durationProp = duration.GetArrayElementAtIndex(i); using (new EditorGUILayout.HorizontalScope()) { GUILayout.Space(16f); EditorGUILayout.PropertyField(from, GUIContent.none); EditorGUILayout.PropertyField(to, GUIContent.none); durationProp.floatValue = EditorGUILayout.FloatField(durationProp.floatValue, GUILayout.MinWidth(25f), GUILayout.MaxWidth(60f)); if (GUILayout.Button("Delete", EditorStyles.miniButton)) { duration.DeleteArrayElementAtIndex(i); toAnimation.DeleteArrayElementAtIndex(i); fromAnimation.DeleteArrayElementAtIndex(i); } } } using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.Space(); if (GUILayout.Button("Add Mix")) { duration.arraySize++; toAnimation.arraySize++; fromAnimation.arraySize++; } EditorGUILayout.Space(); } if (EditorGUI.EndChangeCheck()) { m_skeletonDataAsset.FillStateData(); EditorUtility.SetDirty(m_skeletonDataAsset); serializedObject.ApplyModifiedProperties(); needToSerialize = true; } }
override public void OnInspectorGUI() { if (serializedObject.isEditingMultipleObjects) { using (new SpineInspectorUtility.BoxScope()) { EditorGUILayout.LabelField("SkeletonData", EditorStyles.boldLabel); EditorGUILayout.PropertyField(skeletonJSON, new GUIContent(skeletonJSON.displayName, Icons.spine)); EditorGUILayout.PropertyField(scale); } using (new SpineInspectorUtility.BoxScope()) { EditorGUILayout.LabelField("Atlas", EditorStyles.boldLabel); #if !SPINE_TK2D EditorGUILayout.PropertyField(atlasAssets, true); #else using (new EditorGUI.DisabledGroupScope(spriteCollection.objectReferenceValue != null)) { EditorGUILayout.PropertyField(atlasAssets, true); } EditorGUILayout.LabelField("spine-tk2d", EditorStyles.boldLabel); EditorGUILayout.PropertyField(spriteCollection, true); #endif } using (new SpineInspectorUtility.BoxScope()) { EditorGUILayout.LabelField("Mix Settings", EditorStyles.boldLabel); SpineInspectorUtility.PropertyFieldWideLabel(defaultMix, DefaultMixLabel, 160); EditorGUILayout.Space(); } return; } { // Lazy initialization because accessing EditorStyles values in OnEnable during a recompile causes UnityEditor to throw null exceptions. (Unity 5.3.5) idlePlayButtonStyle = idlePlayButtonStyle ?? new GUIStyle(EditorStyles.miniButton); if (activePlayButtonStyle == null) { activePlayButtonStyle = new GUIStyle(idlePlayButtonStyle); activePlayButtonStyle.normal.textColor = Color.red; } } serializedObject.Update(); EditorGUILayout.LabelField(new GUIContent(target.name + " (SkeletonDataAsset)", Icons.spine), EditorStyles.whiteLargeLabel); if (m_skeletonData != null) { EditorGUILayout.LabelField("(Drag and Drop to instantiate.)", EditorStyles.miniLabel); } EditorGUI.BeginChangeCheck(); // SkeletonData using (new SpineInspectorUtility.BoxScope()) { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("SkeletonData", EditorStyles.boldLabel); // if (m_skeletonData != null) { // var sd = m_skeletonData; // string m = string.Format("{8} - {0} {1}\nBones: {2}\tConstraints: {5} IK + {6} Path + {7} Transform\nSlots: {3}\t\tSkins: {4}\n", // sd.Version, string.IsNullOrEmpty(sd.Version) ? "" : "export", sd.Bones.Count, sd.Slots.Count, sd.Skins.Count, sd.IkConstraints.Count, sd.PathConstraints.Count, sd.TransformConstraints.Count, skeletonJSON.objectReferenceValue.name); // EditorGUILayout.LabelField(new GUIContent("SkeletonData"), new GUIContent("+", m), EditorStyles.boldLabel); // } } EditorGUILayout.PropertyField(skeletonJSON, new GUIContent(skeletonJSON.displayName, Icons.spine)); EditorGUILayout.PropertyField(scale); } // if (m_skeletonData != null) { // if (SpineInspectorUtility.CenteredButton(new GUIContent("Instantiate", Icons.spine, "Creates a new Spine GameObject in the active scene using this Skeleton Data.\nYou can also instantiate by dragging the SkeletonData asset from Project view into Scene View."))) // SpineEditorUtilities.ShowInstantiateContextMenu(this.m_skeletonDataAsset, Vector3.zero); // } // Atlas using (new SpineInspectorUtility.BoxScope()) { EditorGUILayout.LabelField("Atlas", EditorStyles.boldLabel); #if !SPINE_TK2D EditorGUILayout.PropertyField(atlasAssets, true); #else using (new EditorGUI.DisabledGroupScope(spriteCollection.objectReferenceValue != null)) { EditorGUILayout.PropertyField(atlasAssets, true); } EditorGUILayout.LabelField("spine-tk2d", EditorStyles.boldLabel); EditorGUILayout.PropertyField(spriteCollection, true); #endif } if (EditorGUI.EndChangeCheck()) { if (serializedObject.ApplyModifiedProperties()) { if (m_previewUtility != null) { m_previewUtility.Cleanup(); m_previewUtility = null; } m_skeletonDataAsset.Clear(); m_skeletonData = null; OnEnable(); // Should call RepopulateWarnings. return; } } // Some code depends on the existence of m_skeletonAnimation instance. // If m_skeletonAnimation is lazy-instantiated elsewhere, this can cause contents to change between Layout and Repaint events, causing GUILayout control count errors. InitPreview(); if (m_skeletonData != null) { GUILayout.Space(20f); using (new SpineInspectorUtility.BoxScope()) { EditorGUILayout.LabelField("Mix Settings", EditorStyles.boldLabel); DrawAnimationStateInfo(); EditorGUILayout.Space(); } EditorGUILayout.LabelField("Preview", EditorStyles.boldLabel); DrawAnimationList(); EditorGUILayout.Space(); DrawSlotList(); EditorGUILayout.Space(); DrawUnityTools(); } else { #if !SPINE_TK2D // Reimport Button using (new EditorGUI.DisabledGroupScope(skeletonJSON.objectReferenceValue == null)) { if (GUILayout.Button(new GUIContent("Attempt Reimport", Icons.warning))) { DoReimport(); } } #else EditorGUILayout.HelpBox("Couldn't load SkeletonData.", MessageType.Error); #endif // List warnings. foreach (var line in warnings) { EditorGUILayout.LabelField(new GUIContent(line, Icons.warning)); } } if (!Application.isPlaying) { serializedObject.ApplyModifiedProperties(); } }
protected virtual void DrawInspectorGUI(bool multi) { bool valid = TargetIsValid; if (multi) { using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.PropertyField(skeletonDataAsset); const string ReloadButtonLabel = "Reload"; float reloadWidth = GUI.skin.label.CalcSize(new GUIContent(ReloadButtonLabel)).x + 20; if (GUILayout.Button(ReloadButtonLabel, GUILayout.Width(reloadWidth))) { foreach (var c in targets) { var component = c as SkeletonRenderer; if (component.skeletonDataAsset != null) { foreach (AtlasAsset aa in component.skeletonDataAsset.atlasAssets) { if (aa != null) { aa.Reset(); } } component.skeletonDataAsset.Reset(); } component.Initialize(true); } } } foreach (var c in targets) { var component = c as SkeletonRenderer; if (!component.valid) { component.Initialize(true); component.LateUpdate(); if (!component.valid) { continue; } } #if NO_PREFAB_MESH if (isInspectingPrefab) { MeshFilter meshFilter = component.GetComponent <MeshFilter>(); if (meshFilter != null) { meshFilter.sharedMesh = null; } } #endif } if (valid) { EditorGUILayout.PropertyField(initialSkinName); } } else { var component = (SkeletonRenderer)target; using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.PropertyField(skeletonDataAsset); if (valid) { const string ReloadButtonLabel = "Reload"; float reloadWidth = GUI.skin.label.CalcSize(new GUIContent(ReloadButtonLabel)).x + 20; if (GUILayout.Button(ReloadButtonLabel, GUILayout.Width(reloadWidth))) { if (component.skeletonDataAsset != null) { foreach (AtlasAsset aa in component.skeletonDataAsset.atlasAssets) { if (aa != null) { aa.Reset(); } } component.skeletonDataAsset.Reset(); } component.Initialize(true); } } } if (!component.valid) { component.Initialize(true); component.LateUpdate(); if (!component.valid) { EditorGUILayout.HelpBox("Skeleton Data Asset required", MessageType.Warning); return; } } #if NO_PREFAB_MESH if (isInspectingPrefab) { MeshFilter meshFilter = component.GetComponent <MeshFilter>(); if (meshFilter != null) { meshFilter.sharedMesh = null; } } #endif // Initial skin name. if (valid) { string[] skins = new string[component.skeleton.Data.Skins.Count]; int skinIndex = 0; for (int i = 0; i < skins.Length; i++) { string skinNameString = component.skeleton.Data.Skins.Items[i].Name; skins[i] = skinNameString; if (skinNameString == initialSkinName.stringValue) { skinIndex = i; } } skinIndex = EditorGUILayout.Popup("Initial Skin", skinIndex, skins); initialSkinName.stringValue = skins[skinIndex]; } } EditorGUILayout.Space(); // Sorting Layers SpineInspectorUtility.SortingPropertyFields(sortingProperties, applyModifiedProperties: true); if (!valid) { return; } // More Render Options... using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { EditorGUI.indentLevel++; advancedFoldout = EditorGUILayout.Foldout(advancedFoldout, "Advanced"); if (advancedFoldout) { EditorGUI.indentLevel++; SeparatorsField(separatorSlotNames); EditorGUILayout.Space(); // Optimization options SpineInspectorUtility.PropertyFieldWideLabel(meshes, new GUIContent("Render MeshAttachments", "Disable to optimize rendering for skeletons that don't use Mesh Attachments")); SpineInspectorUtility.PropertyFieldWideLabel(immutableTriangles, new GUIContent("Immutable Triangles", "Enable to optimize rendering for skeletons that never change attachment visbility")); EditorGUILayout.Space(); // Render options const float MinZSpacing = -0.1f; const float MaxZSpacing = 0f; EditorGUILayout.Slider(zSpacing, MinZSpacing, MaxZSpacing); EditorGUILayout.Space(); SpineInspectorUtility.PropertyFieldWideLabel(pmaVertexColors, new GUIContent("PMA Vertex Colors", "Use this if you are using the default Spine/Skeleton shader or any premultiply-alpha shader.")); // Optional fields. May be disabled in SkeletonRenderer. if (normals != null) { SpineInspectorUtility.PropertyFieldWideLabel(normals, new GUIContent("Add Normals")); } if (tangents != null) { SpineInspectorUtility.PropertyFieldWideLabel(tangents, new GUIContent("Solve Tangents")); } if (frontFacing != null) { SpineInspectorUtility.PropertyFieldWideLabel(frontFacing); } EditorGUI.indentLevel--; } EditorGUI.indentLevel--; } }