public static EnumPopup ( |
||
selected | The enum option the field shows. | |
Résultat |
void FromStateFilterInspector(TransitionProfile profile, FromStateFilter filter, ref Rect stateRect) { EGL.BeginHorizontal(); filter.type = (FromStateType)EGL.EnumPopup(filter.type, GL.Width(70)); if (filter.type == FromStateType.State) { EditorGUIUtil.AutoCompleteList(filter.stateOrTagName, allStateNames, str => filter.stateOrTagName = str, ref stateRect); } else if (filter.type == FromStateType.Tag) { EditorGUIUtil.AutoCompleteList(filter.stateOrTagName, transition.profile.tags, str => filter.stateOrTagName = str, ref stateRect); } if (filter.type == FromStateType.State) { var state = transition.profile.FindState(filter.stateOrTagName); if (state == null) { EGL.EndHorizontal(); EGL.HelpBox("No Source State", MessageType.Error); } else { List <string> portionSelections = new List <string>(); portionSelections.Add("<any>"); foreach (var p in state.allPortions) { portionSelections.Add(p.name); } var prevIndex = portionSelections.IndexOf(filter.portionName); if (prevIndex == -1) { prevIndex = 0; } prevIndex = EGL.Popup(prevIndex, portionSelections.ToArray()); filter.portionName = prevIndex == 0 ? "" : portionSelections[prevIndex]; if (GL.Button("Focus")) { Utils.FocusEditingAnimation(profile, state.stateName); } EGL.EndHorizontal(); } } else { EGL.EndHorizontal(); } }
public override void OnInspectorGUI() { var settings = (ImportSettings)target; EditorGUI.BeginChangeCheck(); using (new GL.HorizontalScope(EditorStyles.toolbar)) { GL.Label("Options"); } settings.baseName = EGL.TextField("Base Name", settings.baseName); settings.spriteTarget = EGL.TextField("Target Child Object", settings.spriteTarget); EGL.Space(); settings.ppu = EGL.IntField("Pixel Per Unit", settings.ppu); settings.alignment = (SpriteAlignment)EGL.EnumPopup("Default Align", settings.alignment); if (settings.alignment == SpriteAlignment.Custom) { settings.customPivot = EGL.Vector2Field("Custom Pivot", settings.customPivot); } settings.densePacked = EGL.Toggle("Dense Pack", settings.densePacked); settings.border = EGL.IntField("Border", settings.border); settings.automaticReimport = EGL.Toggle("Automatic Reimport", settings.automaticReimport); EGL.Space(); using (new GL.HorizontalScope(EditorStyles.toolbar)) { GL.Label("Output"); } settings.atlasOutputDirectory = PathSelection("Atlas Directory", settings.atlasOutputDirectory); settings.clipOutputDirectory = PathSelection("Anim Clip Directory", settings.clipOutputDirectory); settings.controllerPolicy = (AnimControllerOutputPolicy)EGL.EnumPopup("Anim Controller Policy", settings.controllerPolicy); if (settings.controllerPolicy == AnimControllerOutputPolicy.CreateOrOverride) { settings.animControllerOutputPath = PathSelection("Anim Controller Directory", settings.animControllerOutputPath); } if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(settings); } }
bool ShowDetailPrototype(DetailPrototype prototype, int id) { bool removeThis = false; EGL.BeginVertical(GuiUtils.Skin.box); { EGL.BeginHorizontal(); { EGL.BeginVertical(); { prototype.usePrototypeMesh = EGL.Toggle("Use Mesh", prototype.usePrototypeMesh); prototype.prototype = EGL.ObjectField(prototype.prototype, typeof(GameObject), false) as GameObject; prototype.prototypeTexture = EGL.ObjectField(prototype.prototypeTexture, typeof(Texture2D), false, GUILayout.Width(64f), GUILayout.Height(64f)) as Texture2D; } EGL.EndVertical(); EGL.BeginVertical(); { prototype.bendFactor = EGL.FloatField("Bend Factor", prototype.bendFactor); prototype.dryColor = EGL.ColorField("Dry Color", prototype.dryColor); prototype.healthyColor = EGL.ColorField("Healthy Color", prototype.healthyColor); prototype.maxHeight = EGL.FloatField("Max Height", prototype.maxHeight); prototype.minHeight = EGL.FloatField("Min Height", prototype.minHeight); prototype.maxWidth = EGL.FloatField("Max Width", prototype.maxWidth); prototype.minWidth = EGL.FloatField("Min Width", prototype.minWidth); prototype.noiseSpread = EGL.FloatField("Noise Spread", prototype.noiseSpread); prototype.renderMode = (DetailRenderMode)EGL.EnumPopup("Noise Spread", prototype.renderMode); } EGL.EndVertical(); if (GUILayout.Button("Remove", GUILayout.Width(64f), GUILayout.Height(64f))) { removeThis = true; } } EGL.EndHorizontal(); } EGL.EndVertical(); return(removeThis); }
public override void OnEditorGui() { if (gui.Button("Die")) { _PlayerOwn.networkView.RPC("Die", RPCMode.All); } if (gui.Button("WakeUp")) { _PlayerOwn.networkView.RPC("WakeUp", RPCMode.All); } CantDie = GUI.Toggle("CantDie", CantDie); hostDebug = (hostDebug)GUI.EnumPopup(hostDebug); enableZombies = GUI.Toggle("zombies", enableZombies); if (gui.Button("CreateZombie")) { InstZombie(); } //enableAutoStart = gui.Toggle("autostart", enableAutoStart); base.OnEditorGui(); }
public override void OnInspectorGUI() { if (play) { EGL.LabelField("Play mode", gm.playMode.ToString()); EGL.LabelField("Gen. seed", gm.generatorSeed.ToString()); } else { gm.playMode = (PlayMode)EGL.EnumPopup("Play mode", gm.playMode); if (gm.playMode == PlayMode.RandomDungeon) { gm.generatorSeed = EGL.DelayedIntField("Gen. seed", gm.generatorSeed); if (GL.Button("Random seed")) { gm.generatorSeed = new Random().Next(); } } } }
private void OnGUI() { UG.BeginVertical(); chosenMeshGenerationType = (MeshGenerationType)UG.EnumPopup("网格生成类型", chosenMeshGenerationType); defaultMaterial = UG.ObjectField("默认材质", defaultMaterial, typeof(Material), false) as Material; switch (chosenMeshGenerationType) { case MeshGenerationType.Plane: OnPlaneGenerationGUI(); break; case MeshGenerationType.Box: OnBoxGenerationGUI(); break; case MeshGenerationType.Slope: OnSlopeGenerationGUI(); break; case MeshGenerationType.VolumetricFluid: OnVolumetricFluidGenerationGUI(); break; default: UG.HelpBox("需要选择一种网格生成类别进行编辑!", MessageType.Warning); break; } UG.EndVertical(); }
public override void OnInspectorGUI() { field = (AsteroidField)target; EGL.LabelField("Settings", EditorStyles.boldLabel); field.hideFlags = (HideFlags)EGL.EnumPopup("Hide Flags", field.hideFlags); field.desiredAsteroids = EGL.IntField("Desired Asteroids", field.desiredAsteroids); EGL.Space(); EGL.LabelField("GameObject", EditorStyles.boldLabel); ShowGameObjectInformation(); EGL.Space(); EGL.LabelField("Radius", EditorStyles.boldLabel); ShowRadiusInfromation(); EGL.Space(); EGL.LabelField("Scale", EditorStyles.boldLabel); ShowScaleInformation(); EGL.Space(); ShowButtons(); }
public void OnGUI() { EditorGUIUtility.labelWidth = 75; if (atomMapHolder == null) { atomMapHolder = GameObject.Find("Atom Map List").transform; if (atomMapHolder == null) { GUI.Label(new Rect((position.width - 100) / 2, (position.height - 20) / 2, 100, 20), "NO ATOM MAP LIST"); return; } } if (ionMapHolder == null) { ionMapHolder = GameObject.Find("Ion Map List").transform; if (ionMapHolder == null) { GUI.Label(new Rect((position.width - 100) / 2, (position.height - 20) / 2, 100, 20), "NO ION MAP LIST"); return; } } if (atomMap == null || ionMap == null) { SetTargetMap(0); } GL.BeginHorizontal(); type = (IonType)EGL.EnumPopup("Ion Type:", type); behaviour = (IonBehaviour)EGL.EnumPopup("Behaviour:", behaviour); GL.EndHorizontal(); radiusIndex = EGL.IntSlider("Radius:", radiusIndex, 0, 500); GL.Label("Subdivision:"); subdivIndex = GL.Toolbar(subdivIndex, subdivLabels); subdivOffset = EGL.IntField("Subdiv Offset:", subdivOffset); if (behaviour == IonBehaviour.Orbit) { orbitFreq = EGL.FloatField("Orbit Speed:", orbitFreq); resetTrigger = (Atom)EGL.ObjectField("Reset Trig:", resetTrigger, typeof(Atom)); } bool prevEditingState = isEditing; GL.BeginHorizontal(); //GL.Label(""); isEditing = GL.Toggle(isEditing, "Enable/Disable Editing"); if (isEditing != prevEditingState) { ToggleEditing(isEditing); } int prevTarget = targetMapIndex; targetMapIndex = (int)Mathf.Clamp(EGL.IntField("Target Map", targetMapIndex), 0, atomMapHolder.childCount - 1); if (prevTarget != targetMapIndex) { SetTargetMap(targetMapIndex); } GL.EndHorizontal(); radius = radiusIndex * baseRadiusUnit; subdiv = subdivOptions[subdivIndex]; }
private void OnSampleSettingGUI(BuildTargetGroup platform, AudioImporterInspector.MultiValueStatus status, bool selectionContainsTrackerFile, ref AudioImporterInspector.SampleSettingProperties properties, bool disablePreloadAudioDataOption) { EditorGUI.showMixedValue = status.multiLoadType && !properties.loadTypeChanged; EditorGUI.BeginChangeCheck(); AudioClipLoadType audioClipLoadType = (AudioClipLoadType)EditorGUILayout.EnumPopup("Load Type", (Enum)properties.settings.loadType, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { properties.settings.loadType = audioClipLoadType; properties.loadTypeChanged = true; } EditorGUI.BeginDisabledGroup(disablePreloadAudioDataOption); if (disablePreloadAudioDataOption) { EditorGUILayout.Toggle("Preload Audio Data", false, new GUILayoutOption[0]); } else { EditorGUILayout.PropertyField(this.m_PreloadAudioData); } EditorGUI.EndDisabledGroup(); if (selectionContainsTrackerFile) { return; } AudioCompressionFormat[] formatsForPlatform = this.GetFormatsForPlatform(platform); EditorGUI.showMixedValue = status.multiCompressionFormat && !properties.compressionFormatChanged; EditorGUI.BeginChangeCheck(); AudioCompressionFormat compressionFormat = (AudioCompressionFormat)EditorGUILayout.IntPopup("Compression Format", (int)properties.settings.compressionFormat, Array.ConvertAll <AudioCompressionFormat, string>(formatsForPlatform, (Converter <AudioCompressionFormat, string>)(value => value.ToString())), Array.ConvertAll <AudioCompressionFormat, int>(formatsForPlatform, (Converter <AudioCompressionFormat, int>)(value => (int)value)), new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { properties.settings.compressionFormat = compressionFormat; properties.compressionFormatChanged = true; } if (this.CompressionFormatHasQuality(properties.settings.compressionFormat)) { EditorGUI.showMixedValue = status.multiQuality && !properties.qualityChanged; EditorGUI.BeginChangeCheck(); int num = EditorGUILayout.IntSlider("Quality", (int)Mathf.Clamp(properties.settings.quality * 100f, 1f, 100f), 1, 100, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { properties.settings.quality = 0.01f * (float)num; properties.qualityChanged = true; } } EditorGUI.showMixedValue = status.multiSampleRateSetting && !properties.sampleRateSettingChanged; EditorGUI.BeginChangeCheck(); AudioSampleRateSetting sampleRateSetting = (AudioSampleRateSetting)EditorGUILayout.EnumPopup("Sample Rate Setting", (Enum)properties.settings.sampleRateSetting, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { properties.settings.sampleRateSetting = sampleRateSetting; properties.sampleRateSettingChanged = true; } if (properties.settings.sampleRateSetting == AudioSampleRateSetting.OverrideSampleRate) { EditorGUI.showMixedValue = status.multiSampleRateOverride && !properties.sampleRateOverrideChanged; EditorGUI.BeginChangeCheck(); int num = EditorGUILayout.IntPopup("Sample Rate", (int)properties.settings.sampleRateOverride, AudioImporterInspector.Styles.kSampleRateStrings, AudioImporterInspector.Styles.kSampleRateValues, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { properties.settings.sampleRateOverride = (uint)num; properties.sampleRateOverrideChanged = true; } } EditorGUI.showMixedValue = false; }
static void CacheServerVersion2GUI(bool allowCacheServerChanges, string overrideAddress) { GUILayout.Label(Properties.assetPipelineVersion2, EditorStyles.boldLabel); GUILayout.Space(5); bool changeStateBeforeControls = GUI.changed; s_CacheServer2Mode = (CacheServer2Mode)EditorGUILayout.EnumPopup(Properties.cacheServerDefaultMode, s_CacheServer2Mode); s_CacheServer2IPAddress = EditorGUILayout.TextField(Properties.cacheServerIPLabel, s_CacheServer2IPAddress); if (GUI.changed != changeStateBeforeControls) { s_ConnectionState = ConnectionState.Unknown; } GUILayout.Space(5); using (new EditorGUI.DisabledScope(AssetDatabase.IsV1Enabled())) { if (GUILayout.Button("Check Connection", GUILayout.Width(150))) { var address = s_CacheServer2IPAddress.Split(':'); if (address.Length == 2) // Expected format is '0.0.0.0:0' { var ip = address[0]; var port = Convert.ToUInt16(address[1]); if (AssetDatabaseExperimental.CanConnectToCacheServer(ip, port)) { s_ConnectionState = ConnectionState.Success; } else { s_ConnectionState = ConnectionState.Failure; } } else { s_ConnectionState = ConnectionState.Failure; } } } GUILayout.Space(-25); var s = AssetDatabase.IsV2Enabled() ? s_ConnectionState : ConnectionState.Unknown; switch (s) { case ConnectionState.Success: EditorGUILayout.HelpBox("Connection successful.", MessageType.Info, false); break; case ConnectionState.Failure: EditorGUILayout.HelpBox("Connection failed.", MessageType.Warning, false); break; case ConnectionState.Unknown: GUILayout.Space(44); break; } }
static void CacheServerVersion1GUI(bool allowCacheServerChanges, string overrideAddress) { GUILayout.Label(Properties.assetPipelineVersion1, EditorStyles.boldLabel); GUILayout.Space(5); if (!allowCacheServerChanges) { EditorGUILayout.HelpBox("Cache Server preferences cannot be modified because a remote address was specified via command line argument. To modify Cache Server preferences, restart Unity without the " + kIpAddressKeyArgs + " command line argument.", MessageType.Info, true); } using (new EditorGUI.DisabledScope(!allowCacheServerChanges)) { var displayMode = !allowCacheServerChanges ? CacheServerMode.Remote : s_CacheServerMode; s_CacheServerMode = (CacheServerMode)EditorGUILayout.EnumPopup("Cache Server Mode", displayMode); } if (s_CacheServerMode == CacheServerMode.Remote) { using (new EditorGUI.DisabledScope(!allowCacheServerChanges)) { var displayAddress = overrideAddress != null ? overrideAddress : s_CacheServerIPAddress; s_CacheServerIPAddress = EditorGUILayout.TextField("IP Address", displayAddress); if (GUI.changed) { s_ConnectionState = ConnectionState.Unknown; } } GUILayout.Space(5); using (new EditorGUI.DisabledScope(AssetDatabase.IsV2Enabled())) { if (GUILayout.Button("Check Connection", GUILayout.Width(150))) { if (InternalEditorUtility.CanConnectToCacheServer()) { s_ConnectionState = ConnectionState.Success; } else { s_ConnectionState = ConnectionState.Failure; } } } GUILayout.Space(-25); var s = AssetDatabase.IsV1Enabled() ? s_ConnectionState : ConnectionState.Unknown; switch (s) { case ConnectionState.Success: EditorGUILayout.HelpBox("Connection successful.", MessageType.Info, false); break; case ConnectionState.Failure: EditorGUILayout.HelpBox("Connection failed.", MessageType.Warning, false); break; case ConnectionState.Unknown: GUILayout.Space(44); break; } } else if (s_CacheServerMode == CacheServerMode.Local) { const int kMinSizeInGigabytes = 1; const int kMaxSizeInGigabytes = 200; // Write size in GigaBytes. s_LocalCacheServerSize = EditorGUILayout.IntSlider(Properties.maxCacheSize, s_LocalCacheServerSize, kMinSizeInGigabytes, kMaxSizeInGigabytes); s_EnableCustomPath = EditorGUILayout.Toggle(Properties.customCacheLocation, s_EnableCustomPath); // browse for cache folder if not per project if (s_EnableCustomPath) { GUIStyle style = EditorStyles.miniButton; GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(Properties.cacheFolderLocation, style); Rect r = GUILayoutUtility.GetRect(GUIContent.none, style); GUIContent guiText = string.IsNullOrEmpty(s_CachePath) ? Properties.browse : new GUIContent(s_CachePath); if (EditorGUI.DropdownButton(r, guiText, FocusType.Passive, style)) { string pathToOpen = s_CachePath; string path = EditorUtility.OpenFolderPanel(Properties.browseCacheLocation.text, pathToOpen, ""); if (!string.IsNullOrEmpty(path)) { if (LocalCacheServer.CheckValidCacheLocation(path)) { s_CachePath = path; WritePreferences(); } else { EditorUtility.DisplayDialog("Invalid Cache Location", string.Format("The directory {0} contains some files which don't look like Unity Cache server files. Please delete the directory contents or choose another directory.", path), "OK"); } EditorGUIUtility.ExitGUI(); } } GUILayout.EndHorizontal(); } else { s_CachePath = ""; } bool locationExists = LocalCacheServer.CheckCacheLocationExists(); if (locationExists == true) { GUIContent cacheSizeIs = EditorGUIUtility.TrTextContent("Cache size is unknown"); if (s_LocalCacheServerUsedSize != -1) { cacheSizeIs = EditorGUIUtility.TextContent("Cache size is " + EditorUtility.FormatBytes(s_LocalCacheServerUsedSize)); } GUILayout.BeginHorizontal(); GUIStyle style = EditorStyles.miniButton; EditorGUILayout.PrefixLabel(cacheSizeIs, style); Rect r = GUILayoutUtility.GetRect(GUIContent.none, style); if (EditorGUI.Button(r, Properties.enumerateCache, style)) { s_LocalCacheServerUsedSize = LocalCacheServer.CheckCacheLocationExists() ? FileUtil.GetDirectorySize(LocalCacheServer.GetCacheLocation()) : 0; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUIContent spacerContent = EditorGUIUtility.blankContent; EditorGUILayout.PrefixLabel(spacerContent, style); Rect r2 = GUILayoutUtility.GetRect(GUIContent.none, style); if (EditorGUI.Button(r2, Properties.cleanCache, style)) { LocalCacheServer.Clear(); s_LocalCacheServerUsedSize = 0; } GUILayout.EndHorizontal(); } else { EditorGUILayout.HelpBox("Local cache directory does not exist - please check that you can access the cache folder and are able to write to it", MessageType.Warning, false); //If the cache server was on an external HDD or on a temporarily unavailable network drive, set the size to unknown so that the user re-queries it when they've reconnected s_LocalCacheServerUsedSize = -1; } GUILayout.Label(Properties.cacheFolderLocation.text + ":"); GUILayout.Label(LocalCacheServer.GetCacheLocation(), Styles.cacheFolderLocation); } }
private static void OnGUI(string searchContext) { EditorGUIUtility.labelWidth = 200f; // Get event type before the event is used. var eventType = Event.current.type; if (!InternalEditorUtility.HasTeamLicense()) { GUILayout.Label(EditorGUIUtility.TempContent("You need to have a Pro or Team license to use the cache server.", EditorGUIUtility.GetHelpIcon(MessageType.Warning)), EditorStyles.helpBox); } using (new EditorGUI.DisabledScope(!InternalEditorUtility.HasTeamLicense())) { if (!s_PrefsLoaded) { EnsurePreferencesRead(); OnPreferencesReadGUI(); } EditorGUI.BeginChangeCheck(); s_AssetPipelineVersionForNewProjects = (AssetPipelineVersion)EditorGUILayout.EnumPopup(Properties.newProjectsAssetPipeline, s_AssetPipelineVersionForNewProjects); EditorGUILayout.LabelField(Properties.activeAssetPipelineVersionLabel, Properties.activeAssetPipelineVersion); var overrideAddress = GetCommandLineRemoteAddressOverride(); bool allowCacheServerChanges = overrideAddress == null; if (GetEnvironmentAssetPipelineOverride()) { EditorGUILayout.HelpBox("Asset pipeline currently forced environment variable UNITY_ASSETS_V2_KATANA_TESTS", MessageType.Info, true); } else if (GetCommandLineAssetPipelineOverride() != 0) { EditorGUILayout.HelpBox("Asset pipeline currently forced by command line argument", MessageType.Info, true); } else if (GetMagicFileAssetPipelineOverride()) { EditorGUILayout.HelpBox("Asset pipeline currently forced by magic adb2.txt file", MessageType.Info, true); } GUILayout.Space(5); CacheServerVersion1GUI(allowCacheServerChanges, overrideAddress); GUILayout.Space(5); CacheServerVersion2GUI(allowCacheServerChanges, overrideAddress); GUILayout.Space(10); if (!allowCacheServerChanges) { EditorGUILayout.HelpBox("Cache Server preferences currently forced via command line argument to " + overrideAddress + " and any changes here will not take effect until starting Unity without that command line argument.", MessageType.Info, true); } if (EditorGUI.EndChangeCheck()) { s_HasPendingChanges = true; } // Only commit changes when we don't have an active hot control, to avoid restarting the cache server all the time while the slider is dragged, slowing down the UI. if (s_HasPendingChanges && GUIUtility.hotControl == 0) { s_HasPendingChanges = false; WritePreferences(); ReadPreferences(); } } }
public override void OnInspectorGUI() { var settings = (ImportSettings)target; EditorGUI.BeginChangeCheck(); using (new GL.HorizontalScope(EditorStyles.toolbar)) { GL.Label("Options"); } settings.baseName = EGL.TextField(new GUIContent("Base Name", "Used to name the atlas, clips, and other assets generated"), settings.baseName); settings.spriteTarget = EGL.TextField(new GUIContent("Target Child Object", "Optional name of child object containing destination Sprite Renderer"), settings.spriteTarget); EGL.Space(); settings.ppu = EGL.IntField(new GUIContent("Pixel Per Unit", "How many pixels span a Unity unit"), settings.ppu); settings.pixelOrigin = (PixelOrigin)EGL.EnumPopup(new GUIContent("Pixel Origin", "Where on the sprite's pixel data aligns to." + "\nCenter: center of the pixel (recommended)" + "\nBottom Left: bottom left of the pixel (original)"), settings.pixelOrigin); EGL.Space(); settings.alignment = (SpriteAlignment)EGL.EnumPopup(new GUIContent("Sprite Align", "Where the pivot aligns to the sprite\n" + "Note that a @pivot layer will override this"), settings.alignment); if (settings.alignment == SpriteAlignment.Custom) { settings.customPivot = EGL.Vector2Field("Custom Pivot", settings.customPivot); } settings.densePacked = EGL.Toggle("Dense Pack", settings.densePacked); settings.border = EGL.IntField("Border", settings.border); EGL.Space(); using (new GL.HorizontalScope(EditorStyles.toolbar)) { GL.Label("Output"); } settings.atlasOutputDirectory = PathSelection("Atlas Directory", settings.atlasOutputDirectory); settings.clipOutputDirectory = PathSelection("Anim Clip Directory", settings.clipOutputDirectory); settings.controllerPolicy = (AnimControllerOutputPolicy)EGL.EnumPopup("Anim Controller Policy", settings.controllerPolicy); if (settings.controllerPolicy == AnimControllerOutputPolicy.CreateOrOverride) { settings.animControllerOutputPath = PathSelection("Anim Controller Directory", settings.animControllerOutputPath); } settings.dataOutputDirectory = PathSelection("Anim Data Directory", settings.dataOutputDirectory); if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(settings); } }
protected void UvsGUI() { EditorGUILayout.PropertyField(m_SwapUVChannels, Styles.SwapUVChannels); EditorGUILayout.PropertyField(m_GenerateSecondaryUV, Styles.GenerateSecondaryUV); if (m_GenerateSecondaryUV.boolValue) { m_SecondaryUVAdvancedOptions = EditorGUILayout.Foldout(m_SecondaryUVAdvancedOptions, Styles.GenerateSecondaryUVAdvanced, true, EditorStyles.foldout); if (m_SecondaryUVAdvancedOptions) { using (new EditorGUI.IndentLevelScope()) { EditorGUI.BeginChangeCheck(); EditorGUILayout.Slider(m_SecondaryUVHardAngle, 0, 180, Styles.secondaryUVHardAngle); EditorGUILayout.Slider(m_SecondaryUVAngleDistortion, 1, 75, Styles.secondaryUVAngleDistortion); EditorGUILayout.Slider(m_SecondaryUVAreaDistortion, 1, 75, Styles.secondaryUVAreaDistortion); using (var horizontal = new EditorGUILayout.HorizontalScope()) { using (var prop = new EditorGUI.PropertyScope(horizontal.rect, Styles.secondaryUVMarginMethod, m_SecondaryUVMarginMethod)) { EditorGUI.BeginChangeCheck(); var newValue = (int)(ModelImporterSecondaryUVMarginMethod)EditorGUILayout.EnumPopup(prop.content, (ModelImporterSecondaryUVMarginMethod)m_SecondaryUVMarginMethod.intValue); if (EditorGUI.EndChangeCheck()) { m_SecondaryUVMarginMethod.intValue = newValue; } } } if (m_SecondaryUVMarginMethod.intValue == (int)ModelImporterSecondaryUVMarginMethod.Calculate) { EditorGUILayout.PropertyField(m_SecondaryUVMinLightmapResolution, Styles.secondaryUVMinLightmapResolution); if (LightmapEditorSettings.bakeResolution < m_SecondaryUVMinLightmapResolution.floatValue) { EditorGUILayout.HelpBox(Styles.secondaryUVMinLightmapResolutionNotice); } EditorGUILayout.PropertyField(m_SecondaryUVMinObjectScale, Styles.secondaryUVMinObjectScale); } else { EditorGUILayout.Slider(m_SecondaryUVPackMargin, 1, 64, Styles.secondaryUVPackMargin); } if (EditorGUI.EndChangeCheck()) { m_SecondaryUVHardAngle.floatValue = Mathf.Round(m_SecondaryUVHardAngle.floatValue); m_SecondaryUVPackMargin.floatValue = Mathf.Round(m_SecondaryUVPackMargin.floatValue); m_SecondaryUVMinLightmapResolution.floatValue = Mathf.Round(m_SecondaryUVMinLightmapResolution.floatValue); m_SecondaryUVMinObjectScale.floatValue = m_SecondaryUVMinObjectScale.floatValue; m_SecondaryUVAngleDistortion.floatValue = Mathf.Round(m_SecondaryUVAngleDistortion.floatValue); m_SecondaryUVAreaDistortion.floatValue = Mathf.Round(m_SecondaryUVAreaDistortion.floatValue); } } } } }
void NormalsTangentsGUI() { EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = m_LegacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes.hasMultipleDifferentValues; var legacyComputeFromSmoothingGroups = EditorGUILayout.Toggle(Styles.LegacyComputeNormalsFromSmoothingGroupsWhenMeshHasBlendShapes, m_LegacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes.boolValue); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { m_LegacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes.boolValue = legacyComputeFromSmoothingGroups; } using (var horizontal = new EditorGUILayout.HorizontalScope()) { using (var property = new EditorGUI.PropertyScope(horizontal.rect, Styles.NormalsLabel, m_NormalImportMode)) { EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = m_NormalImportMode.hasMultipleDifferentValues; var newValue = (int)(ModelImporterNormals)EditorGUILayout.EnumPopup(property.content, (ModelImporterNormals)m_NormalImportMode.intValue); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { m_NormalImportMode.intValue = newValue; // This check is made in CheckConsistency, but because AssetImporterEditor does not serialize the object each update, // We need to double check here for UI consistency. if (m_NormalImportMode.intValue == (int)ModelImporterNormals.None) { m_TangentImportMode.intValue = (int)ModelImporterTangents.None; } else if (m_NormalImportMode.intValue == (int)ModelImporterNormals.Calculate && m_TangentImportMode.intValue == (int)ModelImporterTangents.Import) { m_TangentImportMode.intValue = (int)ModelImporterTangents.CalculateMikk; } // Also make the blendshape normal mode follow normal mode, with the exception that we never // select Import automatically (since we can't trust imported normals to be correct, and we // also can't detect when they're not). if (m_NormalImportMode.intValue == (int)ModelImporterNormals.None) { m_BlendShapeNormalCalculationMode.intValue = (int)ModelImporterNormals.None; } else { m_BlendShapeNormalCalculationMode.intValue = (int)ModelImporterNormals.Calculate; } } } } if (!m_LegacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes.boolValue && m_ImportBlendShapes.boolValue && !m_LegacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes.hasMultipleDifferentValues) { using (new EditorGUI.DisabledScope(m_NormalImportMode.intValue == (int)ModelImporterNormals.None)) { EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = m_BlendShapeNormalCalculationMode.hasMultipleDifferentValues; var blendShapeNormalCalculationMode = (int)(ModelImporterNormals)EditorGUILayout.EnumPopup(Styles.BlendShapeNormalsLabel, (ModelImporterNormals)m_BlendShapeNormalCalculationMode.intValue); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { m_BlendShapeNormalCalculationMode.intValue = blendShapeNormalCalculationMode; } } } if (m_NormalImportMode.intValue != (int)ModelImporterNormals.None || m_BlendShapeNormalCalculationMode.intValue != (int)ModelImporterNormals.None) { // Normal calculation mode using (var horizontal = new EditorGUILayout.HorizontalScope()) { using (var property = new EditorGUI.PropertyScope(horizontal.rect, Styles.RecalculateNormalsLabel, m_NormalCalculationMode)) { EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = m_NormalCalculationMode.hasMultipleDifferentValues; var normalCalculationMode = (int)(ModelImporterNormalCalculationMode)EditorGUILayout.EnumPopup(property.content, (ModelImporterNormalCalculationMode)m_NormalCalculationMode.intValue); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { m_NormalCalculationMode.intValue = normalCalculationMode; } } } // Normal smoothness if (!m_LegacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes.boolValue) { using (var horizontal = new EditorGUILayout.HorizontalScope()) using (var property = new EditorGUI.PropertyScope(horizontal.rect, Styles.NormalSmoothingSourceLabel, m_NormalSmoothingSource)) { EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = m_NormalSmoothingSource.hasMultipleDifferentValues; var normalSmoothingSource = (int)(ModelImporterNormalSmoothingSource)EditorGUILayout.EnumPopup(property.content, (ModelImporterNormalSmoothingSource)m_NormalSmoothingSource.intValue); EditorGUI.showMixedValue = false; if (EditorGUI.EndChangeCheck()) { m_NormalSmoothingSource.intValue = normalSmoothingSource; } } } // Normal split angle if (m_LegacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes.boolValue || m_NormalSmoothingSource.intValue == (int)ModelImporterNormalSmoothingSource.PreferSmoothingGroups || m_NormalSmoothingSource.intValue == (int)ModelImporterNormalSmoothingSource.FromAngle) { EditorGUI.BeginChangeCheck(); EditorGUILayout.Slider(m_NormalSmoothAngle, 0, 180, Styles.SmoothingAngle); // Property is serialized as float but we want to show it as an int so we round the value when changed if (EditorGUI.EndChangeCheck()) { m_NormalSmoothAngle.floatValue = Mathf.Round(m_NormalSmoothAngle.floatValue); } } } // Choose the option values and labels based on what the NormalImportMode is if (m_NormalImportMode.intValue != (int)ModelImporterNormals.None) { using (var horizontal = new EditorGUILayout.HorizontalScope()) { using (var property = new EditorGUI.PropertyScope(horizontal.rect, Styles.TangentsLabel, m_TangentImportMode)) { EditorGUI.BeginChangeCheck(); var newValue = (int)(ModelImporterTangents)EditorGUILayout.EnumPopup(property.content, (ModelImporterTangents)m_TangentImportMode.intValue, TangentModeAvailabilityCheck, false); if (EditorGUI.EndChangeCheck()) { m_TangentImportMode.intValue = newValue; } } } } }
private void OnGUI() { UG.BeginVertical(); UG.BeginHorizontal(); UG.LabelField("当前数据源:" + (_dataPath.IsNullPath() ? "未在本地保存,已编辑内容随时可能丢失!" : _dataPath)); if (GUILayout.Button("选择")) { string path = EditorUtility.OpenFilePanelWithFilters("选择数据源文件", Application.dataPath + "/Hotassets/Data", new [] { "text", "txt" }); if (!string.IsNullOrEmpty(path)) { Dictionary <string, List <InterlocutionData> > temperData = null; try { temperData = JsonConvert.DeserializeObject <Dictionary <string, List <InterlocutionData> > >(File.ReadAllText(path)); } catch (JsonException) { temperData = _data; path = _dataPath; EditorApplication.Beep(); EditorUtility.DisplayDialog("异常捕获!", "数据源文件不能被正确加载,请确定.json文件的有效性", "知道了"); } finally { _data = temperData; _dataPath = path; } } } UG.EndHorizontal(); UG.BeginHorizontal(); int subject = UG.Popup("所属学科", _editingSubject, InterlocutionData.Keys); if (subject != _editingSubject) { _editingInterlocution = -1; } _editingSubject = subject; string key = InterlocutionData.Keys[_editingSubject]; UG.LabelField("分组", _editingSubject != InterlocutionData.Keys.Length - 1 ? Subject.ToSubject(InterlocutionData.Keys[_editingSubject]).group.ToString() : "无"); UG.EndHorizontal(); _scrollPostion = UG.BeginScrollView(_scrollPostion); if (!_data.ContainsKey(key)) { _data[key] = new List <InterlocutionData>(); } List <InterlocutionData> interlocutions = _data[key]; int _deletedInterlocution = -1; UG.LabelField("[已有 " + interlocutions.Count + " 道问答]"); for (int i = 0, l = interlocutions.Count; i < l; i++) { UG.BeginHorizontal(); UG.LabelField("[Q " + i + "] " + interlocutions[i].question); if (GUILayout.Button("编辑")) { _editingInterlocution = i; } if (GUILayout.Button("删除")) { EditorApplication.Beep(); if (EditorUtility.DisplayDialog("危险操作警告⚠️", "即将删除问答 [Q" + i + "] (该操作不可逆)", "确认", "取消")) { _deletedInterlocution = i; if (_editingInterlocution == _deletedInterlocution) { _editingInterlocution = -1; } } } UG.EndHorizontal(); } if (_deletedInterlocution != -1) { interlocutions.RemoveAt(_deletedInterlocution); } UG.EndScrollView(); if (GUILayout.Button("添加问答")) { _editingInterlocution = interlocutions.Count; interlocutions.Add(new InterlocutionData()); } UG.LabelField("问答编辑区"); if (_editingInterlocution != -1) { UG.LabelField("Q " + _editingInterlocution); InterlocutionData interlocution = interlocutions[_editingInterlocution]; interlocution.question = UG.TextArea(interlocution.question); interlocution.answer = (Option)UG.EnumPopup("正确选项", interlocution.answer); UG.LabelField("选项A"); interlocution.optionA = UG.TextArea(interlocution.optionA); UG.LabelField("选项B"); interlocution.optionB = UG.TextArea(interlocution.optionB); UG.LabelField("选项C"); interlocution.optionC = UG.TextArea(interlocution.optionC); UG.LabelField("选项D"); interlocution.optionD = UG.TextArea(interlocution.optionD); } else { UG.HelpBox("需要选择一个问答进行编辑!", MessageType.Warning); } if (GUILayout.Button("保存")) { bool toSave = true; bool toImport = false; if (_dataPath.IsNullPath()) { string path = EditorUtility.SaveFilePanel("保存问答数据", Application.dataPath + "/Hotassets/Data", "InterlocutionData", "txt"); if (string.IsNullOrEmpty(path)) { toSave = false; } else { _dataPath = path; toImport = true; } } if (toSave) { File.WriteAllText(_dataPath, JsonConvert.SerializeObject(_data)); EditorPrefs.SetString(DATA_SAVE_PATH, _dataPath); } if (toImport) { AssetDatabase.ImportAsset(_dataPath.Substring(_dataPath.IndexOf("Assets"))); } } UG.EndVertical(); }
public override void OnSelectionInspectorGUI() { BoundsInt selection = GridSelection.position; Tilemap tilemap = GridSelection.target.GetComponent <Tilemap>(); int cellCount = selection.size.x * selection.size.y * selection.size.z; if (tilemap != null && cellCount > 0) { base.OnSelectionInspectorGUI(); GUILayout.Space(10f); if (m_SelectionTiles == null || m_SelectionTiles.Length != cellCount) { m_SelectionTiles = new TileBase[cellCount]; m_SelectionColors = new Color[cellCount]; m_SelectionMatrices = new Matrix4x4[cellCount]; m_SelectionFlagsArray = new TileFlags[cellCount]; m_SelectionSprites = new Sprite[cellCount]; m_SelectionColliderTypes = new Tile.ColliderType[cellCount]; } int index = 0; foreach (var p in selection.allPositionsWithin) { m_SelectionTiles[index] = tilemap.GetTile(p); m_SelectionColors[index] = tilemap.GetColor(p); m_SelectionMatrices[index] = tilemap.GetTransformMatrix(p); m_SelectionFlagsArray[index] = tilemap.GetTileFlags(p); m_SelectionSprites[index] = tilemap.GetSprite(p); m_SelectionColliderTypes[index] = tilemap.GetColliderType(p); index++; } EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = m_SelectionTiles.Any(tile => tile != m_SelectionTiles.First()); var position = new Vector3Int(selection.xMin, selection.yMin, selection.zMin); TileBase newTile = EditorGUILayout.ObjectField(Styles.tileLabel, tilemap.GetTile(position), typeof(TileBase), false) as TileBase; if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(tilemap, "Edit Tilemap"); foreach (var p in selection.allPositionsWithin) { tilemap.SetTile(p, newTile); } } using (new EditorGUI.DisabledScope(true)) { EditorGUI.showMixedValue = m_SelectionSprites.Any(sprite => sprite != m_SelectionSprites.First()); EditorGUILayout.ObjectField(Styles.spriteLabel, m_SelectionSprites[0], typeof(Sprite), false, GUILayout.Height(EditorGUI.kSingleLineHeight)); } bool colorFlagsAllEqual = m_SelectionFlagsArray.All(flags => (flags & TileFlags.LockColor) == (m_SelectionFlagsArray.First() & TileFlags.LockColor)); using (new EditorGUI.DisabledScope(!colorFlagsAllEqual || (m_SelectionFlagsArray[0] & TileFlags.LockColor) != 0)) { EditorGUI.showMixedValue = m_SelectionColors.Any(color => color != m_SelectionColors.First()); EditorGUI.BeginChangeCheck(); Color newColor = EditorGUILayout.ColorField(Styles.colorLabel, m_SelectionColors[0]); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(tilemap, "Edit Tilemap"); foreach (var p in selection.allPositionsWithin) { tilemap.SetColor(p, newColor); } } } using (new EditorGUI.DisabledScope(true)) { EditorGUI.showMixedValue = m_SelectionColliderTypes.Any(colliderType => colliderType != m_SelectionColliderTypes.First()); EditorGUILayout.EnumPopup(Styles.colliderTypeLabel, m_SelectionColliderTypes[0]); } bool transformFlagsAllEqual = m_SelectionFlagsArray.All(flags => (flags & TileFlags.LockTransform) == (m_SelectionFlagsArray.First() & TileFlags.LockTransform)); using (new EditorGUI.DisabledScope(!transformFlagsAllEqual || (m_SelectionFlagsArray[0] & TileFlags.LockTransform) != 0)) { EditorGUI.showMixedValue = m_SelectionMatrices.Any(matrix => matrix != m_SelectionMatrices.First()); EditorGUI.BeginChangeCheck(); Matrix4x4 newTransformMatrix = TileEditor.TransformMatrixOnGUI(m_SelectionMatrices[0]); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(tilemap, "Edit Tilemap"); foreach (var p in selection.allPositionsWithin) { tilemap.SetTransformMatrix(p, newTransformMatrix); } } } using (new EditorGUI.DisabledScope(true)) { EditorGUI.showMixedValue = !colorFlagsAllEqual; EditorGUILayout.Toggle(Styles.lockColorLabel, (m_SelectionFlagsArray[0] & TileFlags.LockColor) != 0); EditorGUI.showMixedValue = !transformFlagsAllEqual; EditorGUILayout.Toggle(Styles.lockTransformLabel, (m_SelectionFlagsArray[0] & TileFlags.LockTransform) != 0); } EditorGUI.showMixedValue = false; } }
public override void OnInspectorGUI() { transition = (Transition)target; EditorGUI.BeginChangeCheck(); var fromName = transition.fromState.GetStatePreview(); var toName = transition.targetInfo; var displayName = fromName + "->" + toName; EGL.LabelField(displayName); EGL.Space(); FromStateFilterInspector(transition.profile, transition.fromState, ref fromStateRect); EGL.Space(); transition.triggerRangeType = (TriggerRangeType)EGL.EnumPopup("Trigger Range Type", transition.triggerRangeType); if (transition.triggerRangeType == TriggerRangeType.Range) { transition.triggerRange = EditorGUIUtil.FrameRangeInput("Trigger Frame", transition.triggerRange); } if (transition.triggerRangeType == TriggerRangeType.FrameSinceExec || transition.triggerRangeType == TriggerRangeType.FrameSinceExecBefore) { transition.triggerFrameSinceExec = EGL.IntField("Frame Since Exec", transition.triggerFrameSinceExec); } transition.timeBuffer = EGL.FloatField("Time Buffer", transition.timeBuffer); using (new EGL.VerticalScope(EditorStyles.helpBox)) { var conds = transition.conditions; var paramNames = transition.profile.parameters.Select(it => it.name).ToArray(); using (new EGL.HorizontalScope()) { EGL.LabelField("Conditions", EditorStyles.boldLabel); GL.FlexibleSpace(); if (GL.Button("+", GL.Width(30))) { conds.Add(new Condition()); } } for (int i = 0; i < conds.Count; ++i) { var cond = conds[i]; EGL.BeginHorizontal(); int condSelectIndex = Mathf.Max(0, Array.IndexOf(paramNames, cond.name)); // cond.name = EGL.TextField(cond.name, GL.Width(70)); condSelectIndex = EGL.Popup(condSelectIndex, paramNames); cond.name = paramNames[condSelectIndex]; var param = transition.profile.FindParam(cond.name); if (param == null) { EGL.LabelField("!Doesn't exist"); } else { var type = param.type; if (type == ParamType.Bool) { cond.boolValue = EGL.Toggle(cond.boolValue); } else if (type != ParamType.Trigger) // Trigger 不需要编辑 { cond.cmp = (Cmp)EGL.EnumPopup(cond.cmp, GL.Width(50)); if (type == ParamType.Int) { cond.intValue = EGL.IntField(cond.intValue); } else { cond.floatValue = EGL.FloatField(cond.floatValue); } } } GL.FlexibleSpace(); if (GL.Button("-", GL.Width(30))) { conds.RemoveAt(i); --i; } EGL.EndHorizontal(); } } EGL.LabelField("", GUI.skin.horizontalSlider); transition.actionType = (ActionType)EGL.EnumPopup("Action", transition.actionType); if (transition.actionType == ActionType.ChangeState) { EGL.BeginHorizontal(); EGL.PrefixLabel("Target State"); EditorGUIUtil.AutoCompleteList(transition.targetStateName, allStateNames, str => transition.targetStateName = str, ref targetStateRect); transition.targetStateFrame = EGL.IntField(transition.targetStateFrame, GL.Width(30)); EGL.LabelField("F", GUILayout.Width(20)); var targetState = transition.profile.FindState(transition.targetStateName); if (targetState) { if (GL.Button("Focus")) { Utils.FocusEditingAnimation(transition.profile, targetState.stateName); } } EGL.EndHorizontal(); if (!targetState) { EGL.HelpBox("No target state " + targetState, MessageType.Error); } } else // SendMessage { transition.messageName = EGL.TextField("Message Name", transition.messageName); EGL.Space(); transition.messageParType = (MessageParType)EGL.EnumPopup("Parameter Type", transition.messageParType); switch (transition.messageParType) { case MessageParType.Int: transition.messageParInt = EGL.IntField("Value", transition.messageParInt); break; case MessageParType.Float: transition.messageParFloat = EGL.FloatField("Value", transition.messageParFloat); break; case MessageParType.Bool: transition.messageParBool = EGL.Toggle("Value", transition.messageParBool); break; } } transition.priority = EGL.IntField("Priority", transition.priority); transition.shouldDelay = EGL.Toggle("Should Delay", transition.shouldDelay); if (transition.shouldDelay) { transition.delay = EGL.FloatField("Delay", transition.delay); } if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(transition); } if (transition.fromState.type == FromStateType.State) { EGL.LabelField("", GUI.skin.horizontalSlider); using (new EGL.VerticalScope(EditorStyles.helpBox)) { EGL.LabelField("From State", EditorStyles.boldLabel); ++EditorGUI.indentLevel; var fromState = transition.profile.FindState(transition.fromState.stateOrTagName); if (fromState) { GUI.enabled = false; if (!fromStateEditor || fromStateEditor.target != fromState) { if (fromStateEditor) { DestroyImmediate(fromStateEditor); } fromStateEditor = Editor.CreateEditor(fromState); } fromStateEditor.OnInspectorGUI(); GUI.enabled = true; } --EditorGUI.indentLevel; } } }
public override void OnInspectorGUI() { base.serializedObject.Update(); if (this.m_AllRoot) { EditorGUILayout.PropertyField(this.m_RenderMode, new GUILayoutOption[0]); this.m_OverlayMode.target = this.m_RenderMode.intValue == 0; this.m_CameraMode.target = this.m_RenderMode.intValue == 1; this.m_WorldMode.target = this.m_RenderMode.intValue == 2; EditorGUI.indentLevel++; if (EditorGUILayout.BeginFadeGroup(this.m_OverlayMode.faded)) { EditorGUILayout.PropertyField(this.m_PixelPerfect, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_SortingOrder, this.sortingOrder, new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(this.m_CameraMode.faded)) { EditorGUILayout.PropertyField(this.m_PixelPerfect, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_Camera, this.renderCamera, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_PlaneDistance, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.SortingLayerField(this.m_SortingLayerStyle, this.m_SortingLayerID, EditorStyles.popup, EditorStyles.label); EditorGUILayout.PropertyField(this.m_SortingOrder, this.m_SortingOrderStyle, new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(this.m_WorldMode.faded)) { EditorGUILayout.PropertyField(this.m_Camera, this.eventCamera, new GUILayoutOption[0]); EditorGUILayout.Space(); EditorGUILayout.SortingLayerField(this.m_SortingLayerStyle, this.m_SortingLayerID, EditorStyles.popup); EditorGUILayout.PropertyField(this.m_SortingOrder, this.m_SortingOrderStyle, new GUILayoutOption[0]); } EditorGUILayout.EndFadeGroup(); EditorGUI.indentLevel--; } else if (this.m_AllNested) { EditorGUI.BeginChangeCheck(); this.pixelPerfect = (PixelPerfect)EditorGUILayout.EnumPopup("Pixel Perfect", this.pixelPerfect, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { if (this.pixelPerfect == PixelPerfect.Inherit) { this.m_PixelPerfectOverride.boolValue = false; } else if (this.pixelPerfect == PixelPerfect.Off) { this.m_PixelPerfectOverride.boolValue = true; this.m_PixelPerfect.boolValue = false; } else { this.m_PixelPerfectOverride.boolValue = true; this.m_PixelPerfect.boolValue = true; } } EditorGUILayout.PropertyField(this.m_OverrideSorting, new GUILayoutOption[0]); this.m_SortingOverride.target = this.m_OverrideSorting.boolValue; if (EditorGUILayout.BeginFadeGroup(this.m_SortingOverride.faded)) { if (this.m_AllOverlay) { EditorGUILayout.PropertyField(this.m_SortingOrder, this.sortingOrder, new GUILayoutOption[0]); } else if (this.m_NoneOverlay) { EditorGUILayout.SortingLayerField(this.m_SortingLayerStyle, this.m_SortingLayerID, EditorStyles.popup); EditorGUILayout.PropertyField(this.m_SortingOrder, this.m_SortingOrderStyle, new GUILayoutOption[0]); } } EditorGUILayout.EndFadeGroup(); } else { GUILayout.Label(s_RootAndNestedMessage, EditorStyles.helpBox, new GUILayoutOption[0]); } base.serializedObject.ApplyModifiedProperties(); }
private void OnPlaneGenerationGUI() { planeGenerationData = planeGenerationData ?? new PlaneGenerationData(); planeGenerationData.direction = (PlaneGenerationData.Direction)UG.EnumPopup("平面方向", planeGenerationData.direction); UG.BeginHorizontal(); planeGenerationData.length = UG.DelayedFloatField("长", planeGenerationData.length); planeGenerationData.width = UG.DelayedFloatField("宽", planeGenerationData.width); UG.EndHorizontal(); UG.BeginHorizontal(); planeGenerationData.verticesPerLength = UG.DelayedIntField("长顶点数", planeGenerationData.verticesPerLength); planeGenerationData.verticesPerWidth = UG.DelayedIntField("宽顶点数", planeGenerationData.verticesPerWidth); UG.EndHorizontal(); bool legal = true; string errorMessage = String.Empty; if (defaultMaterial == null) { legal = false; errorMessage += "默认材质不能为空"; } if (planeGenerationData.length <= 0) { legal = false; errorMessage += "平面长必须大于0\n"; } if (planeGenerationData.width <= 0) { legal = false; errorMessage += "平面宽必须大于0\n"; } if (planeGenerationData.verticesPerLength <= 0) { legal = false; errorMessage += "平面长顶点数必须大于0\n"; } if (planeGenerationData.verticesPerWidth <= 0) { legal = false; errorMessage += "平面宽顶点数必须大于0\n"; } if (legal) { if (GUILayout.Button("生成")) { MeshTool.InstantiatePlane(planeGenerationData, defaultMaterial); } } else { UG.HelpBox(errorMessage, MessageType.Error); } }
void OnGUI() { var dirtyCount = PhysicsVisualizationSettings.dirtyCount; EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); // Workflow PhysicsVisualizationSettings.filterWorkflow = (PhysicsVisualizationSettings.FilterWorkflow)EditorGUILayout.EnumPopup( PhysicsVisualizationSettings.filterWorkflow, EditorStyles.toolbarPopup, GUILayout.Width(130)); GUILayout.FlexibleSpace(); if (GUILayout.Button("Reset", EditorStyles.toolbarButton)) { PhysicsVisualizationSettings.Reset(); } EditorGUILayout.EndHorizontal(); m_MainScrollPos = GUILayout.BeginScrollView(m_MainScrollPos); PhysicsVisualizationSettings.FilterWorkflow filterMode = PhysicsVisualizationSettings.filterWorkflow; string action = (filterMode == PhysicsVisualizationSettings.FilterWorkflow.ShowSelectedItems) ? "Show " : "Hide "; // Layers int oldConcatenatedMask = InternalEditorUtility.LayerMaskToConcatenatedLayersMask( PhysicsVisualizationSettings.GetShowCollisionLayerMask(filterMode)); int newConcatenatedMask = EditorGUILayout.MaskField( GUIContent.Temp(action + "Layers", action + "selected layers"), oldConcatenatedMask, InternalEditorUtility.layers); PhysicsVisualizationSettings.SetShowCollisionLayerMask( filterMode, (int)InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(newConcatenatedMask)); // Static Colliders PhysicsVisualizationSettings.SetShowStaticColliders(filterMode, EditorGUILayout.Toggle( GUIContent.Temp(action + "Static Colliders", action + "collision geometry from Colliders that do not have a Rigidbody") , PhysicsVisualizationSettings.GetShowStaticColliders(filterMode))); // Triggers PhysicsVisualizationSettings.SetShowTriggers(filterMode, EditorGUILayout.Toggle( GUIContent.Temp(action + "Triggers", action + "collision geometry from Colliders that have 'isTrigger' enabled") , PhysicsVisualizationSettings.GetShowTriggers(filterMode))); // Rigidbodies PhysicsVisualizationSettings.SetShowRigidbodies(filterMode, EditorGUILayout.Toggle( GUIContent.Temp(action + "Rigidbodies", action + "collision geometry from Rigidbodies") , PhysicsVisualizationSettings.GetShowRigidbodies(filterMode))); // Kinematic Bodies PhysicsVisualizationSettings.SetShowKinematicBodies(filterMode, EditorGUILayout.Toggle( GUIContent.Temp(action + "Kinematic Bodies", action + "collision geometry from Kinematic Rigidbodies") , PhysicsVisualizationSettings.GetShowKinematicBodies(filterMode))); // Sleeping Bodies PhysicsVisualizationSettings.SetShowSleepingBodies(filterMode, EditorGUILayout.Toggle( GUIContent.Temp(action + "Sleeping Bodies", action + "collision geometry from Sleeping Rigidbodies") , PhysicsVisualizationSettings.GetShowSleepingBodies(filterMode))); m_FilterColliderTypesFoldout = EditorGUILayout.Foldout(m_FilterColliderTypesFoldout, "Collider Types"); if (m_FilterColliderTypesFoldout) { EditorGUI.indentLevel++; float oldWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 200; // BoxCollider PhysicsVisualizationSettings.SetShowBoxColliders(filterMode, EditorGUILayout.Toggle( GUIContent.Temp(action + "BoxColliders", action + "collision geometry from BoxColliders") , PhysicsVisualizationSettings.GetShowBoxColliders(filterMode))); // SphereCollider PhysicsVisualizationSettings.SetShowSphereColliders(filterMode, EditorGUILayout.Toggle( GUIContent.Temp(action + "SphereColliders", action + "collision geometry from SphereColliders") , PhysicsVisualizationSettings.GetShowSphereColliders(filterMode))); // CapsuleCollider PhysicsVisualizationSettings.SetShowCapsuleColliders(filterMode, EditorGUILayout.Toggle( GUIContent.Temp(action + "CapsuleColliders", action + "collision geometry from CapsuleColliders") , PhysicsVisualizationSettings.GetShowCapsuleColliders(filterMode))); // MeshCollider convex PhysicsVisualizationSettings.SetShowMeshColliders(filterMode, PhysicsVisualizationSettings.MeshColliderType.Convex, EditorGUILayout.Toggle( GUIContent.Temp(action + "MeshColliders (convex)", action + "collision geometry from convex MeshColliders") , PhysicsVisualizationSettings.GetShowMeshColliders(filterMode, PhysicsVisualizationSettings.MeshColliderType.Convex))); // MeshCollider non-convex PhysicsVisualizationSettings.SetShowMeshColliders(filterMode, PhysicsVisualizationSettings.MeshColliderType.NonConvex, EditorGUILayout.Toggle( GUIContent.Temp(action + "MeshColliders (concave)", action + "collision geometry from non-convex MeshColliders") , PhysicsVisualizationSettings.GetShowMeshColliders(filterMode, PhysicsVisualizationSettings.MeshColliderType.NonConvex))); // TerrainCollider PhysicsVisualizationSettings.SetShowTerrainColliders(filterMode, EditorGUILayout.Toggle( GUIContent.Temp(action + "TerrainColliders", action + "collision geometry from TerrainColliders") , PhysicsVisualizationSettings.GetShowTerrainColliders(filterMode))); EditorGUIUtility.labelWidth = oldWidth; EditorGUI.indentLevel--; } GUILayout.Space(4); // Selection buttons GUILayout.BeginHorizontal(); bool selectNone = GUILayout.Button(action + "None", "MiniButton"); bool selectAll = GUILayout.Button(action + "All", "MiniButton"); if (selectNone || selectAll) { PhysicsVisualizationSettings.SetShowForAllFilters(filterMode, selectAll); } GUILayout.EndHorizontal(); m_ColorFoldout = EditorGUILayout.Foldout(m_ColorFoldout, "Colors"); if (m_ColorFoldout) { EditorGUI.indentLevel++; PhysicsVisualizationSettings.staticColor = EditorGUILayout.ColorField(Contents.staticColor, PhysicsVisualizationSettings.staticColor); PhysicsVisualizationSettings.triggerColor = EditorGUILayout.ColorField(Contents.triggerColor, PhysicsVisualizationSettings.triggerColor); PhysicsVisualizationSettings.rigidbodyColor = EditorGUILayout.ColorField(Contents.rigidbodyColor, PhysicsVisualizationSettings.rigidbodyColor); PhysicsVisualizationSettings.kinematicColor = EditorGUILayout.ColorField(Contents.kinematicColor, PhysicsVisualizationSettings.kinematicColor); PhysicsVisualizationSettings.sleepingBodyColor = EditorGUILayout.ColorField(Contents.sleepingBodyColor, PhysicsVisualizationSettings.sleepingBodyColor); PhysicsVisualizationSettings.colorVariance = EditorGUILayout.Slider("Variation", PhysicsVisualizationSettings.colorVariance, 0f, 1f); EditorGUI.indentLevel--; } m_RenderingFoldout = EditorGUILayout.Foldout(m_RenderingFoldout, "Rendering"); if (m_RenderingFoldout) { EditorGUI.indentLevel++; PhysicsVisualizationSettings.baseAlpha = 1f - EditorGUILayout.Slider("Transparency" , 1f - PhysicsVisualizationSettings.baseAlpha, 0f, 1f); PhysicsVisualizationSettings.forceOverdraw = EditorGUILayout.Toggle(Contents.forceOverdraw , PhysicsVisualizationSettings.forceOverdraw); PhysicsVisualizationSettings.viewDistance = EditorGUILayout.FloatField(Contents.viewDistance , PhysicsVisualizationSettings.viewDistance); PhysicsVisualizationSettings.terrainTilesMax = EditorGUILayout.IntField(Contents.terrainTilesMax , PhysicsVisualizationSettings.terrainTilesMax); EditorGUI.indentLevel--; } if (Unsupported.IsDeveloperMode() || PhysicsVisualizationSettings.devOptions) { PhysicsVisualizationSettings.devOptions = EditorGUILayout.Toggle(Contents.devOptions , PhysicsVisualizationSettings.devOptions); } if (PhysicsVisualizationSettings.devOptions) { PhysicsVisualizationSettings.dotAlpha = EditorGUILayout.Slider("dotAlpha" , PhysicsVisualizationSettings.dotAlpha, -1f, 1f); PhysicsVisualizationSettings.forceDot = EditorGUILayout.Toggle(Contents.forceDot , PhysicsVisualizationSettings.forceDot); Tools.hidden = EditorGUILayout.Toggle(Contents.toolsHidden , Tools.hidden); } GUILayout.EndScrollView(); if (dirtyCount != PhysicsVisualizationSettings.dirtyCount) { RepaintSceneAndGameViews(); } }
public override void OnInspectorGUI() { var settings = (ImportSettings)target; Undo.RecordObject(settings, "AseFileSettings"); using (new GL.HorizontalScope(EditorStyles.toolbar)) { GL.Label("Options"); } settings.generatePrefab = EGL.Toggle("Generate Prefab", settings.generatePrefab); settings.ppu = EGL.IntField("Pixel Per Unit", settings.ppu); settings.alignment = (SpriteAlignment)EGL.EnumPopup("Default Align", settings.alignment); if (settings.alignment == SpriteAlignment.Custom) { settings.customPivot = EGL.Vector2Field("Custom Pivot", settings.customPivot); } settings.densePacked = EGL.Toggle("Dense Pack", settings.densePacked); settings.border = EGL.IntField("Border", settings.border); EGL.Space(); if (settings.generatePrefab) { using (new GL.HorizontalScope(EditorStyles.toolbar)) { GL.Label("Prefab Options"); } EGL.BeginHorizontal(); string[] opetions = SortingLayer.layers.Select(it => it.name).ToArray(); settings.sortIndex = EGL.Popup("Sort In Layer", settings.sortIndex, opetions); settings.spritesSortInLayer = SortingLayer.NameToID(opetions[settings.sortIndex]); if (GL.Button("Edit", GL.Width(36))) { Selection.objects = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset"); } EGL.EndHorizontal(); settings.orderInLayerInterval = EGL.IntField("Interval of order in layer", settings.orderInLayerInterval); } EGL.Space(); using (new GL.HorizontalScope(EditorStyles.toolbar)) { GL.Label("Output"); } settings.atlasOutputDirectory = PathSelection("Atlas Directory", settings.atlasOutputDirectory); settings.clipOutputDirectory = PathSelection("Anim Clip Directory", settings.clipOutputDirectory); settings.controllerPolicy = (AnimControllerOutputPolicy)EGL.EnumPopup("Anim Controller Policy", settings.controllerPolicy); if (settings.controllerPolicy == AnimControllerOutputPolicy.CreateOrOverride || settings.controllerPolicy == AnimControllerOutputPolicy.CreateNotOverride) { settings.animControllerOutputPath = PathSelection("Anim Controller Directory", settings.animControllerOutputPath); } if (settings.generatePrefab) { settings.prefabsDirectory = PathSelection("Prefab Directory", settings.prefabsDirectory); } }
internal void OnGUI() { GUI.Label(new Rect(0, 0, position.width, position.height), GUIContent.none, "grey_border"); GUILayout.Space(3); GUILayout.Label(Styles.header, EditorStyles.boldLabel); GUILayout.Space(4); GUILayout.BeginHorizontal(); GUILayout.Label(Styles.nameLabel, GUILayout.Width(90f)); m_Name = EditorGUILayout.TextField(m_Name); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(Styles.gridLabel, GUILayout.Width(90f)); EditorGUI.BeginChangeCheck(); var newLayout = (Grid.CellLayout)EditorGUILayout.EnumPopup(m_Layout); if (EditorGUI.EndChangeCheck()) { // Set useful user settings for certain layouts switch (newLayout) { case Grid.CellLayout.Rectangle: case Grid.CellLayout.Hexagon: { m_CellSizing = GridPalette.CellSizing.Automatic; m_CellSize = new Vector3(1, 1, 0); break; } case Grid.CellLayout.Isometric: case Grid.CellLayout.IsometricZAsY: { m_CellSizing = GridPalette.CellSizing.Manual; m_CellSize = new Vector3(1, 0.5f, 1); break; } } m_Layout = newLayout; } GUILayout.EndHorizontal(); if (m_Layout == GridLayout.CellLayout.Hexagon) { GUILayout.BeginHorizontal(); float oldLabelWidth = UnityEditor.EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 94; m_HexagonLayout = EditorGUILayout.Popup(Styles.hexagonLabel, m_HexagonLayout, Styles.hexagonSwizzleTypeLabel); EditorGUIUtility.labelWidth = oldLabelWidth; GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); GUILayout.Label(Styles.sizeLabel, GUILayout.Width(90f)); m_CellSizing = (GridPalette.CellSizing)EditorGUILayout.EnumPopup(m_CellSizing); GUILayout.EndHorizontal(); using (new EditorGUI.DisabledScope(m_CellSizing == GridPalette.CellSizing.Automatic)) { GUILayout.BeginHorizontal(); GUILayout.Label(GUIContent.none, GUILayout.Width(90f)); m_CellSize = EditorGUILayout.Vector3Field(GUIContent.none, m_CellSize); GUILayout.EndHorizontal(); } GUILayout.FlexibleSpace(); // Cancel, Ok GUILayout.BeginHorizontal(); GUILayout.Space(10); if (GUILayout.Button(Styles.cancel)) { Close(); } using (new EditorGUI.DisabledScope(!Utils.Paths.IsValidAssetPath(m_Name))) { if (GUILayout.Button(Styles.ok)) { // case 1077362: Close window to prevent overlap with OS folder window when saving new palette asset Close(); var swizzle = Grid.CellSwizzle.XYZ; if (m_Layout == GridLayout.CellLayout.Hexagon) { swizzle = Styles.hexagonSwizzleTypeValue[m_HexagonLayout]; } GameObject go = GridPaletteUtility.CreateNewPaletteNamed(m_Name, m_Layout, m_CellSizing, m_CellSize, swizzle); if (go != null) { m_Owner.palette = go; m_Owner.Repaint(); } GUIUtility.ExitGUI(); } } GUILayout.Space(10); GUILayout.EndHorizontal(); }