// public override void OnInspectorGUI() // { // serializedObject.Update(); // // SpriteGUI(); // AppearanceControlsGUI(); // RaycastControlsGUI(); // //// m_ShowType.target = m_Sprite.objectReferenceValue != null; // m_ShowType.target = m_Texture.objectReferenceValue != null; // // // if (EditorGUILayout.BeginFadeGroup(m_ShowType.faded)) // TypeGUI(); // EditorGUILayout.EndFadeGroup(); // // SetShowNativeSize(false); // if (EditorGUILayout.BeginFadeGroup(m_ShowNativeSize.faded)) // { // EditorGUI.indentLevel++; // EditorGUILayout.PropertyField(m_PreserveAspect); // EditorGUI.indentLevel--; // } // EditorGUILayout.EndFadeGroup(); // NativeSizeButtonGUI(); // // serializedObject.ApplyModifiedProperties(); // } // void SetShowNativeSize(bool instant) // { // FillableRawImage.Type type = (FillableRawImage.Type)m_Type.enumValueIndex; // bool showNativeSize = (type == FillableRawImage.Type.Simple || type == FillableRawImage.Type.Filled); // base.SetShowNativeSize(showNativeSize, instant); // } /// <summary> /// Draw the atlas and Image selection fields. /// </summary> // protected void SpriteGUI() // { // EditorGUI.BeginChangeCheck(); // //// EditorGUILayout.PropertyField(m_Sprite, m_SpriteContent); // // if (EditorGUI.EndChangeCheck()) // { // var newSprite = m_Sprite.objectReferenceValue as Sprite; // if (newSprite) // { // FillableRawImage.Type oldType = (FillableRawImage.Type)m_Type.enumValueIndex; // if (newSprite.border.SqrMagnitude() > 0) // { // m_Type.enumValueIndex = (int)FillableRawImage.Type.Sliced; // } // else if (oldType == FillableRawImage.Type.Sliced) // { // m_Type.enumValueIndex = (int)FillableRawImage.Type.Simple; // } // } // } // } /// <summary> /// Sprites's custom properties based on the type. /// </summary> protected void TypeGUI() { EditorGUILayout.PropertyField(m_Type, m_SpriteTypeContent); ++EditorGUI.indentLevel; { FillableRawImage.Type typeEnum = (FillableRawImage.Type)m_Type.enumValueIndex; bool showSlicedOrTiled = (!m_Type.hasMultipleDifferentValues && (typeEnum == FillableRawImage.Type.Sliced || typeEnum == FillableRawImage.Type.Tiled)); if (showSlicedOrTiled && targets.Length > 1) { showSlicedOrTiled = targets.Select(obj => obj as Image).All(img => img.hasBorder); } m_ShowSlicedOrTiled.target = showSlicedOrTiled; m_ShowSliced.target = (showSlicedOrTiled && !m_Type.hasMultipleDifferentValues && typeEnum == FillableRawImage.Type.Sliced); m_ShowFilled.target = (!m_Type.hasMultipleDifferentValues && typeEnum == FillableRawImage.Type.Filled); Image image = target as Image; if (EditorGUILayout.BeginFadeGroup(m_ShowSlicedOrTiled.faded)) { if (image.hasBorder) { EditorGUILayout.PropertyField(m_FillCenter); } } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(m_ShowSliced.faded)) { if (image.sprite != null && !image.hasBorder) { EditorGUILayout.HelpBox("This Image doesn't have a border.", MessageType.Warning); } } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(m_ShowFilled.faded)) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_FillMethod); if (EditorGUI.EndChangeCheck()) { m_FillOrigin.intValue = 0; } switch ((Image.FillMethod)m_FillMethod.enumValueIndex) { case Image.FillMethod.Horizontal: m_FillOrigin.intValue = (int)(Image.OriginHorizontal)EditorGUILayout.EnumPopup("Fill Origin", (Image.OriginHorizontal)m_FillOrigin.intValue); break; case Image.FillMethod.Vertical: m_FillOrigin.intValue = (int)(Image.OriginVertical)EditorGUILayout.EnumPopup("Fill Origin", (Image.OriginVertical)m_FillOrigin.intValue); break; case Image.FillMethod.Radial90: m_FillOrigin.intValue = (int)(Image.Origin90)EditorGUILayout.EnumPopup("Fill Origin", (Image.Origin90)m_FillOrigin.intValue); break; case Image.FillMethod.Radial180: m_FillOrigin.intValue = (int)(Image.Origin180)EditorGUILayout.EnumPopup("Fill Origin", (Image.Origin180)m_FillOrigin.intValue); break; case Image.FillMethod.Radial360: m_FillOrigin.intValue = (int)(Image.Origin360)EditorGUILayout.EnumPopup("Fill Origin", (Image.Origin360)m_FillOrigin.intValue); break; } EditorGUILayout.PropertyField(m_FillAmount); if ((Image.FillMethod)m_FillMethod.enumValueIndex > Image.FillMethod.Vertical) { EditorGUILayout.PropertyField(m_FillClockwise, m_ClockwiseContent); } } EditorGUILayout.EndFadeGroup(); } --EditorGUI.indentLevel; }
//called whenever the inspector gui gets rendered public override void OnInspectorGUI() { EditorGUILayout.Space(); if (ivyBehavior == null) { ivyBehavior = (IvyBehavior)target; } wasPartOfPrefab = IvyCore.IsPartOfPrefab(ivyBehavior.gameObject); bool isInARealScene = !string.IsNullOrEmpty(ivyBehavior.gameObject.scene.path) && ivyBehavior.gameObject.activeInHierarchy; if (isInARealScene) { lastDataAsset = IvyCore.GetDataAsset(ivyBehavior.gameObject); } EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUI.BeginChangeCheck(); ivyBehavior.profileAsset = EditorGUILayout.ObjectField(ivyBehavior.profileAsset, typeof(IvyProfileAsset), false) as IvyProfileAsset; if (EditorGUI.EndChangeCheck() || (ivyProfileEditor == null && ivyBehavior.profileAsset != null)) { ivyProfileEditor = Editor.CreateEditor(ivyBehavior.profileAsset); ((IvyProfileEditor)ivyProfileEditor).viewedFromMonobehavior = true; } // destroy old editor / cleanup if (ivyBehavior.profileAsset == null && ivyProfileEditor != null) { DestroyImmediate(ivyProfileEditor); } if (ivyBehavior.profileAsset == null || ivyProfileEditor == null) { EditorGUILayout.HelpBox("Please assign an Ivy Profile Asset.", MessageType.Warning); if (GUILayout.Button("Create new Ivy Profile Asset...")) { var newAsset = IvyCore.CreateNewAsset(""); if (newAsset != null) { ivyBehavior.profileAsset = newAsset; ivyBehavior.showProfileFoldout = true; Selection.activeGameObject = ivyBehavior.gameObject; } } EditorGUILayout.EndVertical(); return; } var ivyProfile = ivyBehavior.profileAsset.ivyProfile; if (!IvyCore.ivyBehaviors.Contains(ivyBehavior)) { IvyCore.ivyBehaviors.Add(ivyBehavior); } GUIContent content = null; EditorGUI.indentLevel++; ivyBehavior.showProfileFoldout = EditorGUILayout.Foldout(ivyBehavior.showProfileFoldout, "Ivy Profile Settings", true); EditorGUI.indentLevel--; if (EditorGUILayout.BeginFadeGroup(ivyBehavior.showProfileFoldout ? 1 : 0)) { ivyProfileEditor.OnInspectorGUI(); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.EndVertical(); DrawUILine(); GUILayout.Label("Ivy Painter", EditorStyles.boldLabel); if (!isInARealScene) { EditorGUILayout.HelpBox("Painting / mesh generation only works in saved scenes on active game objects.\n- Save the scene?\n- Put this game object in a saved scene?\n- Make sure it is active?", MessageType.Error); GUI.enabled = false; } // plant root creation button var oldColor = GUI.color; GUI.color = isPlantingModeActive ? Color.yellow : Color.Lerp(Color.yellow, oldColor, 0.69f); content = new GUIContent(!isPlantingModeActive ? " Start Painting Ivy": " Stop Painting Ivy", iconPaint, "while painting, left-click and drag in the Scene view on any collider"); if (GUILayout.Button(content, GUILayout.Height(20))) { isPlantingModeActive = !isPlantingModeActive; } GUI.color = oldColor; content = new GUIContent(" Enable Growth Sim AI", "If disabled, then you can just paint ivy without simulation or AI, which is useful when you want small strokes or full control."); ivyBehavior.enableGrowthSim = EditorGUILayout.ToggleLeft(content, ivyBehavior.enableGrowthSim); content = new GUIContent(" Make Mesh During Painting / Growth", "Generate 3D ivy mesh during painting and growth. Very cool, but very processing intensive. If your computer gets very slow while painting, then disable this."); ivyBehavior.generateMeshDuringGrowth = EditorGUILayout.ToggleLeft(content, ivyBehavior.generateMeshDuringGrowth); int visibleIvy = ivyBehavior.ivyGraphs.Where(ivy => ivy.isVisible).Count(); GUI.enabled = isInARealScene && visibleIvy > 0; EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); content = new GUIContent(" Re-mesh Visible", iconMesh, "Remake meshes for all visible ivy, all at once. Useful when you change your ivy profile settings, and want to see the new changes."); if (GUILayout.Button(content, EditorStyles.miniButtonLeft, GUILayout.MaxWidth(EditorGUIUtility.currentViewWidth * 0.45f), GUILayout.Height(16))) { if (EditorUtility.DisplayDialog("Hedera: Remake All Visible Meshes", string.Format("Are you sure you want to remake {0} meshes all at once? It also might be very slow or crash your editor.", visibleIvy), "YES!", "Maybe not...")) { foreach (var ivy in ivyBehavior.ivyGraphs) { if (!ivy.isVisible) { continue; } if (ivy.rootGO != null) { Undo.RegisterFullObjectHierarchyUndo(ivy.rootGO, "Hedera > Re-mesh Visible"); } else { IvyMesh.InitOrRefreshRoot(ivy, ivyProfile); Undo.RegisterCreatedObjectUndo(ivy.rootGO, "Hedera > Re-mesh Visible"); } IvyMesh.GenerateMesh(ivy, ivyProfile, ivyProfile.useLightmapping, true); } } } content = new GUIContent(" Merge Visible", iconLeaf, "Merge all visible ivy into a single ivy / single mesh. This is (usually) good for optimizing the 3D performance of your scene, especially if you have a lot of ivy everywhere."); if (GUILayout.Button(content, EditorStyles.miniButtonRight, GUILayout.Height(16))) { if (EditorUtility.DisplayDialog("Hedera: Merge All Visible Ivy Strokes", string.Format("Are you sure you want to merge {0} ivy plants into one?", visibleIvy), "YES!", "Maybe not...")) { Undo.RegisterCompleteObjectUndo(ivyBehavior, "Hedera > Merge Visible"); Undo.SetCurrentGroupName("Hedera > Merge Visible"); //var rootIvyB = IvyCore.StartDestructiveEdit(ivyBehavior, applyAllOverrides:true ); IvyCore.MergeVisibleIvyGraphs(ivyBehavior, ivyProfile); // IvyCore.CommitDestructiveEdit(); } } EditorGUILayout.EndHorizontal(); GUI.enabled = isInARealScene; if (ivyBehavior.ivyGraphs.Count == 0) { EditorGUILayout.HelpBox("To paint Ivy, first click [Start Painting Ivy]... then hold down [Left Mouse Button] on a collider in the Scene view, and drag.", MessageType.Info); } lastMeshIDs.Clear(); IvyGraph ivyGraphObjJob = null; // used to pull .OBJ export out of the for() loop var oldBGColor = GUI.backgroundColor; var pulseColor = Color.Lerp(oldBGColor, Color.yellow, Mathf.PingPong(System.Convert.ToSingle(EditorApplication.timeSinceStartup) * 2f, 1f)); for (int i = 0; i < ivyBehavior.ivyGraphs.Count; i++) { GUI.enabled = isInARealScene; var ivy = ivyBehavior.ivyGraphs[i]; if (ivy.isGrowing) { GUI.backgroundColor = pulseColor; } lastMeshIDs.Add(ivy.leafMeshID); lastMeshIDs.Add(ivy.branchMeshID); EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); GUI.backgroundColor = oldBGColor; GUI.color = ivy.isVisible ? oldColor : Color.gray; var eyeIcon = ivy.isVisible ? iconVisOn : iconVisOff; content = new GUIContent(eyeIcon, "Click to toggle visibility for this ivy plant.\n(Enable / disable the game object.)"); if (GUILayout.Button(content, EditorStyles.miniButtonLeft, GUILayout.Height(16), GUILayout.Width(24))) { ivy.isVisible = !ivy.isVisible; if (ivy.rootGO != null) { ivy.rootGO.SetActive(ivy.isVisible); } } GUI.color = oldColor; GUI.color = ivy != currentIvyGraphMove ? oldColor : Color.gray; content = new GUIContent(iconMove, "Click to start moving the seed position for this ivy plant."); if (GUILayout.Button(content, EditorStyles.miniButtonRight, GUILayout.Height(16), GUILayout.Width(24))) { if (ivy.rootGO != null) { ivy.rootGO.transform.position = ivy.seedPos; } currentIvyGraphMove = ivy == currentIvyGraphMove ? null : ivy; } GUI.color = oldColor; if (ivy.rootGO != null) { GUI.enabled = false; EditorGUILayout.ObjectField(ivy.rootGO, typeof(GameObject), true); GUI.enabled = isInARealScene; } else { string ivyLabel = string.Format( "(no mesh) {0} ivy", ivy.roots.Count, ivy.seedPos ); GUILayout.Label(ivyLabel, EditorStyles.miniLabel); } if (!ivy.isGrowing) { content = new GUIContent(iconMesh, "Make (or remake) the 3D mesh for this ivy"); if (GUILayout.Button(content, EditorStyles.miniButtonLeft, GUILayout.Width(24), GUILayout.Height(16))) { if (ivy.rootGO != null) { Undo.RegisterFullObjectHierarchyUndo(ivy.rootGO, "Hedera > Make Mesh"); } else { IvyMesh.InitOrRefreshRoot(ivy, ivyProfile); Undo.RegisterCreatedObjectUndo(ivy.rootGO, "Hedera > Make Mesh"); } IvyMesh.GenerateMesh(ivy, ivyProfile, ivyProfile.useLightmapping, true); Repaint(); } GUI.enabled = ivy.branchMF != null || ivy.leafMF != null; content = new GUIContent("OBJ", iconExport, "Export ivy mesh to .OBJ file\n(Note: .OBJs only support one UV channel so they cannot have lightmap UVs, Unity must unwrap them upon import)"); if (GUILayout.Button(content, EditorStyles.miniButtonMid, GUILayout.Width(24), GUILayout.Height(16))) { ivyGraphObjJob = ivy; } GUI.enabled = isInARealScene; content = new GUIContent(iconTrash, "Delete this ivy as well as its mesh objects."); if (GUILayout.Button(content, EditorStyles.miniButtonRight, GUILayout.Width(24), GUILayout.Height(16))) { if (ivy.rootGO != null) { IvyCore.DestroyObject(ivy.rootGO); } IvyCore.TryToDestroyMeshes(ivyBehavior, ivy); Undo.RegisterCompleteObjectUndo(ivyBehavior, "Hedera > Delete Ivy"); ivyBehavior.ivyGraphs.Remove(ivy); EditorGUILayout.EndHorizontal(); i--; continue; } } else { if (GUILayout.Button("Stop Growing", EditorStyles.miniButton)) { ivy.isGrowing = false; } } EditorGUILayout.EndHorizontal(); } if (ivyBehavior.ivyGraphs.Where(ivy => ivy.isGrowing).Count() > 0) { EditorGUILayout.Space(); GUI.color = pulseColor; if (GUILayout.Button("Stop All Growing")) { IvyCore.ForceStopGrowing(); } GUI.color = oldColor; } GUI.enabled = true; EditorGUILayout.Space(); content = new GUIContent("Debug Color", "When ivy doesn't have a mesh, Hedera will visualize the ivy structure as a debug wireframe with this color in the Scene view."); ivyBehavior.debugColor = EditorGUILayout.ColorField(content, ivyBehavior.debugColor); EditorGUILayout.Space(); // was getting GUI errors doing OBJ export inline, so let's do it outside of the for() loop /* * if ( ivyGraphObjJob != null) { * var filename = ObjExport.SaveObjFile( new GameObject[] { ivyGraphObjJob.rootGO }, true ); * if ( isInARealScene * && !string.IsNullOrEmpty(filename) * && filename.StartsWith(Application.dataPath) * && AssetDatabase.IsMainAssetAtPathLoaded("Assets" + filename.Substring( Application.dataPath.Length )) * ) { * int choice = EditorUtility.DisplayDialogComplex("Hedera: Instantiate .OBJ into scene?", "You just exported ivy into a .OBJ into your project.\nDo you want to replace the ivy with the .OBJ?", "Yes, and delete old ivy", "No, don't instantiate", "Yes, and hide old ivy"); * * if ( choice == 0 || choice == 2) { * var prefab = AssetDatabase.LoadAssetAtPath<Object>( "Assets" + filename.Substring( Application.dataPath.Length ) ); * var newObj = (GameObject)PrefabUtility.InstantiatePrefab( prefab ); * Undo.RegisterCreatedObjectUndo( newObj, "Hedera > Instantiate OBJ" ); * newObj.transform.SetParent( ivyBehavior.transform ); * newObj.transform.position = ivyGraphObjJob.seedPos; * * var renders = newObj.GetComponentsInChildren<Renderer>(); * renders[0].material = ivyProfile.branchMaterial; * if ( renders.Length > 1) { renders[1].material = ivyProfile.leafMaterial; } * * if ( choice == 0 ) { // remove old ivy * if ( ivyGraphObjJob.rootGO != null) { * IvyCore.DestroyObject( ivyGraphObjJob.rootGO ); * } * IvyCore.TryToDestroyMeshes( ivyBehavior, ivyGraphObjJob); * Undo.RegisterCompleteObjectUndo( ivyBehavior, "Hedera > Instantiate OBJ" ); * ivyBehavior.ivyGraphs.Remove(ivyGraphObjJob); * } else { // just turn off old ivy * Undo.RegisterCompleteObjectUndo( ivyBehavior, "Hedera > Instantiate OBJ" ); * ivyGraphObjJob.isVisible = false; * if ( ivyGraphObjJob.rootGO != null) { * ivyGraphObjJob.rootGO.SetActive( false ); * } * } * } * } * } */ }
private void Draw(ref float value) { if (EditorGUILayout.BeginFadeGroup(value)) { GUI.skin = ResourceLoader.Skin3; EditorGUILayout.IntField("id", NoiseManager.currLayer + 1); GUI.skin = null; GUI.skin = ResourceLoader.Skin2; for (int i = 0; i < NoiseManager.noiseLayers.Count; ++i) { if (GUILayout.Button("NoiseLayer " + (i + 1) + " ■ " + NoiseManager.noiseLayers[i].noiseData.presetName)) { NoiseManager.currLayer = i; } } GUI.skin = null; GUI.skin = ResourceLoader.Skin3; EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("+")) { NoiseManager.noiseLayers.Add(new NoiseLayer()); NoiseManager.Next(); } if (GUILayout.Button("-")) { NoiseManager.noiseLayers.RemoveAt(NoiseManager.currLayer); NoiseManager.Next(); } if (GUILayout.Button("Save")) { NoiseManager.Save(Paths.NoiseLayers + "NoiseLayerDataSaved"); } if (GUILayout.Button("Load")) { NoiseManager.Load(Paths.NoiseLayers + "NoiseLayerDataSaved"); } EditorGUILayout.EndHorizontal(); GUI.skin = null; ResetSkin(); if (NoiseManager.noiseLayers.Count != 0) { EditorGUILayout.Separator(); noiseLayer = NoiseManager.noiseLayers[NoiseManager.currLayer]; if (!dynamicUpdate) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("ApplyLayer")) { addnoise = true; } if (GUILayout.Button("ClearLayer")) { clearnoise = true; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("ApplyAllLayers")) { addnoise = true; allLayers = true; } if (GUILayout.Button("ClearAllLayers")) { clearnoise = true; allLayers = true; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); height = EditorGUILayout.Slider("Modify base height ", height, -1f, 1f); if (GUILayout.Button("Apply")) { WorldManagerInspector.worldManager.ChangeBaseHeight(height); WorldManagerInspector.worldManager.noised = true; } EditorGUILayout.EndHorizontal(); } EditorGUILayout.Separator(); EditorGUILayout.Separator(); noiseLayer.seed = EditorGUILayout.Vector2Field("Seed", noiseLayer.seed); noiseLayer.seedIgnore = EditorGUILayout.Toggle("RandSeed", noiseLayer.seedIgnore); noiseLayer.islandMode = EditorGUILayout.Toggle("IslandMode", noiseLayer.islandMode); EditorGUILayout.Separator(); EditorGUILayout.Separator(); show2 = EditorGUILayout.Foldout(show2, "NoiseData"); if (show2) { GUI.skin = null; EditorGUILayout.BeginHorizontal(); string[] noise_str = new string[3]; int[] noise_int = new int[3]; noise_str[0] = eNoise.FRACTAL.ToString(); noise_int[0] = 0; noise_str[1] = eNoise.FBM.ToString(); noise_int[1] = 1; noise_str[2] = eNoise.BILLOW.ToString(); noise_int[2] = 2; noise_selected = EditorGUILayout.IntPopup((int)(noiseLayer.noiseData.type), noise_str, noise_int); dynamicUpdate = GUILayout.Toggle(dynamicUpdate, "DynamicUpdate"); noiseLayer.noiseData.type = (eNoise)(noise_selected); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Octaves"); noiseLayer.noiseData.octaves = EditorGUILayout.IntSlider(noiseLayer.noiseData.octaves, 1, 8); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Persistence"); noiseLayer.noiseData.persistence = EditorGUILayout.Slider(noiseLayer.noiseData.persistence, 0, 2); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Lacunarity"); noiseLayer.noiseData.lacunarity = EditorGUILayout.Slider(noiseLayer.noiseData.lacunarity, 1, 15); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Frequency"); noiseLayer.noiseData.frequency = EditorGUILayout.Slider(noiseLayer.noiseData.frequency, 0, 100); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Size"); noiseLayer.noiseData.size = EditorGUILayout.Slider(noiseLayer.noiseData.size, -50, 50); EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); ResetSkin(); show = EditorGUILayout.Foldout(show, "Save/Load Presets"); if (show) { PresetHandler(); } } if (addnoise || CheckDynamicUpdate()) { if (allLayers) { for (int i = 0; i < NoiseManager.noiseLayers.Count; ++i) { manager.GenerateNoise(dynamicUpdate); NoiseManager.Next(); } allLayers = false; } else { manager.GenerateNoise(dynamicUpdate); } WorldManagerInspector.worldManager.noised = true; addnoise = false; } if (clearnoise) { if (allLayers) { foreach (NoiseLayer layer in NoiseManager.noiseLayers) { layer.noiseData.size = -1f * layer.noiseData.size; manager.GenerateNoise(dynamicUpdate); layer.noiseData.size = -1f * layer.noiseData.size; NoiseManager.Next(); } allLayers = false; } else { noiseLayer.noiseData.size = -1f * noiseLayer.noiseData.size; manager.GenerateNoise(dynamicUpdate); noiseLayer.noiseData.size = -1f * noiseLayer.noiseData.size; } WorldManagerInspector.worldManager.noised = true; clearnoise = false; } SetLastValues(); } GUI.skin = null; EditorGUILayout.Separator(); EditorGUILayout.Separator(); GUILayout.Box("", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(1) }); EditorGUILayout.Separator(); } EditorGUILayout.EndFadeGroup(); }
public override void OnInspectorGUI() { serializedObject.Update(); if (!IsDerivedSelectableHelperEditor()) { EditorGUILayout.PropertyField(m_Script); } var trans = GetTransition(m_TransitionProperty); var graphic = m_TargetGraphicProperty.objectReferenceValue as Graphic; if (graphic == null) { graphic = (target as SelectableHelper).GetComponent <Graphic>(); } var animator = (target as SelectableHelper).GetComponent <Animator>(); m_ShowColorTint.target = (!m_TransitionProperty.hasMultipleDifferentValues && trans == Button.Transition.ColorTint); m_ShowSpriteTrasition.target = (!m_TransitionProperty.hasMultipleDifferentValues && trans == Button.Transition.SpriteSwap); m_ShowAnimTransition.target = (!m_TransitionProperty.hasMultipleDifferentValues && trans == Button.Transition.Animation); EditorGUILayout.PropertyField(m_TransitionProperty); ++EditorGUI.indentLevel; { if (trans == Selectable.Transition.ColorTint || trans == Selectable.Transition.SpriteSwap) { EditorGUILayout.PropertyField(m_TargetGraphicProperty); } switch (trans) { case Selectable.Transition.ColorTint: if (graphic == null) { EditorGUILayout.HelpBox("You must have a Graphic target in order to use a color transition.", MessageType.Warning); } break; case Selectable.Transition.SpriteSwap: if (graphic as Image == null) { EditorGUILayout.HelpBox("You must have a Image target in order to use a sprite swap transition.", MessageType.Warning); } break; } if (EditorGUILayout.BeginFadeGroup(m_ShowColorTint.faded)) { EditorGUILayout.PropertyField(m_ColorBlockProperty); EditorGUILayout.Space(); } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(m_ShowSpriteTrasition.faded)) { EditorGUILayout.PropertyField(m_SpriteStateProperty); EditorGUILayout.Space(); } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(m_ShowAnimTransition.faded)) { EditorGUILayout.PropertyField(m_AnimTriggerProperty); if (animator == null || animator.runtimeAnimatorController == null) { Rect buttonRect = EditorGUILayout.GetControlRect(); buttonRect.xMin += EditorGUIUtility.labelWidth; if (GUI.Button(buttonRect, "Auto Generate Animation", EditorStyles.miniButton)) { UnityEditor.Animations.AnimatorController controller = GenerateSelectableAnimatorContoller((target as SelectableHelper).AnimationTriggers, target as SelectableHelper); if (controller != null) { if (animator == null) { animator = (target as SelectableHelper).gameObject.AddComponent <Animator>(); } UnityEditor.Animations.AnimatorController.SetAnimatorController(animator, controller); } } } } EditorGUILayout.EndFadeGroup(); } --EditorGUI.indentLevel; EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); Rect toggleRect = EditorGUILayout.GetControlRect(); toggleRect.xMin += EditorGUIUtility.labelWidth; ChildClassPropertiesGUI(); serializedObject.ApplyModifiedProperties(); }
override public void OnInspectorGUI() { serializedObject.Update(); SkeletonDataAsset asset = (SkeletonDataAsset)target; EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(spriteCollection); EditorGUILayout.PropertyField(skeletonJSON); EditorGUILayout.PropertyField(scale); if (EditorGUI.EndChangeCheck()) { if (failedSkeletonDataLatch) { failedSkeletonDataLatch = false; } if (m_previewUtility != null) { m_previewUtility.Cleanup(); m_previewUtility = null; } serializedObject.ApplyModifiedProperties(); } if (failedSkeletonDataLatch) { GUI.color = Color.red; GUILayout.Label("WARNING: Skeleton JSON and Sprite Collection Mismatch"); return; } SkeletonData skeletonData = asset.GetSkeletonData(asset.spriteCollection == null || asset.skeletonJSON == null); if (skeletonData != null) { showAnimationStateData = EditorGUILayout.Foldout(showAnimationStateData, "Animation State Data"); if (showAnimationStateData) { EditorGUILayout.PropertyField(defaultMix); // Animation names String[] animations = new String[skeletonData.Animations.Count]; for (int i = 0; i < animations.Length; i++) { animations[i] = skeletonData.Animations[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); EditorGUILayout.BeginHorizontal(); 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); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Add Mix")) { duration.arraySize++; toAnimation.arraySize++; fromAnimation.arraySize++; } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); } if (GUILayout.Button(new GUIContent("Setup Pose", SpineEditorUtilities.Icons.skeleton), GUILayout.Width(105), GUILayout.Height(18))) { StopAnimation(); m_skeletonAnimation.skeleton.SetToSetupPose(); m_requireRefresh = true; } #if UNITY_4_3 m_showAnimationList = EditorGUILayout.Foldout(m_showAnimationList, new GUIContent("Animations", SpineEditorUtilities.Icons.animationRoot)); if (m_showAnimationList) { #else m_showAnimationList.target = EditorGUILayout.Foldout(m_showAnimationList.target, new GUIContent("Animations", SpineEditorUtilities.Icons.animationRoot)); if (EditorGUILayout.BeginFadeGroup(m_showAnimationList.faded)) { #endif EditorGUILayout.LabelField("Name", "Duration"); foreach (Spine.Animation a in skeletonData.Animations) { GUILayout.BeginHorizontal(); if (m_skeletonAnimation != null && m_skeletonAnimation.state != null) { if (m_skeletonAnimation.state.GetCurrent(0) != null && m_skeletonAnimation.state.GetCurrent(0).Animation == a) { GUI.contentColor = Color.black; if (GUILayout.Button("\u25BA", GUILayout.Width(24))) { StopAnimation(); } GUI.contentColor = Color.white; } else { if (GUILayout.Button("\u25BA", GUILayout.Width(24))) { PlayAnimation(a.Name, true); } } } else { GUILayout.Label("?", GUILayout.Width(24)); } EditorGUILayout.LabelField(new GUIContent(a.Name, SpineEditorUtilities.Icons.animation), new GUIContent(a.Duration.ToString("f3") + "s" + ("(" + (Mathf.RoundToInt(a.Duration * 30)) + ")").PadLeft(12, ' '))); GUILayout.EndHorizontal(); } } #if !UNITY_4_3 EditorGUILayout.EndFadeGroup(); #endif } if (!Application.isPlaying) { if (serializedObject.ApplyModifiedProperties() || (UnityEngine.Event.current.type == EventType.ValidateCommand && UnityEngine.Event.current.commandName == "UndoRedoPerformed") ) { asset.Reset(); } } }
void OnGUI() { m_SelectionGameobjectWinWin.target = EditorGUILayout.ToggleLeft("选择模型制作为预制体", m_SelectionGameobjectWinWin.target); if (EditorGUILayout.BeginFadeGroup(m_SelectionGameobjectWinWin.faded)) { EditorGUI.indentLevel++; EditorGUILayout.PrefixLabel("预制体存放根路径"); m_PrefabsRootPath = EditorGUILayout.TextField(m_PrefabsRootPath ?? "Assets/Prefabs/"); EditorGUILayout.PrefixLabel("预制体存放文件夹名称"); m_PrafabsParent = EditorGUILayout.TextField(m_PrafabsParent ?? "Other"); m_SetAnimatorController = EditorGUILayout.Toggle("为该模型添加动画控制", m_SetAnimatorController); if (EditorGUILayout.BeginFadeGroup(m_SetAnimatorController == true ? 1.0f : 0)) { EditorGUILayout.PrefixLabel("动画状态机存放文件夹名称"); m_AnimatorControllerPath = EditorGUILayout.TextField(m_AnimatorControllerPath ?? "Assets/AnimatorControllers"); } EditorGUILayout.EndFadeGroup(); if (GUILayout.Button("把选择的模型制作为预制体", GUILayout.Width(200))) { if (Selection.gameObjects.Length > 0) { Debug.LogError("根据CreationPrefabTool.GetAnimationClip()适配"); Close(); } else { Debug.LogError("请选择至少大于一个模型进行预制体制作!"); Close(); } } EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); m_Win.target = EditorGUILayout.ToggleLeft("批量模型制作为预制体", m_Win.target); if (EditorGUILayout.BeginFadeGroup(m_Win.faded)) { EditorGUI.indentLevel++; EditorGUILayout.PrefixLabel("预制体存放根路径"); m_PrefabsRootPath = EditorGUILayout.TextField(m_PrefabsRootPath ?? "Assets/Prefabs/"); EditorGUILayout.PrefixLabel("模型存放根路径"); for (int i = 0; i < list.Count; i++) { EditorGUILayout.BeginHorizontal("box"); m_SetAnimatorController = EditorGUILayout.Toggle("为该模型添加动画控制", m_SetAnimatorController); if (EditorGUILayout.BeginFadeGroup(m_SetAnimatorController == true ? 1.0f : 0)) { EditorGUILayout.PrefixLabel("动画状态机存放文件夹名称"); m_AnimatorControllerPath = EditorGUILayout.TextField(m_AnimatorControllerPath ?? "Assets/AnimatorControllers"); } EditorGUILayout.EndFadeGroup(); list[i] = EditorGUILayout.TextField(list[i]); if (GUILayout.Button("Remove", GUILayout.Width(70))) { list.RemoveAt(i); } EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("Add", GUILayout.Width(200))) { list.Add(""); } if (GUILayout.Button("批量制作预制体", GUILayout.Width(200))) { CreationPrefabTool.MyCreationPrefab(list, m_PrefabsRootPath, m_SetAnimatorController, m_AnimatorControllerPath); } EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); }
public static bool SerializeJBehaviourType(AnimBool[] fadeGroup, ILTypeInstance instance) { //如果JBehaviour var jBehaviourType = Init.Appdomain.LoadedTypes["JEngine.Core.JBehaviour"]; var t = instance.Type.ReflectionType; if (t.IsSubclassOf(jBehaviourType.ReflectionType)) { var f = t.GetField("_instanceID", BindingFlags.NonPublic); if (!(f is null)) { GUI.enabled = false; var id = f.GetValue(instance).ToString(); EditorGUILayout.TextField("InstanceID", id); GUI.enabled = true; } string frameModeStr = "FrameMode"; string frequencyStr = "Frequency"; string pausedStr = "Paused"; string totalTimeStr = "TotalTime"; string loopDeltaTimeStr = "LoopDeltaTime"; string loopCountsStr = "LoopCounts"; string timeScaleStr = "TimeScale"; fadeGroup[0].target = EditorGUILayout.Foldout(fadeGroup[0].target, "JBehaviour Stats", true); if (EditorGUILayout.BeginFadeGroup(fadeGroup[0].faded)) { var fm = t.GetField(frameModeStr, BindingFlags.Public); bool frameMode = !(fm is null) && EditorGUILayout.Toggle(frameModeStr, (bool)fm.GetValue(instance)); fm?.SetValue(instance, frameMode); var fq = t.GetField(frequencyStr, BindingFlags.Public); if (!(fq is null)) { int frequency = EditorGUILayout.IntField(frequencyStr, (int)fq.GetValue(instance)); fq.SetValue(instance, frequency); } GUI.enabled = false; var paused = t.GetField(pausedStr, BindingFlags.NonPublic); if (!(paused is null)) { EditorGUILayout.Toggle(pausedStr, (bool)paused.GetValue(instance)); } var totalTime = t.GetField(totalTimeStr, BindingFlags.Public); if (!(totalTime is null)) { EditorGUILayout.FloatField(totalTimeStr, (float)totalTime.GetValue(instance)); } var loopDeltaTime = t.GetField(loopDeltaTimeStr, BindingFlags.Public); if (!(loopDeltaTime is null)) { EditorGUILayout.FloatField(loopDeltaTimeStr, (float)loopDeltaTime.GetValue(instance)); } var loopCounts = t.GetField(loopCountsStr, BindingFlags.Public); if (!(loopCounts is null)) { EditorGUILayout.LongField(loopCountsStr, (long)loopCounts.GetValue(instance)); } GUI.enabled = true; var timeScale = t.GetField(timeScaleStr, BindingFlags.Public); if (!(timeScale is null)) { var ts = EditorGUILayout.FloatField(timeScaleStr, (float)timeScale.GetValue(instance)); timeScale.SetValue(instance, ts); } } EditorGUILayout.EndFadeGroup(); if (instance.Type.FieldMapping.Count > 0) { EditorGUILayout.Space(10); EditorGUILayout.HelpBox(String.Format(Setting.GetString(SettingString.MemberVariables), t.Name), MessageType.Info); } return(true); } return(false); }
public override void OnInspectorGUI() { if (ExtraRenderFrames > 0 && !Application.isPlaying) { ExtraRenderFrames -= 1; if (ExtraRenderFrames > 2) { UnityEditorInternal.InternalEditorUtility.RepaintAllViews(); } } else { if (ExtraRenderFrames <= 0) { ExtraRenderFrames = 70; } } if (toggles == null) { toggles = new GUIStyle(EditorStyles.layerMaskField); toggles.fontStyle = FontStyle.Bold; toggles.alignment = TextAnchor.MiddleCenter; toggles.fixedHeight += 5; toggles.fontSize = 12; } serializedObject.Update(); EditorGUILayout.HelpBox("You can override the settings for this light by toggling the checkmark next to each variables, It will use that value instead of the one set on the camera.", MessageType.Info); if (GUILayout.Button("Light Settings", toggles)) { m_ShowLightSettings.target = !m_ShowLightSettings.target; } if (EditorGUILayout.BeginFadeGroup(m_ShowLightSettings.faded)) { EditorGUILayout.PropertyField(ExtraDensity); CustomField(CustomColor, Color); CustomField(CustomIntensity, Intensity); EditorGUILayout.PropertyField(Shadows); CustomField(CustomStrength, Strength); EditorGUILayout.PropertyField(NearPlane); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.Space(); if (GUILayout.Button("Light Scattering", toggles)) { m_ShowLighting.target = !m_ShowLighting.target; } if (EditorGUILayout.BeginFadeGroup(m_ShowLighting.faded)) { CustomField(CustomDensity, Density); CustomField(CustomMieScatter, MieScattering); CustomField(CustomExtinction, Extinction); CustomField(CustomSunSize, SunSize); CustomField(CustomSunBleed, SunBleed); EditorGUILayout.HelpBox("Although tempting, Modifying Density and Extintion per light can result in an inaccurate result", MessageType.Info); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.Space(); if (GUILayout.Button("Tint", toggles)) { m_ShowAmbient.target = !m_ShowAmbient.target; } if (EditorGUILayout.BeginFadeGroup(m_ShowAmbient.faded)) { CustomField(CustomTintMode, TintMode); CustomField(CustomTintColor, TintColor); CustomField(CustomTintColor2, TintColor2); CustomField(CustomTintGradient, TintGradient); CustomField(CustomTintIntensity, TintIntensity); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.Space(); if (GUILayout.Button("Fog Height", toggles)) { m_ShowFog.target = !m_ShowFog.target; } if (EditorGUILayout.BeginFadeGroup(m_ShowFog.faded)) { CustomField(CustomFogHeightEnabled, FogHeightEnabled); CustomField(CustomFogHeight, FogHeight); CustomField(CustomFogTransitionSize, FogTransitionSize); CustomField(CustomAboveFogPercent, AboveFogPercent); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.Space(); if (GUILayout.Button("Noise", toggles)) { m_ShowNoise.target = !m_ShowNoise.target; } if (EditorGUILayout.BeginFadeGroup(m_ShowNoise.faded)) { CustomField(CustomNoiseEnabled, NoiseEnabled); CustomField(CustomNoiseTexture, noiseTexture); CustomField(CustomNoiseContrast, NoiseContrast); CustomField(CustomNoiseScale, NoiseScale); CustomField(CustomNoiseVelocity, NoiseVelocity); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.Space(); if (GUILayout.Button("General Settings", toggles)) { m_ShowGeneral.target = !m_ShowGeneral.target; } if (EditorGUILayout.BeginFadeGroup(m_ShowGeneral.faded)) { CustomField(CustomSampleCount, SampleCount); CustomField(CustomMaxLightDistance, MaxLightDistance); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.Space(); serializedObject.ApplyModifiedProperties(); }
protected void DrawBaseInspector() { if (string.IsNullOrEmpty(this.m_ItemName.stringValue)) { EditorGUILayout.HelpBox("Name field can't be empty. Please enter a unique name.", MessageType.Error); } else if (InventorySystemEditor.instance != null && InventorySystemEditor.Database.items.Any(x => !x.Equals(target) && x.Name == (target as Item).Name)) { EditorGUILayout.HelpBox("Duplicate name. Item names need to be unique.", MessageType.Error); } EditorGUILayout.PropertyField(this.m_ItemName, new GUIContent("Name")); EditorGUILayout.PropertyField(this.m_UseItemNameAsDisplayName, new GUIContent("Use name as display name")); this.m_ShowItemDisplayNameOptions.target = !this.m_UseItemNameAsDisplayName.boolValue; if (EditorGUILayout.BeginFadeGroup(this.m_ShowItemDisplayNameOptions.faded)) { EditorGUI.indentLevel = EditorGUI.indentLevel + 1; EditorGUILayout.PropertyField(this.m_ItemDisplayName); EditorGUI.indentLevel = EditorGUI.indentLevel - 1; } EditorGUILayout.EndFadeGroup(); EditorGUILayout.PropertyField(this.m_Icon); GUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(this.m_Prefab); SetupPrefab(this.m_Prefab); GUILayout.EndHorizontal(); EditorGUILayout.PropertyField(this.m_Description); EditorGUILayout.Space(); EditorGUILayout.LabelField("Properties:", EditorStyles.boldLabel); EditorGUILayout.HelpBox("Properties can be used to define item specific information like stats or any custom information you want to change and save at runtime.", MessageType.Info); this.m_PropertyList.elementHeight = this.m_PropertyList.count == 0 ? (EditorGUIUtility.singleLineHeight + 4f) : (EditorGUIUtility.singleLineHeight + 4f) * 3; this.m_PropertyList.DoLayoutList(); EditorGUILayout.PropertyField(this.m_Category); EditorGUILayout.PropertyField(this.m_IsSellable); this.m_ShowSellOptions.target = this.m_IsSellable.boolValue; if (EditorGUILayout.BeginFadeGroup(this.m_ShowSellOptions.faded)) { EditorGUI.indentLevel = EditorGUI.indentLevel + 1; EditorGUILayout.PropertyField(this.m_CanBuyBack); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(this.m_BuyPrice); EditorGUILayout.PropertyField(this.m_BuyCurrency, GUIContent.none); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(this.m_SellPrice); EditorGUILayout.PropertyField(this.m_SellCurrency, GUIContent.none); EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel = EditorGUI.indentLevel - 1; } EditorGUILayout.EndFadeGroup(); EditorGUILayout.PropertyField(this.m_Stack); if (this.m_MaxStack.intValue == 0) { EditorGUILayout.HelpBox("Maximum stack of 0 ~ unlimited", MessageType.Info); } EditorGUILayout.PropertyField(this.m_MaxStack); EditorGUILayout.PropertyField(this.m_IsDroppable); this.m_ShowDropOptions.target = this.m_IsDroppable.boolValue; if (EditorGUILayout.BeginFadeGroup(this.m_ShowDropOptions.faded)) { EditorGUI.indentLevel = EditorGUI.indentLevel + 1; EditorGUILayout.PropertyField(this.m_OverridePrefab); EditorGUILayout.PropertyField(this.m_DropSound); EditorGUI.indentLevel = EditorGUI.indentLevel - 1; } EditorGUILayout.EndFadeGroup(); EditorGUILayout.PropertyField(this.m_IsCraftable); this.m_ShowCraftOptions.target = this.m_IsCraftable.boolValue; if (EditorGUILayout.BeginFadeGroup(this.m_ShowCraftOptions.faded)) { EditorGUI.indentLevel = EditorGUI.indentLevel + 1; EditorGUILayout.PropertyField(this.m_CraftingDuration); EditorGUILayout.PropertyField(this.m_CraftingAnimatorState); EditorGUILayout.PropertyField(this.m_UseCraftingSkill); this.m_ShowSkillOptions.target = this.m_UseCraftingSkill.boolValue; if (EditorGUILayout.BeginFadeGroup(this.m_ShowSkillOptions.faded)) { EditorGUI.indentLevel = EditorGUI.indentLevel + 1; EditorGUILayout.PropertyField(this.m_SkillWindow); EditorGUILayout.PropertyField(this.m_CraftingSkill, new GUIContent("Skill")); EditorGUILayout.PropertyField(this.m_MinCraftingSkillValue, new GUIContent("Min Skill Value")); EditorGUILayout.PropertyField(this.m_RemoveIngredientsWhenFailed); EditorGUI.indentLevel = EditorGUI.indentLevel - 1; } EditorGUILayout.EndFadeGroup(); EditorGUI.indentLevel = EditorGUI.indentLevel - 1; GUILayout.Space(3f); GUILayout.BeginHorizontal(); GUILayout.Space(16f); GUILayout.BeginVertical(); EditorGUILayout.HelpBox("Crafting item modifiers can be used to randomize the item when crafting.", MessageType.Info); this.m_CraftingModifierList.DoLayoutList(); EditorGUILayout.Space(); EditorGUILayout.HelpBox("Required ingredients to craft this item.", MessageType.Info); this.m_IngredientList.DoLayoutList(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } EditorGUILayout.EndFadeGroup(); }
public override void OnInspectorGUI() { if (!metaTarget) { EditorGUILayout.HelpBox("AudioAssistant is missing", MessageType.Error); return; } main = (AudioAssistant)metaTarget; Undo.RecordObject(main, ""); main.musicVolume = EditorGUILayout.Slider("Music Volume", main.musicVolume, 0f, 1f); if (main.tracks == null) { main.tracks = new List <AudioAssistant.MusicTrack>(); } if (main.sounds == null) { main.sounds = new List <AudioAssistant.Sound>(); } #region Music Tracks tracksFade.target = GUILayout.Toggle(tracksFade.target, "Music Tracks", EditorStyles.foldout); if (EditorGUILayout.BeginFadeGroup(tracksFade.faded)) { EditorGUILayout.BeginVertical(EditorStyles.textArea); EditorGUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.Label("Name", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(100)); GUILayout.Label("Audio Clip", EditorStyles.centeredGreyMiniLabel, GUILayout.ExpandWidth(true)); EditorGUILayout.EndHorizontal(); foreach (AudioAssistant.MusicTrack track in main.tracks) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("X", GUILayout.Width(20))) { main.tracks.Remove(track); break; } track.name = EditorGUILayout.TextField(track.name, GUILayout.Width(100)); track.track = (AudioClip)EditorGUILayout.ObjectField(track.track, typeof(AudioClip), false, GUILayout.ExpandWidth(true)); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Add", GUILayout.Width(60))) { main.tracks.Add(new AudioAssistant.MusicTrack()); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } EditorGUILayout.EndFadeGroup(); #endregion #region Sounds iapsFade.target = GUILayout.Toggle(iapsFade.target, "Sounds", EditorStyles.foldout); if (EditorGUILayout.BeginFadeGroup(iapsFade.faded)) { EditorGUILayout.BeginVertical(EditorStyles.textArea); EditorGUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.Label("Edit", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(40)); GUILayout.Label("Name", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(120)); GUILayout.Label("Audio Clips", EditorStyles.centeredGreyMiniLabel, GUILayout.ExpandWidth(true)); EditorGUILayout.EndHorizontal(); foreach (AudioAssistant.Sound sound in main.sounds) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("X", GUILayout.Width(20))) { main.sounds.Remove(sound); break; } if (GUILayout.Button("Edit", GUILayout.Width(40))) { if (edit == sound) { edit = null; } else { edit = sound; } } sound.name = EditorGUILayout.TextField(sound.name, GUILayout.Width(120)); if (edit == sound || sound.clips.Count == 0) { EditorGUILayout.BeginVertical(); for (int i = 0; i < sound.clips.Count; i++) { sound.clips[i] = (AudioClip)EditorGUILayout.ObjectField(sound.clips[i], typeof(AudioClip), false, GUILayout.ExpandWidth(true)); if (sound.clips[i] == null) { sound.clips.RemoveAt(i); break; } } AudioClip new_clip = (AudioClip)EditorGUILayout.ObjectField(null, typeof(AudioClip), false, GUILayout.Width(150)); if (new_clip) { sound.clips.Add(new_clip); } EditorGUILayout.EndVertical(); } else { GUILayout.Label(sound.clips.Count.ToString() + " audio clip(s)", EditorStyles.miniBoldLabel); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Add", GUILayout.Width(60))) { main.sounds.Add(new AudioAssistant.Sound()); edit = main.sounds[main.sounds.Count - 1]; } if (GUILayout.Button("Sort", GUILayout.Width(60))) { main.sounds.Sort((AudioAssistant.Sound a, AudioAssistant.Sound b) => { return(string.Compare(a.name, b.name)); }); foreach (AudioAssistant.Sound sound in main.sounds) { sound.clips.Sort((AudioClip a, AudioClip b) => { return(string.Compare(a.ToString(), b.ToString())); }); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } EditorGUILayout.EndFadeGroup(); #endregion }
private void SectionEffects() { GUILayout.Label("Effects", "HeaderLabel"); using (MadGUI.Indent()) { FieldSmoothEffect(); burnEffectAnimBool.target = effectBurn.boolValue; MadGUI.PropertyField(effectBurn, "Burn"); if (EditorGUILayout.BeginFadeGroup(burnEffectAnimBool.faded)) { MadGUI.Indent(() => { FieldSprite(effectBurnSprite, "Bar Texture"); MadGUI.PropertyField(effectBurnSprite.FindPropertyRelative("material"), "Material"); MadGUI.PropertyFieldEnumPopup(effectBurnDirection, "Direction"); if (effectBurnDirection.enumValueIndex != (int) EnergyBarBase.BurnDirection.OnlyWhenDecreasing && !effectSmoothChange.boolValue) { if ( MadGUI.WarningFix( "Burning when increasing will be visible only if the Smooth effect is enabled.", "Enable Smooth Effect")) { effectSmoothChange.boolValue = true; } } MadGUI.PropertyField(effectSmoothChangeSpeed, "Speed"); }); EditorGUILayout.Space(); } EditorGUILayout.EndFadeGroup(); blinkEffectAnimBool.target = effectBlink.boolValue; MadGUI.PropertyField(effectBlink, "Blink"); if (EditorGUILayout.BeginFadeGroup(blinkEffectAnimBool.faded)) { MadGUI.Indent(() => { MadGUI.PropertyFieldEnumPopup(effectBlinkOperator, "Operator"); MadGUI.PropertyField(effectBlinkValue, "Value"); MadGUI.PropertyField(effectBlinkRatePerSecond, "Rate (per second)"); MadGUI.PropertyField(effectBlinkColor, "Color"); }); EditorGUILayout.Space(); } EditorGUILayout.EndFadeGroup(); tiledEffectAnimBool.target = effectTiled.boolValue; MadGUI.PropertyField(effectTiled, "Tiled"); if (EditorGUILayout.BeginFadeGroup(tiledEffectAnimBool.faded)) { MadGUI.Indent(() => { EditorGUILayout.BeginHorizontal(); MadGUI.PropertyField(effectTiledSprite, "Sprite", MadGUI.ObjectIsSet); EditorGUILayout.PropertyField(effectTiledTint, new GUIContent(""), GUILayout.Width(90)); EditorGUILayout.EndHorizontal(); EnsureSpriteRepeated(effectTiledSprite); MadGUI.PropertyFieldVector2(effectTiledTiling, "Tiling"); MadGUI.PropertyFieldVector2(effectTiledStartOffset, "Start Offset"); MadGUI.PropertyFieldVector2(effectTiledOffsetChangeSpeed, "Speed"); }); EditorGUILayout.Space(); } EditorGUILayout.EndFadeGroup(); followEffectAnimBool.target = effectFollow.boolValue; MadGUI.PropertyField(effectFollow, "Follow"); if (EditorGUILayout.BeginFadeGroup(followEffectAnimBool.faded)) { using (MadGUI.Indent()) { if (!GrowDirectionSupportedByFollowEffect()) { MadGUI.Error("This effect cannot be used with selected grow direction. " + "Please read manual for more information."); } MadGUI.PropertyField(effectFollowObject, "GameObject"); MadGUI.PropertyField(effectFollowOffset, "Position Offset"); EditorGUILayout.Space(); MadGUI.PropertyField(effectFollowColor, "Color"); MadGUI.PropertyField(effectFollowRotation, "Rotation"); if (MadGUI.Foldout("Scale", false)) { MadGUI.Indent(() => { MadGUI.PropertyField(effectFollowScaleX, "X"); MadGUI.PropertyField(effectFollowScaleY, "Y"); MadGUI.PropertyField(effectFollowScaleZ, "Z"); }); } } } EditorGUILayout.Space(); EditorGUILayout.EndFadeGroup(); } }
public static bool DrawShapeEditor(this Editor target, BlendSystem blendSystem, string[] blendables, bool useBones, bool allowCreationFromAnimClip, Shape shape, string name, int id, string invalidError = "") { bool markedForDeletion = false; // Add names if missing if (shape.blendableNames == null || shape.blendableNames.Count < shape.blendShapes.Count) { shape.blendableNames = new List <string>(); for (int i = 0; i < shape.blendShapes.Count; i++) { shape.blendableNames.Add(blendables[shape.blendShapes[i]]); } } // Create AnimBool if not defined if (!showBoneOptions.ContainsKey(target)) { showBoneOptions.Add(target, new AnimBool(useBones, target.Repaint)); } showBoneOptions[target].target = useBones; // Create styles if not defined if (lightToolbar == null) { lightToolbar = new GUIStyle(EditorStyles.toolbarDropDown); lightToolbar.normal.background = lightToolbarTexture; miniLabelDark = new GUIStyle(EditorStyles.miniLabel); miniLabelDark.normal.textColor = Color.black; } if (currentToggle == id && currentTarget == target.target) { Undo.RecordObject(target.target, "Change " + name + " Pose"); Rect box = EditorGUILayout.BeginHorizontal(); if (shape.verified) { GUI.backgroundColor = new Color(1f, 0.77f, 0f); } else { GUI.backgroundColor = new Color(0.4f, 0.4f, 0.4f); } if (GUI.Button(box, "", lightToolbar)) { currentSearchBlendable = -1; searchString = ""; currentToggle = -1; } GUI.backgroundColor = Color.white; GUILayout.Box(name, miniLabelDark, GUILayout.Width(250)); if (shape.weights.Count == 1) { GUILayout.Box("1 " + blendSystem.blendableDisplayName, miniLabelDark); } else if (shape.weights.Count > 1) { GUILayout.Box(shape.weights.Count.ToString() + " " + blendSystem.blendableDisplayNamePlural, miniLabelDark); } if (shape.bones.Count == 1 && useBones) { GUILayout.Box("1 Bone Transform", miniLabelDark); } else if (shape.bones.Count > 1 && useBones) { GUILayout.Box(shape.bones.Count.ToString() + " Bone Transforms", miniLabelDark); } if (!shape.verified) { GUILayout.FlexibleSpace(); GUILayout.Box("Missing", miniLabelDark); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); if (!shape.verified) { if (invalidError != "") { EditorGUILayout.HelpBox(invalidError, MessageType.Warning); } else { EditorGUILayout.HelpBox("There is no matching " + shape.GetType().Name + " in the project settings. It will still function correctly, but it is advised you add it to the project settings for compatibility. Alternatively, you can delete it from here.", MessageType.Warning); } if (GUILayout.Button("Delete Pose")) { markedForDeletion = true; } } box = EditorGUILayout.BeginVertical(); GUI.Box(new Rect(box.x + 4, box.y, box.width - 7, box.height), "", EditorStyles.helpBox); GUILayout.Space(20); for (int b = 0; b < shape.weights.Count; b++) { Rect newBox = EditorGUILayout.BeginHorizontal(); GUI.Box(new Rect(newBox.x + 5, newBox.y, newBox.width - 11, newBox.height), "", EditorStyles.toolbar); GUILayout.Space(5); // Check if blendables have become out-of-sync // (blend system started reporting different blendables) if (blendables[shape.blendShapes[b]] != shape.blendableNames[b] && blendSystem.allowResyncing) { bool matched = false; for (int i = 0; i < blendables.Length; i++) { if (blendables[i] == shape.blendableNames[b]) { shape.blendShapes[b] = i; matched = true; } else if (blendables[i].Remove(blendables[i].Length - 5).Contains(shape.blendableNames[b].Remove(shape.blendableNames[b].Length - 5))) { shape.blendShapes[b] = i; shape.blendableNames[b] = blendables[i]; matched = true; } } if (!matched) { shape.blendableNames[b] = blendables[shape.blendShapes[b]]; } } int oldShape = shape.blendShapes[b]; if (currentSearchBlendable == b) { searchString = EditorGUILayout.TextField("Search", searchString, EditorStyles.toolbarTextField, GUILayout.ExpandWidth(true)); if (GUILayout.Button("Search", EditorStyles.toolbarButton, GUILayout.MaxWidth(45))) { GenericMenu menu = new GenericMenu(); for (int i = 0; i < blendables.Length; i++) { if (blendables[i].ToLowerInvariant().Contains(searchString.ToLowerInvariant())) { int b2 = b; int i2 = i; menu.AddItem(new GUIContent(blendables[i2]), false, () => { if (shape.blendShapes[b2] != i2) { oldShape = shape.blendShapes[b2]; blendSystem.OnBlendableRemovedFromPose(shape.blendShapes[b2]); shape.blendShapes[b2] = i2; blendSystem.OnBlendableAddedToPose(i2); shape.blendableNames[b2] = blendables[b2]; blendSystem.SetBlendableValue(oldShape, 0); blendSystem.SetBlendableValue(i2, shape.weights[b2]); } currentSearchBlendable = -1; searchString = ""; }); } } menu.ShowAsContext(); } } else { int oldBlendable = shape.blendShapes[b]; shape.blendShapes[b] = EditorGUILayout.Popup(blendSystem.blendableDisplayName + " " + b.ToString(), shape.blendShapes[b], blendables, EditorStyles.toolbarPopup); if (oldBlendable != shape.blendShapes[b]) { blendSystem.OnBlendableRemovedFromPose(oldBlendable); blendSystem.OnBlendableAddedToPose(shape.blendShapes[b]); } } if (shape.blendShapes[b] != oldShape) { shape.blendableNames[b] = blendables[b]; blendSystem.SetBlendableValue(oldShape, 0); } if (GUILayout.Button(currentSearchBlendable == b ? list : search, EditorStyles.toolbarButton, GUILayout.MaxWidth(30))) { currentSearchBlendable = currentSearchBlendable == b ? -1 : b; } GUI.backgroundColor = new Color(0.8f, 0.3f, 0.3f); if (GUILayout.Button(delete, EditorStyles.toolbarButton, GUILayout.MaxWidth(50))) { Undo.RecordObject(target.target, "Delete " + blendSystem.blendableDisplayName); shape.blendShapes.RemoveAt(b); blendSystem.SetBlendableValue(oldShape, 0); blendSystem.OnBlendableRemovedFromPose(oldShape); selectedBone = 0; shape.weights.RemoveAt(b); shape.blendableNames.RemoveAt(b); EditorUtility.SetDirty(target.target); break; } GUILayout.Space(4); GUI.backgroundColor = Color.white; EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Space(15); shape.weights[b] = EditorGUILayout.Slider(shape.weights[b], blendSystem.blendRangeLow, blendSystem.blendRangeHigh); GUILayout.Space(10); EditorGUILayout.EndHorizontal(); GUILayout.Space(10); } if (EditorGUILayout.BeginFadeGroup(showBoneOptions[target].faded)) { for (int b = 0; b < shape.bones.Count; b++) { Rect newBox = EditorGUILayout.BeginHorizontal(); GUI.Box(new Rect(newBox.x + 5, newBox.y, newBox.width - 11, newBox.height), "", EditorStyles.toolbar); GUILayout.Space(10); bool selected = EditorGUILayout.ToggleLeft(new GUIContent("Bone Transform " + b.ToString(), EditorGUIUtility.FindTexture("Transform Icon"), "Show Transform Handles"), selectedBone == b, GUILayout.Width(170)); selectedBone = selected ? b : selectedBone; Transform oldBone = shape.bones[b].bone; shape.bones[b].bone = (Transform)EditorGUILayout.ObjectField("", shape.bones[b].bone, typeof(Transform), true); if (oldBone != shape.bones[b].bone) { if (shape.bones[b].bone != null) { Transform newbone = shape.bones[b].bone; shape.bones[b].bone = oldBone; if (shape.bones[b].bone != null) { shape.bones[b].bone.localPosition = shape.bones[b].neutralPosition; shape.bones[b].bone.localScale = shape.bones[b].neutralScale; shape.bones[b].bone.localEulerAngles = shape.bones[b].neutralRotation; } shape.bones[b].bone = newbone; shape.bones[b].SetNeutral(); shape.bones[b].endRotation = shape.bones[b].bone.localEulerAngles; shape.bones[b].endPosition = shape.bones[b].bone.localPosition; shape.bones[b].endScale = shape.bones[b].bone.localScale; shape.bones[b].bone.localPosition = shape.bones[b].endPosition; shape.bones[b].bone.localEulerAngles = shape.bones[b].endRotation; shape.bones[b].bone.localScale = shape.bones[b].endScale; } } GUI.backgroundColor = new Color(0.8f, 0.3f, 0.3f); if (GUILayout.Button(delete, EditorStyles.toolbarButton, GUILayout.MaxWidth(50))) { Undo.RecordObject(target.target, "Delete Bone Transform"); if (shape.bones[b].bone != null) { shape.bones[b].bone.localPosition = shape.bones[b].neutralPosition; shape.bones[b].bone.localEulerAngles = shape.bones[b].neutralRotation; shape.bones[b].bone.localScale = shape.bones[b].neutralScale; } shape.bones.RemoveAt(b); if (selectedBone >= shape.bones.Count) { selectedBone -= 1; } EditorUtility.SetDirty(target.target); break; } GUILayout.Space(4); GUI.backgroundColor = Color.white; EditorGUILayout.EndHorizontal(); GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); GUILayout.Space(10); GUILayout.Box("Position", EditorStyles.label, GUILayout.MaxWidth(80)); EditorGUI.BeginDisabledGroup(shape.bones[b].bone == null); EditorGUI.BeginDisabledGroup(shape.bones[b].lockPosition); Vector3 newBonePosition = EditorGUILayout.Vector3Field("", shape.bones[b].endPosition); EditorGUI.EndDisabledGroup(); GUILayout.Space(10); if (GUILayout.Button(shape.bones[b].lockPosition ? locked : unlocked, GUILayout.Width(30), GUILayout.Height(16))) { shape.bones[b].lockPosition = !shape.bones[b].lockPosition; } EditorGUI.EndDisabledGroup(); if (shape.bones[b].bone != null) { if (newBonePosition != shape.bones[b].endPosition) { Undo.RecordObject(shape.bones[b].bone, "Move"); shape.bones[b].endPosition = newBonePosition; shape.bones[b].bone.localPosition = shape.bones[b].endPosition; } else if (shape.bones[b].bone.localPosition != shape.bones[b].endPosition) { shape.bones[b].endPosition = shape.bones[b].bone.localPosition; } } GUILayout.Space(10); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Space(10); GUILayout.Box("Rotation", EditorStyles.label, GUILayout.MaxWidth(80)); EditorGUI.BeginDisabledGroup(shape.bones[b].bone == null); EditorGUI.BeginDisabledGroup(shape.bones[b].lockRotation); Vector3 newBoneRotation = EditorGUILayout.Vector3Field("", shape.bones[b].endRotation); EditorGUI.EndDisabledGroup(); GUILayout.Space(10); if (GUILayout.Button(shape.bones[b].lockRotation ? locked : unlocked, GUILayout.Width(30), GUILayout.Height(16))) { shape.bones[b].lockRotation = !shape.bones[b].lockRotation; } EditorGUI.EndDisabledGroup(); if (shape.bones[b].bone != null) { if (newBoneRotation != shape.bones[b].endRotation) { Undo.RecordObject(shape.bones[b].bone, "Rotate"); shape.bones[b].endRotation = newBoneRotation; shape.bones[b].bone.localEulerAngles = shape.bones[b].endRotation; } else if (shape.bones[b].bone.localEulerAngles != shape.bones[b].endRotation) { shape.bones[b].endRotation = shape.bones[b].bone.localEulerAngles; } } GUILayout.Space(10); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Space(10); GUILayout.Box("Scale", EditorStyles.label, GUILayout.MaxWidth(80)); EditorGUI.BeginDisabledGroup(shape.bones[b].bone == null); Vector3 newBoneScale = EditorGUILayout.Vector3Field("", shape.bones[b].endScale); EditorGUI.EndDisabledGroup(); GUILayout.Space(10); GUILayout.Button(unlocked, GUILayout.Width(30), GUILayout.Height(16)); if (shape.bones[b].bone != null) { if (newBonePosition != shape.bones[b].endScale) { Undo.RecordObject(shape.bones[b].bone, "Scale"); shape.bones[b].endScale = newBoneScale; shape.bones[b].bone.localScale = shape.bones[b].endScale; } else if (shape.bones[b].bone.localScale != shape.bones[b].endScale) { shape.bones[b].endScale = shape.bones[b].bone.localScale; } } GUILayout.Space(10); EditorGUILayout.EndHorizontal(); GUILayout.Space(10); } } FixedEndFadeGroup(showBoneOptions[target].faded); EditorGUILayout.Space(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (blendSystem.blendableCount > 0) { if (GUILayout.Button("Add " + blendSystem.blendableDisplayName, GUILayout.MaxWidth(200))) { Undo.RecordObject(target.target, "Add " + blendSystem.blendableDisplayName); shape.blendShapes.Add(0); shape.weights.Add(0); shape.blendableNames.Add(blendables[0]); blendSystem.OnBlendableAddedToPose(0); EditorUtility.SetDirty(target.target); } if (useBones) { EditorGUILayout.Space(); } } if (useBones) { if (GUILayout.Button("Add Bone Transform", GUILayout.MaxWidth(240))) { Undo.RecordObject(target.target, "Add Bone Shape"); shape.bones.Add(new BoneShape()); selectedBone = shape.bones.Count - 1; EditorUtility.SetDirty(target.target); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (allowCreationFromAnimClip) { GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Create Pose from AnimationClip", GUILayout.MaxWidth(240))) { PoseExtractorWizard.ShowWindow(blendSystem.transform, shape, name); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } } else { GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } if (blendSystem.blendableCount == 0 && !useBones) { GUILayout.BeginHorizontal(); GUILayout.Space(10); EditorGUILayout.HelpBox(blendSystem.noBlendablesMessage, MessageType.Warning); GUILayout.Space(10); GUILayout.EndHorizontal(); } GUILayout.Space(14); EditorGUILayout.EndVertical(); } else { Rect box = EditorGUILayout.BeginHorizontal(); if (shape.verified) { GUI.backgroundColor = Color.white; } else { GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f); } if (GUI.Button(box, "", EditorStyles.toolbarDropDown)) { currentToggle = id; currentTarget = target.target; selectedBone = 0; searchString = ""; currentSearchBlendable = -1; } GUILayout.Box(name, EditorStyles.miniLabel, GUILayout.Width(250)); if (shape.weights.Count == 1) { GUILayout.Box("1 " + blendSystem.blendableDisplayName, EditorStyles.miniLabel); } else if (shape.weights.Count > 1) { GUILayout.Box(shape.weights.Count.ToString() + " " + blendSystem.blendableDisplayNamePlural, EditorStyles.miniLabel); } if (shape.bones.Count == 1 && useBones) { GUILayout.Box("1 Bone Transform", EditorStyles.miniLabel); } else if (shape.bones.Count > 1 && useBones) { GUILayout.Box(shape.bones.Count.ToString() + " Bone Transforms", EditorStyles.miniLabel); } if (!shape.verified) { GUILayout.FlexibleSpace(); GUILayout.Box("Missing", EditorStyles.miniLabel); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); } return(markedForDeletion); }
protected override void OnGUI() { base.OnGUI(); EditorGUILayout.LabelField("ChangeCheck 框选中代码只有被操作后,判断内逻辑才会被执行,而不是每帧执行"); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); go = (GameObject)EditorGUILayout.ObjectField(go, typeof(GameObject), true); if (EditorGUI.EndChangeCheck()) { Debug.Log("chanegr"); } ///和上述是等价的。 using (var changerCheck = new EditorGUI.ChangeCheckScope()) { go = (GameObject)EditorGUILayout.ObjectField(go, typeof(GameObject), true); if (changerCheck.changed) { Debug.Log("use changer"); } } EditorGUILayout.LabelField("DisabledGroup"); EditorGUILayout.Space(); EditorGUI.BeginDisabledGroup(false); EditorGUILayout.LabelField("Disable false"); EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(true); EditorGUILayout.LabelField("Disable true"); EditorGUI.EndDisabledGroup(); EditorGUILayout.LabelField("FadeGroup"); EditorGUILayout.Space(); m_ShowExtraFields.target = EditorGUILayout.ToggleLeft("Show extra fields", m_ShowExtraFields.target); if (EditorGUILayout.BeginFadeGroup(m_ShowExtraFields.faded)) { EditorGUILayout.LabelField("FadeGroup"); EditorGUILayout.LabelField("FadeGroup"); EditorGUILayout.LabelField("FadeGroup"); GUILayout.Button("Btn"); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.LabelField("ToogleGroup"); EditorGUILayout.Space(); toogle = EditorGUILayout.BeginToggleGroup("ToogleGroup", toogle); EditorGUILayout.LabelField("ToogleGroup"); EditorGUILayout.LabelField("ToogleGroup"); EditorGUILayout.LabelField("ToogleGroup"); GUILayout.Button("Btn"); EditorGUILayout.EndToggleGroup(); EditorGUILayout.LabelField("BuildTargetSelectionGrouping"); EditorGUILayout.Space(); target = EditorGUILayout.BeginBuildTargetSelectionGrouping(); if (target == BuildTargetGroup.Android) { EditorGUILayout.LabelField("Android specific things"); } if (target == BuildTargetGroup.Standalone) { EditorGUILayout.LabelField("Standalone specific things"); } EditorGUILayout.EndBuildTargetSelectionGrouping(); }
public override void OnGUI(Rect position) { position = ApplySettingsPadding(position); Styles.Init(); GUILayout.BeginArea(position); { GUILayout.Label(title, Styles.TitleStyle); EditorGUIUtility.labelWidth = 250; position.x = 0; position.y = 0; EditorGUILayout.Space(); } GUILayout.EndArea(); position = ApplySettingsPadding(position); GUILayout.BeginArea(position); { hasNotRatedFadePopup.target = !hasRated; GUILayout.Space(30); //Star Bar if (EditorGUILayout.BeginFadeGroup(hasNotRatedFadePopup.faded)) { //GUILayout.FlexibleSpace(); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Label(Content.ratingPrompt, Styles.subHeadingStyle); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { //Rating selector is invisible GlobalStyles.StartColorArea(Color.clear); //Push ratings bar to middle //if (EditorGUILayout.BeginFadeGroup(hasNotRatedFadePopup.faded)) { GUILayout.FlexibleSpace(); //Ensure maximum middle-ness EditorGUILayout.IntField(0, GUILayout.MaxWidth(EditorGUIUtility.fieldWidth)); } //EditorGUILayout.EndFadeGroup(); //Rating selector EditorGUI.BeginChangeCheck(); rating = EditorGUILayout.IntSlider(rating, 1, maxRating, GUILayout.MaxWidth(starSizeFull + EditorGUIUtility.fieldWidth)); if (EditorGUI.EndChangeCheck()) { hasRated = true; } GlobalStyles.EndColorArea(); Rect lastRect = GUILayoutUtility.GetLastRect(); Rect filledStarRect = new Rect(lastRect.x, lastRect.y - (starSize / 8f), starSizeFull / (maxRating / (float)rating), starSize); Rect emptyStarRect = new Rect(filledStarRect.x + filledStarRect.width, filledStarRect.y, starSizeFull - filledStarRect.width, starSize); //Draw full stars if (!hasRated) { GUI.DrawTextureWithTexCoords( new Rect(filledStarRect.x, filledStarRect.y, starSizeFull, starSize), Styles.starEmptyTex, new Rect(0, 0, maxRating, 1)); } else if (rating < maxRating) { GlobalStyles.StartColorArea(new Color(0.2755f, 0.2755f, 0.2755f, 1)); GUI.DrawTextureWithTexCoords(filledStarRect, Styles.starFullTex, new Rect(0, 0, rating, 1)); GlobalStyles.EndColorArea(); } else { GlobalStyles.StartColorArea(new Color(1, 0.61f, 0, 1)); GUI.DrawTextureWithTexCoords(filledStarRect, Styles.starFullTex, new Rect(0, 0, rating, 1)); GlobalStyles.EndColorArea(); } if (hasRated) { //Draw empty stars GlobalStyles.StartColorArea(EditorGUIUtility.isProSkin ? Color.white : new Color(0.2755f, 0.2755f, 0.2755f, 1)); GUI.DrawTextureWithTexCoords(emptyStarRect, Styles.starEmptyTex, new Rect(0, 0, maxRating - rating, 1)); GlobalStyles.EndColorArea(); } } //if (EditorGUILayout.BeginFadeGroup(hasNotRatedFadePopup.faded)) { GUILayout.FlexibleSpace(); //} //EditorGUILayout.EndFadeGroup(); EditorGUILayout.EndHorizontal(); hasRatedFadePopup.target = hasRated; if (EditorGUILayout.BeginFadeGroup(hasRatedFadePopup.faded)) { GUILayout.Space(5); //Show the rating dialog if rating is full fadeRatingPopup.target = rating == maxRating; //Show the support dialog if rating is less than the support level fadeSupportPopup.target = rating < supportRating && hasRated; //Rating Dialog if (EditorGUILayout.BeginFadeGroup(fadeRatingPopup.faded)) { EditorGUILayout.LabelField(Content.ReviewText, Styles.feedbackLabelStyle); GlobalStyles.LayoutExternalLink(Content.RatingLinkText, Content.RatingLink); } EditorGUILayout.EndFadeGroup(); //Support dialog if (EditorGUILayout.BeginFadeGroup(fadeSupportPopup.faded)) { EditorGUILayout.LabelField(Content.SupportText, Styles.feedbackLabelStyle); GlobalStyles.LayoutExternalLink(Content.SupportLinkText, Content.s1WebsiteLink); } EditorGUILayout.EndFadeGroup(); //Feedback Email //Feedback input box GUI.enabled = !hasSubmitted; { float minHeight = EditorGUIUtility.singleLineHeight * 3; //Expand the textbox if required if ((rating == maxRating) && !String.IsNullOrEmpty(feedbackText)) { int count = feedbackText.Split('\n').Length; if (count > 3) { minHeight = count * EditorGUIUtility.singleLineHeight; } } else if ((rating < maxRating) && !String.IsNullOrEmpty(feedbackText2)) { int count = feedbackText2.Split('\n').Length; if (count > 3) { minHeight = count * EditorGUIUtility.singleLineHeight; } } if (!hasSubmitted) { if (rating < maxRating && hasRated) { feedbackText2 = EditorGUILayout.TextArea(feedbackText2, Styles.feedbackWindowStyle, GUILayout.MinHeight(minHeight)); } else { feedbackText = EditorGUILayout.TextArea(feedbackText, Styles.feedbackWindowStyle, GUILayout.MinHeight(minHeight)); } } else { EditorGUILayout.LabelField(feedbackText, Styles.feedbackWindowStyle, GUILayout.MinHeight(minHeight)); } if (!hasSubmitted && GUILayout.Button(Content.SubmitFeedback)) { if (rating < maxRating && hasRated) { feedbackText = feedbackText2; } hasSubmitted = true; StringBuilder ratingAppendBuilder = new StringBuilder(); for (int i = 0; i < maxRating; i++) { if (i < rating) { ratingAppendBuilder.Append('★'); } else { ratingAppendBuilder.Append('☆'); } } ratingAppendBuilder.Append('|').Append(String.Format( "{0}|{1}.{2}.{3} ", Application.unityVersion, GlobalPortalSettings.MAJOR_VERSION, GlobalPortalSettings.MINOR_VERSION, GlobalPortalSettings.PATCH_VERSION)); ratingAppendBuilder.Append('|').Append(SKSGlobalRenderSettings.Instance.ToString()); ratingAppendBuilder.Append('|').Append(GlobalPortalSettings.Instance.ToString()); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", SystemInfo.deviceUniqueIdentifier)); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", SystemInfo.graphicsDeviceName)); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", SystemInfo.operatingSystem)); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", SystemInfo.processorType)); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", SystemInfo.systemMemorySize)); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", SystemInfo.graphicsMemorySize)); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", Application.platform)); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", EditorUserBuildSettings.activeBuildTarget)); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", PlayerSettings.stereoRenderingPath)); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", SetupUtility.projectMode.ToString())); ratingAppendBuilder.Append('|') .Append(String.Format("{0}", Application.systemLanguage)); String feedbackNext = feedbackText; feedbackNext = feedbackNext.Replace(Environment.NewLine, " "); feedbackNext = feedbackNext.Replace("\n", " "); feedbackNext = feedbackNext.Replace("|", " "); feedbackNext = feedbackNext + '|' + ratingAppendBuilder; //Queue and send IRC message (wow such technology (I swear there is a reason we're doing it this way)) TcpClient socket = new TcpClient(); Int32 port = 7000; string server = "irc.rizon.net"; String chan = "#SKSPortalKitFeedback"; socket.Connect(server, port); StreamReader input = new System.IO.StreamReader(socket.GetStream()); StreamWriter output = new System.IO.StreamWriter(socket.GetStream()); String nick = SystemInfo.deviceName; output.Write( "USER " + nick + " 0 * :" + "ChunkBuster" + "\r\n" + "NICK " + nick + "\r\n" ); output.Flush(); Thread sendMsgThread = new Thread(() => { bool joined = false; while (true) { try { String buf = input.ReadLine(); //Debug.Log(buf); if (buf == null) { //Debug.Log("Null"); return; } //Send pong reply to any ping messages if (buf.StartsWith("PING ")) { output.Write(buf.Replace("PING", "PONG") + "\r\n"); output.Flush(); } if (buf[0] != ':') { continue; } /* IRC commands come in one of these formats: * :NICK!USER@HOST COMMAND ARGS ... :DATA\r\n * :SERVER COMAND ARGS ... :DATA\r\n */ //After server sends 001 command, we can set mode to bot and join a channel if (buf.Split(' ')[1] == "001") { output.Write( "MODE " + nick + " +B\r\n" + "JOIN " + chan + "\r\n" ); output.Flush(); joined = true; continue; } if (buf.Contains("End of /NAMES list")) { String[] outputText = feedbackNext.Split('\n'); foreach (string s in outputText) { output.Write("PRIVMSG " + chan + " :" + s + "\r\n"); output.Flush(); Thread.Sleep(200); } socket.Close(); return; } } catch (Exception) { //If this doesn't function perfectly then just dispose of it, not worth possibly causing issues with clients over network issues return; } } }); sendMsgThread.Start(); } if (hasSubmitted) { GUILayout.Button(Content.SubmittedFeedback); } } GUI.enabled = true; GUILayout.Space(20); //Content submission GUILayout.Label(Content.GalleryText, Styles.subHeadingStyle); GUILayout.Label(Content.GalleryResponseText, Styles.feedbackLabelStyle); GlobalStyles.LayoutExternalLink(Content.GalleryLinkText, Content.GalleryLink); GUILayout.FlexibleSpace(); } else { GUILayout.FlexibleSpace(); } EditorGUILayout.EndFadeGroup(); GUILayout.Label(Content.supportLabel, Styles.subHeadingStyle); GlobalStyles.LayoutExternalLink(Content.s1Text, Content.s1WebsiteLink); GlobalStyles.LayoutExternalLink(Content.s2Text, Content.s2WebsiteLink); } GUILayout.EndArea(); }
public override void OnInspectorGUI() { m_TargetSerializedDOFObject.Update(); UpdateAnimBoolTargets(); EditorGUILayout.LabelField("Simulates camera lens defocus", EditorStyles.miniLabel); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(m_VisualizeBluriness); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(m_UIMode, new GUIContent("Mode")); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(m_ApertureShape); if (EditorGUILayout.BeginFadeGroup(showBlurOrientation.faded)) { EditorGUILayout.PropertyField(m_ApertureOrientation); } EditorGUILayout.EndFadeGroup(); if ((m_ApertureShape.enumValueIndex == (int)DepthOfField.ApertureShape.Circular) || (m_ApertureShape.enumValueIndex == (int)DepthOfField.ApertureShape.Hexagonal) || (m_ApertureShape.enumValueIndex == (int)DepthOfField.ApertureShape.Octogonal) ) { EditorGUILayout.Separator(); OnQualityLevelInspectorGUI(); } EditorGUILayout.Separator(); EditorGUILayout.PropertyField(m_FocusPlane); EditorGUILayout.PropertyField(m_FocusTransform, new GUIContent("Focus on Transform")); EditorGUILayout.Separator(); if (m_UIMode.enumValueIndex == (int)DepthOfField.UIMode.Basic) { EditorGUILayout.PropertyField(m_FStops, new GUIContent("F-Stops")); EditorGUILayout.PropertyField(m_FocusRange); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(m_Radius, new GUIContent("Max Blur")); m_NearRadius.floatValue = m_Radius.floatValue; m_FarRadius.floatValue = m_Radius.floatValue; m_UseBokehTexture.boolValue = false; } else { if (EditorGUILayout.BeginFadeGroup(1 - showExplicitSettings.faded)) { EditorGUILayout.Slider(m_FStops, 1.0f, 128.0f, new GUIContent("F-Stops")); EditorGUILayout.PropertyField(m_FocusRange); } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(showExplicitSettings.faded)) { EditorGUILayout.PropertyField(m_FocusRange); EditorGUILayout.PropertyField(m_NearPlane); EditorGUILayout.PropertyField(m_FarPlane); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.Separator(); OnBokehTextureInspectorGUI(); if (EditorGUILayout.BeginFadeGroup(showDX11BlurSettings.faded)) { EditorGUILayout.PropertyField(m_Radius, new GUIContent("Max Blur")); m_NearRadius.floatValue = m_Radius.floatValue; m_FarRadius.floatValue = m_Radius.floatValue; } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(1 - showDX11BlurSettings.faded)) { EditorGUILayout.PropertyField(m_NearRadius, new GUIContent("Near Max Blur")); EditorGUILayout.PropertyField(m_FarRadius, new GUIContent("Far Max Blur")); m_Radius.floatValue = (m_FarRadius.floatValue + m_NearRadius.floatValue) * 0.5f; } EditorGUILayout.EndFadeGroup(); } EditorGUILayout.Separator(); if (EditorGUILayout.BeginFadeGroup(showBoostSettings.faded)) { EditorGUILayout.PropertyField(m_BoostPoint); EditorGUILayout.PropertyField(m_NearBoostAmount); EditorGUILayout.PropertyField(m_FarBoostAmount); } EditorGUILayout.EndFadeGroup(); m_TargetSerializedDOFObject.ApplyModifiedProperties(); }
/// <summary> /// Sprites's custom properties based on the type. /// </summary> protected void TypeGUI() { EditorGUILayout.PropertyField(m_Type, m_SpriteTypeContent); ++EditorGUI.indentLevel; { var typeEnum = (YuLegoImage.Type)m_Type.enumValueIndex; bool showSlicedOrTiled = (!m_Type.hasMultipleDifferentValues && (typeEnum == YuLegoImage.Type.Sliced || typeEnum == YuLegoImage.Type.Tiled)); if (showSlicedOrTiled && targets.Length > 1) { showSlicedOrTiled = targets.Select(obj => obj as YuLegoImage).All(img => img.hasBorder); } m_ShowSlicedOrTiled.target = showSlicedOrTiled; m_ShowSliced.target = (showSlicedOrTiled && !m_Type.hasMultipleDifferentValues && typeEnum == YuLegoImage.Type.Sliced); m_ShowTiled.target = (showSlicedOrTiled && !m_Type.hasMultipleDifferentValues && typeEnum == YuLegoImage.Type.Tiled); m_ShowFilled.target = (!m_Type.hasMultipleDifferentValues && typeEnum == YuLegoImage.Type.Filled); YuLegoImage image = target as YuLegoImage; if (EditorGUILayout.BeginFadeGroup(m_ShowSlicedOrTiled.faded)) { if (image.hasBorder) { EditorGUILayout.PropertyField(m_FillCenter); } } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(m_ShowSliced.faded)) { if (image.sprite != null && !image.hasBorder) { EditorGUILayout.HelpBox("This Image doesn't have a border.", MessageType.Warning); } } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(m_ShowTiled.faded)) { if (image.sprite != null && !image.hasBorder && (image.sprite.texture.wrapMode != TextureWrapMode.Repeat || image.sprite.packed)) { EditorGUILayout.HelpBox( "It looks like you want to tile a sprite with no border. It would be more efficient to modify the Sprite properties, clear the Packing tag and set the Wrap mode to Repeat.", MessageType.Warning); } } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(m_ShowFilled.faded)) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_FillMethod); if (EditorGUI.EndChangeCheck()) { m_FillOrigin.intValue = 0; } switch ((YuLegoImage.FillMethod)m_FillMethod.enumValueIndex) { case YuLegoImage.FillMethod.Horizontal: m_FillOrigin.intValue = (int)(YuLegoImage.OriginHorizontal)EditorGUILayout.EnumPopup("Fill Origin", (YuLegoImage.OriginHorizontal)m_FillOrigin.intValue); break; case YuLegoImage.FillMethod.Vertical: m_FillOrigin.intValue = (int)(YuLegoImage.OriginVertical)EditorGUILayout.EnumPopup("Fill Origin", (YuLegoImage.OriginVertical)m_FillOrigin.intValue); break; case YuLegoImage.FillMethod.Radial90: m_FillOrigin.intValue = (int)(YuLegoImage.Origin90)EditorGUILayout.EnumPopup("Fill Origin", (YuLegoImage.Origin90)m_FillOrigin.intValue); break; case YuLegoImage.FillMethod.Radial180: m_FillOrigin.intValue = (int)(YuLegoImage.Origin180)EditorGUILayout.EnumPopup("Fill Origin", (YuLegoImage.Origin180)m_FillOrigin.intValue); break; case YuLegoImage.FillMethod.Radial360: m_FillOrigin.intValue = (int)(YuLegoImage.Origin360)EditorGUILayout.EnumPopup("Fill Origin", (YuLegoImage.Origin360)m_FillOrigin.intValue); break; } EditorGUILayout.PropertyField(m_FillAmount); if ((YuLegoImage.FillMethod)m_FillMethod.enumValueIndex > YuLegoImage.FillMethod.Vertical) { EditorGUILayout.PropertyField(m_FillClockwise, m_ClockwiseContent); } } EditorGUILayout.EndFadeGroup(); } --EditorGUI.indentLevel; }
private void OnGUI() { if (wizardData == null) { return; } if (!inited) { inited = true; biggerButton = new GUIStyle("button"); biggerButton.padding = new RectOffset(12, 12, 6, 6); urlIcon = EditorGUIUtility.IconContent("_Help"); eyeIcon = EditorGUIUtility.IconContent(EditorGUIUtility.isProSkin ? "ViewToolOrbit On" : "ViewToolOrbit"); header = new GUIStyle(EditorStyles.boldLabel); header.fontSize = 14; header.alignment = TextAnchor.MiddleCenter; questionContainer = new GUIStyle(); answer = new GUIStyle(EditorStyles.label); answer.normal.textColor = EditorStyles.label.normal.textColor; answer.wordWrap = true; answer.alignment = TextAnchor.MiddleLeft; answer.stretchWidth = false; // var c = answer.normal.textColor; // c.a = 0.8f; // answer.normal.textColor = c; answer.padding = new RectOffset(4, 4, 4, 4); message = new GUIStyle(answer); // message.normal.textColor = EditorStyles.label.normal.textColor; // message.fontSize = 12; // message.stretchWidth = true; message.alignment = TextAnchor.MiddleCenter; message.stretchWidth = true; question = new GUIStyle("box"); question.fontSize = 14; question.normal.textColor = EditorStyles.label.normal.textColor; question.font = EditorStyles.boldFont; var c = question.normal.textColor; c.a = 0.9f; question.normal.textColor = c; } void DrawButtonLinks() { EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); foreach (var wAction in wizardData.buttonLinks) { urlIcon.text = wAction.actionText; if (GUILayout.Button(urlIcon, biggerButton)) { Application.OpenURL(wAction.url); } } EditorGUILayout.EndHorizontal(); // EditorGUILayout.Space(); } scroll = EditorGUILayout.BeginScrollView(scroll, GUILayout.Width(position.width)); EditorGUILayout.Space(); EditorGUILayout.LabelField(wizardData.header, header); EditorUtils.HorizontalLine(1, header.CalcSize(new GUIContent(wizardData.header)).x); EditorGUILayout.Space(); var backgroundColor = EditorGUIUtility.isProSkin ? new Color(30 / 255f, 30 / 255f, 30 / 255f) : new Color(1f, 1f, 1f); backgroundColor.a = 0.3f; var messageRect = GUILayoutUtility.GetRect(new GUIContent(wizardData.message), message); // EditorGUILayout.LabelField(, message); EditorGUI.DrawRect(messageRect, backgroundColor); EditorGUI.LabelField(messageRect, wizardData.message, message); EditorGUILayout.Separator(); void CloseOtherGroup(WizardData.WizardActionGroup onGroup) { foreach (var group in wizardData.wizardActionGroups) { if (group != onGroup) { group.visible.target = false; } } } foreach (var group in wizardData.wizardActionGroups) { if (group.visible == null) { Refresh(); } EditorGUI.BeginChangeCheck(); group.visible.target = EditorUtils.Foldout(group.visible.target, group.groupName); if (EditorGUI.EndChangeCheck() && group.visible.target) { CloseOtherGroup(group); } if (EditorGUILayout.BeginFadeGroup(group.visible.faded)) { EditorUtils.Indent(); foreach (var action in group.actions) { EditorGUILayout.BeginVertical(questionContainer); GUILayout.Space(2); using (new EditorUtils.GUIColorScope(Color.yellow)) using (new EditorUtils.BackgroundColorScope(EditorGUIUtility.isProSkin ? Color.yellow : new Color(1, 1, 171 / 255f, 0.34f))) EditorGUILayout.LabelField($"Q: {action.question}", question); GUILayout.Space(2); var offset = question.CalcSize(new GUIContent("Q: ")); EditorGUILayout.BeginHorizontal(); GUILayout.Space(offset.x); // using (new EditorUtils.BackgroundColorScope(EditorGUIUtility.isProSkin ? Color.black : Color.white)) var answerSize = GUILayoutUtility.GetRect(new GUIContent(action.answer), answer); EditorGUI.DrawRect(answerSize, backgroundColor); // GUILayout.Label(, answer); EditorGUI.LabelField(answerSize, action.answer, answer); EditorGUILayout.EndHorizontal(); GUILayout.Space(2); if (action.wActions != null) { EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); foreach (var wAction in action.wActions) { var isUrl = !string.IsNullOrWhiteSpace(wAction.url); if (isUrl) { urlIcon.text = wAction.actionText; if (GUILayout.Button(urlIcon, biggerButton)) { Application.OpenURL(wAction.url); } } else { eyeIcon.text = wAction.actionText; if (GUILayout.Button(eyeIcon, biggerButton)) { if (!string.IsNullOrWhiteSpace(wAction.referenceAssetPath)) { if (wAction.referenceAssetPath.EndsWith(".unity")) { LoadScene(wAction.referenceAssetPath); } else { PingAsset(LoadAsset <UnityEngine.Object>(wAction.referenceAssetPath)); } } if (!string.IsNullOrWhiteSpace(wAction.referenceSceneObjectName)) { LocateGameObject(GameObject.Find(wAction.referenceSceneObjectName)); } GUIUtility.ExitGUI(); } } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); //Draw vertical line var rect = GUILayoutUtility.GetLastRect(); rect.x += 10; rect.y += offset.y + 6; rect.height -= offset.y + 6; rect.width = 2; var color = answer.normal.textColor; color.a = 0.5f; EditorGUI.DrawRect(rect, color); // EditorGUILayout.Separator(); } EditorUtils.EndIndent(); } EditorGUILayout.EndFadeGroup(); } GUILayout.FlexibleSpace(); EditorGUILayout.EndScrollView(); DrawButtonLinks(); }
public override void OnInspectorGUI() { serializedObject.Update(); base.OnInspectorGUI(); EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_TextViewport); EditorGUILayout.PropertyField(m_TextComponent); TextMeshProUGUI text = null; if (m_TextComponent != null && m_TextComponent.objectReferenceValue != null) { text = m_TextComponent.objectReferenceValue as TextMeshProUGUI; //if (text.supportRichText) //{ // EditorGUILayout.HelpBox("Using Rich Text with input is unsupported.", MessageType.Warning); //} } EditorGUI.BeginDisabledGroup(m_TextComponent == null || m_TextComponent.objectReferenceValue == null); // TEXT INPUT BOX Rect rect = EditorGUILayout.GetControlRect(false, 25); EditorGUIUtility.labelWidth = 130f; //EditorGUIUtility.fieldWidth; rect.y += 2; GUI.Label(rect, "<b>TEXT INPUT BOX</b>" + (m_foldout.textInput ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label); if (GUI.Button(new Rect(rect.x, rect.y, rect.width - 150, rect.height), GUIContent.none, GUI.skin.label)) { m_foldout.textInput = !m_foldout.textInput; } // Toggle showing Rich Tags //GUI.Label(new Rect(rect.width - 125, rect.y + 4, 125, 24), "<i>Enable RTL Editor</i>", toggleStyle); if (m_foldout.textInput) { EditorGUI.BeginChangeCheck(); m_Text.stringValue = EditorGUILayout.TextArea(m_Text.stringValue, TMP_UIStyleManager.TextAreaBoxEditor, GUILayout.Height(125), GUILayout.ExpandWidth(true)); } // INPUT FIELD SETTINGS #region INPUT FIELD SETTINGS if (GUILayout.Button("<b>INPUT FIELD SETTINGS</b>" + (m_foldout.fontSettings ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label)) { m_foldout.fontSettings = !m_foldout.fontSettings; } if (m_foldout.fontSettings) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_GlobalFontAsset, new GUIContent("Font Asset", "Set the Font Asset for both Placeholder and Input Field text object.")); if (EditorGUI.EndChangeCheck()) { TMP_InputField inputField = target as TMP_InputField; inputField.SetGlobalFontAsset(m_GlobalFontAsset.objectReferenceValue as TMP_FontAsset); } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_GlobalPointSize, new GUIContent("Point Size", "Set the point size of both Placeholder and Input Field text object.")); if (EditorGUI.EndChangeCheck()) { TMP_InputField inputField = target as TMP_InputField; inputField.SetGlobalPointSize(m_GlobalPointSize.floatValue); } EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_CharacterLimit); EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_ContentType); if (!m_ContentType.hasMultipleDifferentValues) { EditorGUI.indentLevel++; if (m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Standard || m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Autocorrected || m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Custom) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_LineType); if (EditorGUI.EndChangeCheck()) { if (text != null) { if (m_LineType.enumValueIndex == (int)TMP_InputField.LineType.SingleLine) { text.enableWordWrapping = false; } else { text.enableWordWrapping = true; } } } } if (m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Custom) { EditorGUILayout.PropertyField(m_InputType); EditorGUILayout.PropertyField(m_KeyboardType); EditorGUILayout.PropertyField(m_CharacterValidation); if (m_CharacterValidation.enumValueIndex == (int)TMP_InputField.CharacterValidation.Regex) { EditorGUILayout.PropertyField(m_RegexValue); } else if (m_CharacterValidation.enumValueIndex == (int)TMP_InputField.CharacterValidation.CustomValidator) { EditorGUILayout.PropertyField(m_InputValidator); } } EditorGUI.indentLevel--; } EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_Placeholder); EditorGUILayout.PropertyField(m_VerticalScrollbar); if (m_VerticalScrollbar.objectReferenceValue != null) { EditorGUILayout.PropertyField(m_ScrollbarScrollSensitivity); } EditorGUILayout.PropertyField(m_CaretBlinkRate); EditorGUILayout.PropertyField(m_CaretWidth); EditorGUILayout.PropertyField(m_CustomCaretColor); m_CustomColor.target = m_CustomCaretColor.boolValue; if (EditorGUILayout.BeginFadeGroup(m_CustomColor.faded)) { EditorGUILayout.PropertyField(m_CaretColor); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.PropertyField(m_SelectionColor); } #endregion // CONTROL SETTINGS #region CONTROL SETTINGS if (GUILayout.Button("<b>CONTROL SETTINGS</b>" + (m_foldout.extraSettings ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label)) { m_foldout.extraSettings = !m_foldout.extraSettings; } if (m_foldout.extraSettings) { EditorGUILayout.PropertyField(m_OnFocusSelectAll, new GUIContent("OnFocus - Select All", "Should all the text be selected when the Input Field is selected.")); EditorGUILayout.PropertyField(m_ResetOnDeActivation, new GUIContent("Reset On DeActivation", "Should the Text and Caret position be reset when Input Field is DeActivated.")); EditorGUILayout.PropertyField(m_RestoreOriginalTextOnEscape, new GUIContent("Restore On ESC Key", "Should the original text be restored when pressing ESC.")); EditorGUILayout.PropertyField(m_HideMobileInput); EditorGUILayout.PropertyField(m_ReadOnly); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(m_RichText); EditorGUIUtility.labelWidth = 140f; EditorGUILayout.PropertyField(m_RichTextEditingAllowed, new GUIContent("Allow Rich Text Editing")); EditorGUIUtility.labelWidth = 130f; EditorGUILayout.EndHorizontal(); } #endregion EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_OnValueChanged); EditorGUILayout.PropertyField(m_OnEndEdit); EditorGUILayout.PropertyField(m_OnSelect); EditorGUILayout.PropertyField(m_OnDeselect); EditorGUI.EndDisabledGroup(); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { const int fieldCount = 3; bool compiling = EditorApplication.isCompiling || EditorApplication.isUpdating; AssemblyName assemblyName = assemblyInfo.GetAssemblyName(); string versionString; bool enabled = assemblyInfo.canBeEdited && InAssetsFolder(assemblyInfo); if (!VersionsEquals(assemblyName.Version, newVersion)) { versionString = assemblyName.Version.ToString(fieldCount) + " → " + newVersion.ToString(fieldCount) + " (awaiting asset refresh)"; enabled = false; } else if (compiling) { versionString = assemblyName.Version.ToString(fieldCount) + " (awaiting compilation)"; enabled = false; } else { versionString = assemblyName.Version.ToString(fieldCount); } EditorGUILayout.Space(); EditorGUILayout.LabelField(assemblyName.Name, EditorStyles.boldLabel); GUI.enabled = enabled; string input = EditorGUILayout.DelayedTextField("Assembly Version", versionString); if (System.Version.TryParse(input, out System.Version version) && !VersionsEquals(version, assemblyName.Version)) { OverwriteAssemblyVersion(assemblyInfo, version); if (assemblyInfo.canEditMultipleScriptFiles && assemblyInfo.alsoEditsAssemblyInfos != null) { foreach (MonoScript otherAssemblyInfo in assemblyInfo.alsoEditsAssemblyInfos) { OverwriteAssemblyVersion(otherAssemblyInfo, version); } } newVersion = version; if (assemblyInfo.updatesProjectVersion) { PlayerSettings.bundleVersion = newVersion.ToString(fieldCount); } } GUI.enabled = true; if (!(assemblyInfo.canBeEdited && InAssetsFolder(assemblyInfo))) { return; } EditorGUILayout.Space(); EditorGUILayout.HelpBox("Changing above version will recompile source.", MessageType.Warning); EditorGUILayout.Space(); SerializedProperty updatesProjectVersion = serializedObject.FindProperty(nameof(AssemblyInfo.updatesProjectVersion)); EditorGUILayout.PropertyField(updatesProjectVersion, true); animBoolEditProjectSettings.target = updatesProjectVersion.boolValue; if (EditorGUILayout.BeginFadeGroup(animBoolEditProjectSettings.faded)) { GUI.enabled = false; EditorGUILayout.TextField("Project Version", Application.version); GUI.enabled = true; } EditorGUILayout.EndFadeGroup(); EditorGUILayout.Space(); SerializedProperty editsOtherScripts = serializedObject.FindProperty(nameof(AssemblyInfo.canEditMultipleScriptFiles)); EditorGUILayout.PropertyField(editsOtherScripts, true); animBoolExtraAssembliesProperty.target = editsOtherScripts.boolValue; if (EditorGUILayout.BeginFadeGroup(animBoolExtraAssembliesProperty.faded)) { SerializedProperty otherScripts = serializedObject.FindProperty(nameof(AssemblyInfo.alsoEditsAssemblyInfos)); EditorGUILayout.PropertyField(otherScripts, true); } EditorGUILayout.EndFadeGroup(); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { NVRPlayer player = (NVRPlayer)target; if (PlayerPrefs.HasKey(CheckForUpdatesKey) == false || PlayerPrefs.GetInt(CheckForUpdatesKey) != Convert.ToInt32(player.NotifyOnVersionUpdate)) { PlayerPrefs.SetInt("NewtonVRCheckForUpdates", Convert.ToInt32(player.NotifyOnVersionUpdate)); } if (hasReloaded == false) { DidReloadScripts(); } if (waitingForReload) { HasWaitedLongEnough(); } player.OculusSDKEnabled = hasOculusSDKDefine; player.SteamVREnabled = hasSteamVRDefine; bool installSteamVR = false; bool installOculusSDK = false; bool enableSteamVR = player.SteamVREnabled; bool enableOculusSDK = player.OculusSDKEnabled; EditorGUILayout.BeginHorizontal(); if (hasSteamVR == false) { using (new EditorGUI.DisabledScope(hasSteamVR == false)) { EditorGUILayout.Toggle("Enable SteamVR", player.SteamVREnabled); } installSteamVR = GUILayout.Button("Install SteamVR"); } else { enableSteamVR = EditorGUILayout.Toggle("Enable SteamVR", player.SteamVREnabled); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (hasOculusSDK == false) { using (new EditorGUI.DisabledScope(hasOculusSDK == false)) { EditorGUILayout.Toggle("Enable Oculus SDK", player.OculusSDKEnabled); } installOculusSDK = GUILayout.Button("Install Oculus SDK"); } else { enableOculusSDK = EditorGUILayout.Toggle("Enable Oculus SDK", player.OculusSDKEnabled); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.Label("Model override for all SDKs"); bool modelOverrideAll = EditorGUILayout.Toggle("Override hand models for all SDKs", player.OverrideAll); EditorGUILayout.BeginFadeGroup(1); using (new EditorGUI.DisabledScope(modelOverrideAll == false)) { player.OverrideAllLeftHand = (GameObject)EditorGUILayout.ObjectField("Left Hand", player.OverrideAllLeftHand, typeof(GameObject), false); GUILayout.BeginHorizontal(); GUILayout.Space(20); player.OverrideAllLeftHandPhysicalColliders = (GameObject) EditorGUILayout.ObjectField("Left Hand Physical Colliders", player.OverrideAllLeftHandPhysicalColliders, typeof(GameObject), false); GUILayout.EndHorizontal(); player.OverrideAllRightHand = (GameObject)EditorGUILayout.ObjectField("Right Hand", player.OverrideAllRightHand, typeof(GameObject), false); GUILayout.BeginHorizontal(); GUILayout.Space(20); player.OverrideAllRightHandPhysicalColliders = (GameObject) EditorGUILayout.ObjectField("Right Hand Physical Colliders", player.OverrideAllRightHandPhysicalColliders, typeof(GameObject), false); GUILayout.EndHorizontal(); } EditorGUILayout.EndFadeGroup(); if (modelOverrideAll) { player.OverrideOculus = false; player.OverrideSteamVR = false; } if (player.OverrideAll != modelOverrideAll) { EditorUtility.SetDirty(target); player.OverrideAll = modelOverrideAll; } GUILayout.Space(10); if (player.OculusSDKEnabled) { GUILayout.Label("Model override for Oculus SDK"); using (new EditorGUI.DisabledScope(hasOculusSDK == false)) { bool modelOverrideOculus = EditorGUILayout.Toggle("Override hand models for Oculus SDK", player.OverrideOculus); EditorGUILayout.BeginFadeGroup(Convert.ToSingle(modelOverrideOculus)); using (new EditorGUI.DisabledScope(modelOverrideOculus == false)) { player.OverrideOculusLeftHand = (GameObject) EditorGUILayout.ObjectField("Left Hand", player.OverrideOculusLeftHand, typeof(GameObject), false); GUILayout.BeginHorizontal(); GUILayout.Space(20); player.OverrideOculusLeftHandPhysicalColliders = (GameObject) EditorGUILayout.ObjectField("Left Hand Physical Colliders", player.OverrideOculusLeftHandPhysicalColliders, typeof(GameObject), false); GUILayout.EndHorizontal(); player.OverrideOculusRightHand = (GameObject) EditorGUILayout.ObjectField("Right Hand", player.OverrideOculusRightHand, typeof(GameObject), false); GUILayout.BeginHorizontal(); GUILayout.Space(20); player.OverrideOculusRightHandPhysicalColliders = (GameObject) EditorGUILayout.ObjectField("Right Hand Physical Colliders", player.OverrideOculusRightHandPhysicalColliders, typeof(GameObject), false); GUILayout.EndHorizontal(); } EditorGUILayout.EndFadeGroup(); if (modelOverrideOculus) { player.OverrideAll = false; } if (player.OverrideOculus != modelOverrideOculus) { EditorUtility.SetDirty(target); player.OverrideOculus = modelOverrideOculus; } } } if (player.SteamVREnabled) { GUILayout.Label("Model override for SteamVR"); using (new EditorGUI.DisabledScope(hasSteamVR == false)) { bool modelOverrideSteamVR = EditorGUILayout.Toggle("Override hand models for SteamVR", player.OverrideSteamVR); EditorGUILayout.BeginFadeGroup(Convert.ToSingle(modelOverrideSteamVR)); using (new EditorGUI.DisabledScope(modelOverrideSteamVR == false)) { player.OverrideSteamVRLeftHand = (GameObject) EditorGUILayout.ObjectField("Left Hand", player.OverrideSteamVRLeftHand, typeof(GameObject), false); GUILayout.BeginHorizontal(); GUILayout.Space(20); player.OverrideSteamVRLeftHandPhysicalColliders = (GameObject) EditorGUILayout.ObjectField("Left Hand Physical Colliders", player.OverrideSteamVRLeftHandPhysicalColliders, typeof(GameObject), false); GUILayout.EndHorizontal(); player.OverrideSteamVRRightHand = (GameObject) EditorGUILayout.ObjectField("Right Hand", player.OverrideSteamVRRightHand, typeof(GameObject), false); GUILayout.BeginHorizontal(); GUILayout.Space(20); player.OverrideSteamVRRightHandPhysicalColliders = (GameObject) EditorGUILayout.ObjectField("Right Hand Physical Colliders", player.OverrideSteamVRRightHandPhysicalColliders, typeof(GameObject), false); GUILayout.EndHorizontal(); } EditorGUILayout.EndFadeGroup(); if (modelOverrideSteamVR) { player.OverrideAll = false; } if (player.OverrideSteamVR != modelOverrideSteamVR) { EditorUtility.SetDirty(target); player.OverrideSteamVR = modelOverrideSteamVR; } } GUILayout.Space(10); } GUILayout.Space(10); if (enableSteamVR == false && player.SteamVREnabled) { RemoveDefine(SteamVRDefine); } else if (enableSteamVR && player.SteamVREnabled == false) { AddDefine(SteamVRDefine); } if (enableOculusSDK == false && player.OculusSDKEnabled) { RemoveDefine(OculusDefine); } else if (enableOculusSDK && player.OculusSDKEnabled == false) { AddDefine(OculusDefine); } if (installOculusSDK) { Application.OpenURL("https://developer3.oculus.com/downloads/game-engines/1.10.0/Oculus_Utilities_for_Unity_5/"); } if (installSteamVR) { Application.OpenURL("com.unity3d.kharma:content/32647"); } DrawDefaultInspector(); if (waitingForReload || string.IsNullOrEmpty(progressBarMessage) == false) { DisplayProgressBar(); } if (GUI.changed) { if (Application.isPlaying == false) { EditorUtility.SetDirty(target); EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene()); } } }
public override void OnInspectorGUI() { serObj.Update(); UpdateAnimBoolTargets(); EditorGUILayout.LabelField("Simulates camera lens defocus", EditorStyles.miniLabel); GUILayout.Label("Focal Settings"); EditorGUILayout.PropertyField(visualizeFocus, new GUIContent(" Visualize")); EditorGUILayout.PropertyField(focalTransform, new GUIContent(" Focus on Transform")); if (EditorGUILayout.BeginFadeGroup(showFocalDistance.faded)) { EditorGUILayout.PropertyField(focalLength, new GUIContent(" Focal Distance")); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.Slider(focalSize, 0.0f, 2.0f, new GUIContent(" Focal Size")); EditorGUILayout.Slider(aperture, 0.0f, 1.0f, new GUIContent(" Aperture")); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(blurType, new GUIContent("Defocus Type")); if (!(target as DepthOfField).Dx11Support() && blurType.enumValueIndex > 0) { EditorGUILayout.HelpBox("DX11 mode not supported (need shader model 5)", MessageType.Info); } if (EditorGUILayout.BeginFadeGroup(showDiscBlurSettings.faded)) { EditorGUILayout.PropertyField(blurSampleCount, new GUIContent(" Sample Count")); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.Slider(maxBlurSize, 0.1f, 2.0f, new GUIContent(" Max Blur Distance")); EditorGUILayout.PropertyField(highResolution, new GUIContent(" High Resolution")); EditorGUILayout.Separator(); EditorGUILayout.PropertyField(nearBlur, new GUIContent("Near Blur")); if (EditorGUILayout.BeginFadeGroup(showNearBlurOverlapSize.faded)) { EditorGUILayout.Slider(foregroundOverlap, 0.1f, 2.0f, new GUIContent(" Overlap Size")); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.Separator(); if (EditorGUILayout.BeginFadeGroup(showDX11BlurSettings.faded)) { GUILayout.Label("DX11 Bokeh Settings"); EditorGUILayout.PropertyField(dx11BokehTexture, new GUIContent(" Bokeh Texture")); EditorGUILayout.Slider(dx11BokehScale, 0.0f, 50.0f, new GUIContent(" Bokeh Scale")); EditorGUILayout.Slider(dx11BokehIntensity, 0.0f, 100.0f, new GUIContent(" Bokeh Intensity")); EditorGUILayout.Slider(dx11BokehThreshold, 0.0f, 1.0f, new GUIContent(" Min Luminance")); EditorGUILayout.Slider(dx11SpawnHeuristic, 0.01f, 1.0f, new GUIContent(" Spawn Heuristic")); } EditorGUILayout.EndFadeGroup(); serObj.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { LuaTarget currTarget = target as LuaTarget; if (EditorApplication.isPlaying) { EditorGUI.BeginDisabledGroup(true); } EditorGUILayout.Space(); EditorGUILayout.BeginVertical("GroupBox"); EditorGUILayout.PropertyField(serializedObject.FindProperty("luaFilename")); EditorGUILayout.BeginHorizontal(); string targetPath = currTarget.luaFilename == null ? string.Empty : LuaEnv.LuaRelativeDir + "/" + currTarget.luaFilename; string targetLuaPath = targetPath.EndsWith(".lua") ? targetPath : targetPath + ".lua"; if (targetLuaPath.StartsWith(LuaEnv.LuaRelativeDir) && targetLuaPath.Length > LuaEnv.LuaRelativeDir.Length + 1) { targetLuaPath = targetLuaPath.Substring(LuaEnv.LuaRelativeDir.Length + 1); } int prevIndex = System.Array.FindIndex(fileOptions, luaFile => luaFile == targetLuaPath); int currIndex = EditorGUILayout.Popup(prevIndex, fileOptions); if (prevIndex != currIndex) { if ((uint)currIndex < fileOptions.Length) { currTarget.luaFilename = fileOptions[currIndex]; } GUI.changed = true; } string apath = Path.Combine("Assets", targetPath); if (!apath.EndsWith(".lua")) { apath += ".lua"; } var prevAsset = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(apath); var currAsset = EditorGUILayout.ObjectField(prevAsset, typeof(UnityEngine.Object), false); if (currAsset != prevAsset) { currTarget.luaFilename = currAsset != null?AssetDatabase.GetAssetPath(currAsset).Substring(("Assets/" + LuaEnv.LuaRelativeDir + "/").Length) : string.Empty; targetPath = currTarget.luaFilename == null ? string.Empty : LuaEnv.LuaRelativeDir + "/" + currTarget.luaFilename; GUI.changed = true; } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); if (EditorApplication.isPlaying) { EditorGUI.EndDisabledGroup(); OnInspectorGUI_Playing(); return; } string path = Path.Combine(Application.dataPath, targetPath); if (!path.EndsWith(".lua")) { path += ".lua"; } if (!File.Exists(path)) { serializedObject.ApplyModifiedProperties(); if (lastPath != "" && PrefabUtility.GetPrefabType(serializedObject.targetObject) == PrefabType.Prefab) { Debug.Log("Auto save in project view 1"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } lastPath = ""; lastKeyList = null; return; } List <string> keylist = new List <string>(); List <DescriptorValue> valuelist = new List <DescriptorValue>(); var prevValues = currTarget.savedValues; var currValues = new Dictionary <string, object>(); if (lastTarget == currTarget && lastKeyList != null && lastPath != path && lastModifyTime != File.GetLastWriteTime(path)) { lastPath = path; keylist = lastKeyList; valuelist = lastValueList; } else { int originTop = 0; try { var content = File.ReadAllText(path); LuaTable argsTable = null; keylist = ParseLuaBehaviour_Begin(Utils.LuaL, path, ref originTop, ref argsTable); if (keylist == null) { ParseLuaTarget_End(Utils.LuaL, originTop); return; } var argsFieldIndex = GetFieldSourceIndex(content, LuaTarget.ArgsName); var argsFieldContent = content.Substring(argsFieldIndex.Key, argsFieldIndex.Value - argsFieldIndex.Key - 1); var orderResult = (argsFieldIndex.Key == -1 || argsFieldIndex.Value == -1) ? null : GetOrderedKey(keylist, argsFieldContent); string region = "--region"; string endRegion = "--endregion"; if (orderResult != null) { keylist = keylist.OrderBy(key => { int index; orderResult.TryGetValue(key, out index); return(index); }).ToList(); List <int> lastRegionIndexList = null; List <string> regionNameList = null; int i = 0; int len = argsFieldContent.Length; while (i < len) { int start = argsFieldContent.IndexOf(region, i); if (start < 0) { break; } int regionNameEndIndex = argsFieldContent.IndexOf('\n', start); if (regionNameEndIndex < start + region.Length + 1) { break; } int end = argsFieldContent.IndexOf(endRegion, start); if (end < 0) { break; } if (lastRegionIndexList == null) { lastRegionIndexList = new List <int>(); regionNameList = new List <string>(); } lastRegionIndexList.Add(start); lastRegionIndexList.Add(end); regionNameList.Add(argsFieldContent.Substring(start + region.Length + 1, regionNameEndIndex - start - region.Length - 1)); i = end + endRegion.Length; } if (lastRegionIndexList != null) { var keyIndexList = keylist.ConvertAll(key => { int index; orderResult.TryGetValue(key, out index); return(index); }); int currKeyIndexListIndex = 0; lastRegionList = new List <Region>(); for (int j = 0; j < lastRegionIndexList.Count; j += 2) { int start = lastRegionIndexList[j]; int end = lastRegionIndexList[j + 1]; int curr = keyIndexList[currKeyIndexListIndex]; while (curr < start) { currKeyIndexListIndex++; if (currKeyIndexListIndex >= keyIndexList.Count) { curr = -1; break; } else { curr = keyIndexList[currKeyIndexListIndex]; } } if (curr == -1) { break; } int startKeyListIndex = currKeyIndexListIndex; while (curr < end) { currKeyIndexListIndex++; if (currKeyIndexListIndex >= keyIndexList.Count) { curr = -1; break; } else { curr = keyIndexList[currKeyIndexListIndex]; } } lastRegionList.Add(new Region() { start = startKeyListIndex, end = currKeyIndexListIndex, name = regionNameList[j >> 1], fadeValue = 1f, }); if (curr == -1) { break; } } } } else { keylist.Sort(); } valuelist = ParseLuaTarget_GetValues(Utils.LuaL, argsTable, keylist); ParseLuaTarget_End(Utils.LuaL, originTop); lastKeyList = keylist; lastValueList = valuelist; lastTarget = currTarget; lastPath = path; lastModifyTime = File.GetLastWriteTime(path); regionFoldout = new Dictionary <string, bool>(); } catch (System.Exception e) { ParseLuaTarget_End(Utils.LuaL, originTop); Debug.LogError(e.Message); } } int currRegionIndex = 0; int regionNextIndex = (lastRegionList != null && lastRegionList.Count > currRegionIndex) ? lastRegionList[currRegionIndex].start : -1; bool inRegion = false; bool regionShow = true; for (int i = 0; i < keylist.Count; i++) { var key = keylist[i]; DescriptorValue value = valuelist[i]; object pv; prevValues.TryGetValue(key, out pv); if (pv != null) { if (value.v is System.Type) { if (!(pv is System.Type) && (pv.GetType() == value.v || pv.GetType().IsSubclassOf(value.v as System.Type))) { value.v = pv; } } else { if (pv.GetType() == value.v.GetType()) { value.v = pv; } } } if (regionNextIndex != -1 && i >= regionNextIndex && inRegion) { EditorGUILayout.EndFadeGroup(); EditorGUILayout.EndVertical(); currRegionIndex++; regionNextIndex = (lastRegionList != null && lastRegionList.Count > currRegionIndex) ? lastRegionList[currRegionIndex].start : -1; inRegion = false; regionShow = true; } if (regionNextIndex != -1 && i >= regionNextIndex && !inRegion) { EditorGUILayout.BeginVertical("GroupBox"); var region = lastRegionList[currRegionIndex]; regionNextIndex = region.end; inRegion = true; if (!regionFoldout.TryGetValue(region.name, out regionShow)) { regionShow = true; } EditorGUI.indentLevel++; bool currRegionShow = EditorGUILayout.Foldout(regionShow, region.name, RegionStyle); EditorGUI.indentLevel--; regionFoldout[region.name] = currRegionShow; if (currRegionShow != regionShow) { if (region.fadeAnim != null) { region.fadeAnim.valueChanged = null; } region.fadeAnim = new AnimFloat(region.fadeValue) { target = currRegionShow ? 1f : 0f, speed = 2.5f, }; var tRegion = region; var unityEvent = new UnityEvent(); unityEvent.AddListener(() => { Repaint(); if (tRegion.fadeAnim != null) { tRegion.fadeValue = tRegion.fadeAnim.value; } }); region.fadeAnim.valueChanged = unityEvent; } EditorGUILayout.BeginFadeGroup(region.fadeValue); regionShow = region.fadeValue > 0f; } if (regionShow) { currValues[key] = ShowItem(key, value.v, value.desc); } else { var type = value.v as System.Type; if (type != null) { object ret = type.IsArray ? System.Array.CreateInstance(type.GetElementType(), 0) : type.IsValueType ? System.Activator.CreateInstance(type) : null; if (ret != null && !(ret is System.Type)) { GUI.changed = true; } currValues[key] = ret; } else { currValues[key] = value.v; } } } if (inRegion) { EditorGUILayout.EndFadeGroup(); EditorGUILayout.EndVertical(); } if (GUI.changed) { currTarget.savedValues = currValues; serializedObject.ApplyModifiedProperties(); Undo.RecordObject(currTarget, "LuaTarget Value Updated"); EditorUtility.SetDirty(currTarget); if (PrefabUtility.GetPrefabType(serializedObject.targetObject) == PrefabType.Prefab) { Debug.Log("Auto save in project view 2"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } } }
/// <summary> Panel to display modifications to apply when active </summary> /// <param name="inlineHelp">Should help be displayed?</param> void ModificationsPanel(bool inlineHelp) { ++EditorGUI.indentLevel; ToggleField(EditorGUILayout.GetControlRect(), m_modClips, m_modClipsType, m_editorUtils.GetContent("mModClipsType")); m_editorUtils.InlineHelp("mModClipsType", inlineHelp); clipsVisible.target = m_modClips.boolValue; if (EditorGUILayout.BeginFadeGroup(clipsVisible.faded)) { if (m_clipsExpanded) { m_clipsReorderable.DoLayoutList(); } else { int oldIndent = EditorGUI.indentLevel; EditorGUI.indentLevel = 1; m_clipsExpanded = EditorGUILayout.Foldout(m_clipsExpanded, PropertyCount("mClips", m_clipData), true); EditorGUI.indentLevel = oldIndent; } m_editorUtils.InlineHelp("mClips", inlineHelp); int badClipCount = 0; for (int x = 0; x < m_clipData.arraySize; ++x) { AudioClip clip = m_clipData.GetArrayElementAtIndex(x).FindPropertyRelative("m_clip").objectReferenceValue as AudioClip; if (clip != null) { if (clip.loadType != AudioClipLoadType.DecompressOnLoad) { ++badClipCount; } } } if (badClipCount > 0) { EditorGUILayout.HelpBox(m_editorUtils.GetContent("InvalidClipMessage").text, MessageType.Warning, true); if (m_editorUtils.ButtonRight("InvalidClipButton")) { GUIContent progressBarContent = m_editorUtils.GetContent("InvalidClipPopup"); for (int x = 0; x < m_clipData.arraySize; ++x) { AudioClip clip = m_clipData.GetArrayElementAtIndex(x).FindPropertyRelative("m_clip").objectReferenceValue as AudioClip; EditorUtility.DisplayProgressBar(progressBarContent.text, progressBarContent.tooltip + clip.name, x / (float)badClipCount); if (clip != null) { if (clip.loadType != AudioClipLoadType.DecompressOnLoad) { AudioImporter importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(clip)) as AudioImporter; AudioImporterSampleSettings sampleSettings = importer.defaultSampleSettings; sampleSettings.loadType = AudioClipLoadType.DecompressOnLoad; importer.defaultSampleSettings = sampleSettings; if (importer.ContainsSampleSettingsOverride("Standalone")) { sampleSettings = importer.GetOverrideSampleSettings("Standalone"); sampleSettings.loadType = AudioClipLoadType.DecompressOnLoad; importer.SetOverrideSampleSettings("Standalone", sampleSettings); } importer.SaveAndReimport(); } } } EditorUtility.ClearProgressBar(); } } } EditorGUILayout.EndFadeGroup(); ToggleField(EditorGUILayout.GetControlRect(), m_modVolume, m_volume, m_editorUtils.GetContent("mVolume")); m_editorUtils.InlineHelp("mVolume", inlineHelp); ToggleField(EditorGUILayout.GetControlRect(), m_modPlaybackSpeed, m_playbackSpeed, m_editorUtils.GetContent("mPlaybackSpeed")); m_editorUtils.InlineHelp("mPlaybackSpeed", inlineHelp); ToggleField(EditorGUILayout.GetControlRect(), m_modRandomizePlaybackSpeed, m_randomizePlaybackSpeed, m_editorUtils.GetContent("mRandomizePlaybackSpeed")); m_editorUtils.InlineHelp("mRandomizePlaybackSpeed", inlineHelp); ToggleSliderRangeField(EditorGUILayout.GetControlRect(), m_modMinMaxPlaybackSpeed, m_minMaxPlaybackSpeed, m_editorUtils.GetContent("mMinMaxPlaybackSpeed"), 0.01f, 3f); m_editorUtils.InlineHelp("mMinMaxPlaybackSpeed", inlineHelp); ToggleField(EditorGUILayout.GetControlRect(), m_modDelayChance, m_delayChance, m_editorUtils.GetContent("mDelayChance")); m_editorUtils.InlineHelp("mDelayChance", inlineHelp); ToggleVector2Field(EditorGUILayout.GetControlRect(), m_modDelay, m_minMaxDelay, m_editorUtils.GetContent("mMinMaxDelay"), m_editorUtils.GetContent("mMinPrefix"), m_editorUtils.GetContent("mMaxPrefix")); m_editorUtils.InlineHelp("mMinMaxDelay", inlineHelp); ToggleField(EditorGUILayout.GetControlRect(), m_modRandomizeVolume, m_randomizeVolume, m_editorUtils.GetContent("mRandomizeVolume")); m_editorUtils.InlineHelp("mRandomizeVolume", inlineHelp); ToggleSliderRangeField(EditorGUILayout.GetControlRect(), m_modMinMaxVolume, m_minMaxVolume, m_editorUtils.GetContent("mMinMaxVolume"), 0.01f, 2f); m_editorUtils.InlineHelp("mMinMaxVolume", inlineHelp); --EditorGUI.indentLevel; }
public override void OnInspectorGUI() { serializedObject.Update(); base.OnInspectorGUI(); EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_TextViewport); EditorGUILayout.PropertyField(m_TextComponent); TextMeshProUGUI text = null; if (m_TextComponent != null && m_TextComponent.objectReferenceValue != null) { text = m_TextComponent.objectReferenceValue as TextMeshProUGUI; //if (text.supportRichText) //{ // EditorGUILayout.HelpBox("Using Rich Text with input is unsupported.", MessageType.Warning); //} } EditorGUI.BeginDisabledGroup(m_TextComponent == null || m_TextComponent.objectReferenceValue == null); // TEXT INPUT BOX Rect rect = EditorGUILayout.GetControlRect(false, 25); EditorGUIUtility.labelWidth = 130f; //EditorGUIUtility.fieldWidth; rect.y += 2; GUI.Label(rect, "<b>TEXT INPUT BOX</b>" + (m_foldout.textInput ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label); if (GUI.Button(new Rect(rect.x, rect.y, rect.width - 150, rect.height), GUIContent.none, GUI.skin.label)) { m_foldout.textInput = !m_foldout.textInput; } // Toggle showing Rich Tags //GUI.Label(new Rect(rect.width - 125, rect.y + 4, 125, 24), "<i>Enable RTL Editor</i>", toggleStyle); if (m_foldout.textInput) { EditorGUI.BeginChangeCheck(); m_Text.stringValue = EditorGUILayout.TextArea(m_Text.stringValue, TMP_UIStyleManager.TextAreaBoxEditor, GUILayout.Height(125), GUILayout.ExpandWidth(true)); } // INPUT FIELD SETTINGS if (GUILayout.Button("<b>INPUT FIELD SETTINGS</b>" + (m_foldout.fontSettings ? uiStateLabel[1] : uiStateLabel[0]), TMP_UIStyleManager.Section_Label)) { m_foldout.fontSettings = !m_foldout.fontSettings; } if (m_foldout.fontSettings) { EditorGUILayout.PropertyField(m_CharacterLimit); EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_ContentType); if (!m_ContentType.hasMultipleDifferentValues) { EditorGUI.indentLevel++; if (m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Standard || m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Autocorrected || m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Custom) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_LineType); if (EditorGUI.EndChangeCheck()) { if (text != null) { if (m_LineType.enumValueIndex == (int)TMP_InputField.LineType.SingleLine) { text.enableWordWrapping = false; } else { text.enableWordWrapping = true; } } } } if (m_ContentType.enumValueIndex == (int)TMP_InputField.ContentType.Custom) { EditorGUILayout.PropertyField(m_InputType); EditorGUILayout.PropertyField(m_KeyboardType); EditorGUILayout.PropertyField(m_CharacterValidation); } EditorGUI.indentLevel--; } EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_Placeholder); EditorGUILayout.PropertyField(m_CaretBlinkRate); EditorGUILayout.PropertyField(m_CaretWidth); EditorGUILayout.PropertyField(m_CustomCaretColor); m_CustomColor.target = m_CustomCaretColor.boolValue; if (EditorGUILayout.BeginFadeGroup(m_CustomColor.faded)) { EditorGUILayout.PropertyField(m_CaretColor); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.PropertyField(m_SelectionColor); EditorGUILayout.PropertyField(m_HideMobileInput); EditorGUILayout.PropertyField(m_ReadOnly); EditorGUILayout.PropertyField(m_RichText); } EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_OnValueChanged); EditorGUILayout.PropertyField(m_OnEndEdit); EditorGUILayout.PropertyField(m_OnFocusLost); EditorGUI.EndDisabledGroup(); serializedObject.ApplyModifiedProperties(); }
private void DrawDetails() { EditorGUILayout.BeginFadeGroup(1); EditorGUILayout.LabelField("Action Details", headerLabelStyle); EditorGUILayout.Space(); EditorGUILayout.LabelField("Full Action Path:"); if (selectedActionIndex != -1) { EditorGUILayout.LabelField(selectedAction.name); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Name:"); if (selectedActionIndex != -1) { string newName = EditorGUILayout.TextField(selectedAction.shortName); if (newName != selectedAction.shortName) { selectedAction.name = selectedAction.path + newName; } } EditorGUILayout.Space(); EditorGUILayout.LabelField("Type:"); if (selectedActionIndex != -1) { bool directionIn = selectedAction.path.IndexOf("/in/", StringComparison.CurrentCultureIgnoreCase) != -1; string[] list; if (directionIn) { list = SteamVR_Input_ActionFile_ActionTypes.listIn; } else { list = SteamVR_Input_ActionFile_ActionTypes.listOut; } int selectedType = Array.IndexOf(list, selectedAction.type); int newSelectedType = EditorGUILayout.Popup(selectedType, list); if (selectedType == -1 && newSelectedType == -1) { newSelectedType = 0; } if (selectedType != newSelectedType && newSelectedType != -1) { selectedAction.type = list[newSelectedType]; } if (selectedAction.type == SteamVR_Input_ActionFile_ActionTypes.skeleton) { string currentSkeletonPath = selectedAction.skeleton; if (string.IsNullOrEmpty(currentSkeletonPath) == false) { currentSkeletonPath = currentSkeletonPath.Replace("/", "\\"); } int selectedSkeletonType = Array.IndexOf(SteamVR_Input_ActionFile_ActionTypes.listSkeletons, currentSkeletonPath); int newSelectedSkeletonType = EditorGUILayout.Popup(selectedSkeletonType, SteamVR_Input_ActionFile_ActionTypes.listSkeletons); if (selectedSkeletonType == -1) { selectedSkeletonType = 0; } if (selectedSkeletonType != newSelectedSkeletonType && newSelectedSkeletonType != -1) { selectedAction.skeleton = SteamVR_Input_ActionFile_ActionTypes.listSkeletons[newSelectedSkeletonType].Replace("\\", "/"); } } } EditorGUILayout.Space(); EditorGUILayout.LabelField("Required:"); if (selectedActionIndex != -1) { int oldRequirement = (int)selectedAction.requirementEnum; int newRequirement = GUILayout.SelectionGrid(oldRequirement, SteamVR_Input_ActionFile_Action.requirementValues, 1, EditorStyles.radioButton); if (oldRequirement != newRequirement) { selectedAction.requirementEnum = (SteamVR_Input_ActionFile_Action_Requirements)newRequirement; } } EditorGUILayout.Space(); EditorGUILayout.LabelField("Localization:"); localizationList.DoLayoutList(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Localized String:"); if (selectedLocalizationIndex != -1) { Dictionary <string, string> localizationItems = SteamVR_Input.actionFile.localizationHelperList[selectedLocalizationIndex].items; string oldValue = ""; if (localizationItems.ContainsKey(selectedAction.name)) { oldValue = localizationItems[selectedAction.name]; } string newValue = EditorGUILayout.TextField(oldValue); if (string.IsNullOrEmpty(newValue)) { localizationItems.Remove(selectedAction.name); } else if (oldValue != newValue) { if (localizationItems.ContainsKey(selectedAction.name) == false) { localizationItems.Add(selectedAction.name, newValue); } else { localizationItems[selectedAction.name] = newValue; } } } EditorGUILayout.EndFadeGroup(); }
//検索モード void ShowInputMode() { EditorGUILayout.LabelField(GetText(100)); EditorGUILayout.LabelField(GetText(101)); EditorGUILayout.LabelField(GetText(102)); //検索名入力スペース findName = EditorGUILayout.TextField(GetText(103), findName, GUILayout.Width(position.width * 0.8f)); //検索タイプフィルタ bool refinder = false; var hasFilter = EditorGUILayout.ToggleLeft(GetText(104), hasFilterTypes.target, EditorStyles.boldLabel); if (hasFilter != hasFilterTypes.target) { refinder = true; } hasFilterTypes.target = hasFilter; if (EditorGUILayout.BeginFadeGroup(hasFilterTypes.faded)) { GUILayout.Label(GetText(105), EditorStyles.largeLabel); EditorGUILayout.BeginHorizontal(); foreach (var toggle in filterToggles) { toggle.Show(); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndFadeGroup(); //パッケージ化を含めない var ep = EditorGUILayout.ToggleLeft(GetText(108), exceptPackages); if (exceptPackages != ep) { refinder = true; exceptPackages = ep; } //検索結果表示領域 GUILayout.Label(GetText(106), EditorStyles.boldLabel); foundScroll = EditorGUILayout.BeginScrollView(foundScroll, false, true, GUILayout.Width(position.width), GUILayout.Height(position.height * 0.3f)); if (prebFindName.Equals(findName) && !refinder && !FilterToggle.isChanged) { foreach (var label in pathLabels) { label.ShowButton(); } } else { CreatePathLabel(findName); } EditorGUILayout.EndScrollView(); FilterToggle.isChanged = false; }
public override void OnInspectorGUI() { _title = new GUIStyle(GUI.skin.label) { fontSize = 16, fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleCenter, stretchWidth = true }; GUILayout.Space(10); GUILayout.Label("PARADOX ENGINE" + "\n" + "ANSWER STATE", _title); GUILayout.Space(10); EditorGUI.DrawRect(GUILayoutUtility.GetRect(100, 2), Color.black); GUILayout.Space(20); EditorGUILayout.LabelField("Info:"); GUILayout.BeginVertical("BOX"); EditorGUILayout.LabelField("\n The Answer state is one of the desitions that can be selected derived of a Question node.\n", new GUIStyle(GUI.skin.label) { wordWrap = true, fontStyle = FontStyle.Italic }); GUILayout.EndVertical(); GUILayout.Space(10); EditorGUI.BeginChangeCheck(); EditorGUILayout.LabelField(new GUIContent("Desition text:", "Text that appears on the decision button")); _node.answer = EditorGUILayout.TextField(_node.answer); GUILayout.Space(5); EditorGUILayout.LabelField(new GUIContent("Button canvas position:", "Absolute position of the button on the canvas.")); GUILayout.BeginVertical("BOX"); _node.buttonPosition.x = EditorGUILayout.FloatField(new GUIContent("X:", "X absolute value from 0 to 1, of left to right. Center is .5f"), _node.buttonPosition.x); _node.buttonPosition.y = EditorGUILayout.FloatField(new GUIContent("Y:", "Y absolute value from 0 to 1, of down to up. Center is .5f"), _node.buttonPosition.y); GUILayout.EndVertical(); if (_node.buttonPosition.x > 1) { _node.buttonPosition.x = 1; } else if (_node.buttonPosition.x < 0) { _node.buttonPosition.x = 0; } if (_node.buttonPosition.y > 1) { _node.buttonPosition.x = 1; } else if (_node.buttonPosition.y < 0) { _node.buttonPosition.y = 0; } GUILayout.Space(10); _keyBool.target = _node.customKey; _node.customKey = GUILayout.Toggle(_node.customKey, new GUIContent("Custom input key", "Use an input key to select this decision.")); if (EditorGUILayout.BeginFadeGroup(_keyBool.faded)) { GUILayout.BeginVertical("BOX"); _node.myKey = (KeyCode)EditorGUILayout.EnumFlagsField("Input key", _node.myKey); GUILayout.EndVertical(); } EditorGUILayout.EndFadeGroup(); if (EditorGUI.EndChangeCheck()) { EngineGraphUtilities.SetDirty(_node); } }
private void DrawItemFilters() { showFilters = EditorGUILayout.Foldout(showFilters, "Item Filters", true, EditorStyles.foldout); if (showFilters) { EditorGUI.indentLevel++; showCalculateFilter = EditorGUILayout.Foldout(showCalculateFilter, new GUIContent("Calculate Size Filter", "Used to filter out any RectTransforms you don't want used in the Content's size calculation and you don't want to be able to snap to."), true); if (showCalculateFilter) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(calculateFilterMode, new GUIContent()); EditorGUI.indentLevel--; addToCalculateFilter.boolValue = EditorGUILayout.ToggleLeft(new GUIContent("Add Inactive Children", "Adds inactive/disabled children to the filter."), addToCalculateFilter.boolValue); EditorGUI.indentLevel++; EditorGUILayout.EndHorizontal(); showCalculateError.target = (calculateFilterMode.enumValueIndex == (int)DirectionalScrollSnap.FilterMode.WhiteList && calculateFilter.arraySize == 0); if (EditorGUILayout.BeginFadeGroup(showCalculateError.faded)) { EditorGUILayout.HelpBox("An empty whitelist will render the Scroll Snap unable to calculate its size correctly.", MessageType.Error); } EditorGUILayout.EndFadeGroup(); for (int i = 0; i < calculateFilter.arraySize; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(calculateFilter.GetArrayElementAtIndex(i), new GUIContent()); if (GUILayout.Button("-", GUILayout.Width(20))) { calculateFilter.DeleteArrayElementAtIndex(i); } EditorGUILayout.EndHorizontal(); } if (Button("Add Child")) { calculateFilter.InsertArrayElementAtIndex(calculateFilter.arraySize); } } showSnapFilter = EditorGUILayout.Foldout(showSnapFilter, new GUIContent("Available Snaps Filter", "Used to filter out any RectTransforms you don't want to be able to snap to. If a RectTransform is filtered out in the Calculate Size Filter you cannot snap to it here even if you whitelist it."), true); if (showSnapFilter) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(snapFilterMode, new GUIContent()); EditorGUI.indentLevel--; addToSnapFilter.boolValue = EditorGUILayout.ToggleLeft(new GUIContent("Add Inactive Children", "Adds inactive/disabled children to the filter."), addToSnapFilter.boolValue); EditorGUI.indentLevel++; EditorGUILayout.EndHorizontal(); showSnapError.target = (snapFilterMode.enumValueIndex == (int)DirectionalScrollSnap.FilterMode.WhiteList && snapFilter.arraySize == 0); if (EditorGUILayout.BeginFadeGroup(showSnapError.faded)) { EditorGUILayout.HelpBox("An empty whitelist will render the Scroll Snap unable to snap to items.", MessageType.Error); } EditorGUILayout.EndFadeGroup(); for (int i = 0; i < snapFilter.arraySize; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(snapFilter.GetArrayElementAtIndex(i), new GUIContent()); if (GUILayout.Button("-", GUILayout.Width(20))) { snapFilter.DeleteArrayElementAtIndex(i); } EditorGUILayout.EndHorizontal(); } if (Button("Add Child")) { snapFilter.InsertArrayElementAtIndex(snapFilter.arraySize); } } EditorGUI.indentLevel--; } }
void OnModuleWindowCB(int id) { // something happened in the meantime? if (id >= Modules.Count || mModuleCount != Modules.Count) { return; } CGModule mod = Modules[id]; //if (LMB && Sel.SelectedModules.Count<=1) if (EV.type == EventType.MouseUp && !Sel.SelectedModules.Contains(mod)) { Sel.Select(Modules[id]); } Rect winRect = mod.Properties.Dimensions; // Draw Title Buttons // Enabled EditorGUI.BeginChangeCheck(); mod.Active = GUI.Toggle(new Rect(2, 2, 16, 16), mod.Active, ""); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(Generator); } //Edit Title & Color if (editTitleModule == mod) { GUI.SetNextControlName("editTitle" + id); mod.ModuleName = GUI.TextField(new Rect(30, 5, winRect.width - 120, 16), mod.ModuleName); mod.Properties.BackgroundColor = EditorGUI.ColorField(new Rect(winRect.width - 70, 5, 32, 16), mod.Properties.BackgroundColor); } if (GUI.Button(new Rect(winRect.width - 32, 6, 16, 16), new GUIContent(CurvyStyles.EditTexture, "Rename"), CurvyStyles.BorderlessButton)) { editTitleModule = mod; Sel.Select(mod); EditorGUI.FocusTextInControl("editTitle" + id); } // Help if (GUI.Button(new Rect(winRect.width - 16, 6, 16, 16), new GUIContent(CurvyStyles.HelpTexture, "Help"), CurvyStyles.BorderlessButton)) { var url = DTUtility.GetHelpUrl(mod); if (!string.IsNullOrEmpty(url)) { Application.OpenURL(url); } } // Check errors if (mod.CircularReferenceError) { EditorGUILayout.HelpBox("Circular Reference", MessageType.Error); } // Draw Slots DTGUI.PushColor(mod.Properties.BackgroundColor.SkinAwareColor(true)); EditorGUILayout.BeginVertical(CurvyStyles.ModuleWindowSlotBackground); DTGUI.PopColor(); OnModuleWindowSlotGUI(mod); EditorGUILayout.EndVertical(); var ed = GetModuleEditor(mod); if (ed && ed.target != null) { if (EditorGUILayout.BeginFadeGroup(mShowDebug.faded)) { ed.OnInspectorDebugGUIINTERNAL(Repaint); } EditorGUILayout.EndFadeGroup(); // Draw Module Options mod.Properties.Expanded.valueChanged.RemoveListener(Repaint); mod.Properties.Expanded.valueChanged.AddListener(Repaint); if (!CurvyProject.Instance.CGAutoModuleDetails) { mod.Properties.Expanded.target = GUILayout.Toggle(mod.Properties.Expanded.target, new GUIContent(mod.Properties.Expanded.target ? CurvyStyles.CollapseTexture : CurvyStyles.ExpandTexture, "Show Details"), EditorStyles.toolbarButton); } // === Module Details === // Handle Auto-Folding if (DTGUI.IsLayout && CurvyProject.Instance.CGAutoModuleDetails) { mod.Properties.Expanded.target = (mod == Sel.SelectedModule); } if (EditorGUILayout.BeginFadeGroup(mod.Properties.Expanded.faded)) { EditorGUIUtility.labelWidth = (mod.Properties.LabelWidth); // Draw Inspectors using Modules Background color DTGUI.PushColor(ed.Target.Properties.BackgroundColor.SkinAwareColor(true)); EditorGUILayout.BeginVertical(CurvyStyles.ModuleWindowBackground); DTGUI.PopColor(); ed.RenderGUI(true); if (ed.NeedRepaint) { mDoRepaint = true; } GUILayout.Space(2); EditorGUILayout.EndVertical(); } EditorGUILayout.EndFadeGroup(); } // Make it dragable GUI.DragWindow(new Rect(0, 0, winRect.width, CurvyStyles.ModuleWindowTitleHeight)); }
public override void OnInspectorGUI() { SetAnimBools(false); serializedObject.Update(); // Once we have a reliable way to know if the object changed, only re-cache in that case. CalculateCachedValues(); EditorGUILayout.PropertyField(m_Content); EditorGUILayout.PropertyField(m_Horizontal); EditorGUILayout.PropertyField(m_Vertical); EditorGUILayout.PropertyField(m_MovementType); EditorGUILayout.PropertyField(m_Inertia); if (EditorGUILayout.BeginFadeGroup(m_ShowDecelerationRate.faded)) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(m_DecelerationRate); EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); EditorGUILayout.PropertyField(m_ScrollSensitivity); EditorGUILayout.PropertyField(m_StickToBottom); EditorGUILayout.Space(); EditorGUILayout.PropertyField(m_Viewport); EditorGUILayout.PropertyField(m_HorizontalScrollbar); if (m_HorizontalScrollbar.objectReferenceValue && !m_HorizontalScrollbar.hasMultipleDifferentValues) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(m_HorizontalScrollbarVisibility, new GUIContent("Visibility")); if ((ScrollRect.ScrollbarVisibility)m_HorizontalScrollbarVisibility.enumValueIndex == ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport && !m_HorizontalScrollbarVisibility.hasMultipleDifferentValues) { if (m_ViewportIsNotChild || m_HScrollbarIsNotChild) { EditorGUILayout.HelpBox(s_HError, MessageType.Error); } EditorGUILayout.PropertyField(m_HorizontalScrollbarSpacing, new GUIContent("Spacing")); } EditorGUI.indentLevel--; } EditorGUILayout.PropertyField(m_VerticalScrollbar); if (m_VerticalScrollbar.objectReferenceValue && !m_VerticalScrollbar.hasMultipleDifferentValues) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(m_VerticalScrollbarVisibility, new GUIContent("Visibility")); if ((ScrollRect.ScrollbarVisibility)m_VerticalScrollbarVisibility.enumValueIndex == ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport && !m_VerticalScrollbarVisibility.hasMultipleDifferentValues) { if (m_ViewportIsNotChild || m_VScrollbarIsNotChild) { EditorGUILayout.HelpBox(s_VError, MessageType.Error); } EditorGUILayout.PropertyField(m_VerticalScrollbarSpacing, new GUIContent("Spacing")); } EditorGUI.indentLevel--; } EditorGUILayout.Space(); if (GUILayout.Button("Make Scrollbar Last Child")) { foreach (var s in serializedObject.targetObjects) { GMScrollRect scrollRect = (GMScrollRect)s; scrollRect.MakeScrollbarLastChild(); } } EditorGUILayout.PropertyField(m_OnValueChanged); serializedObject.ApplyModifiedProperties(); }