private void OnDrawLayer(Rect rect, int index, bool isActive, bool isFocused) { var lineHeight = EditorGUIUtility.singleLineHeight; var lineSpacing = EditorGUIUtility.standardVerticalSpacing; var lineOffset = lineHeight + lineSpacing; var y = rect.y + lineSpacing; var layer = _layers[index]; var obj = layer.OutlineSettings; var enabled = layer.Enabled; var name = layer.NameTag; var color = layer.OutlineColor; var width = layer.OutlineWidth; var renderMode = layer.OutlineRenderMode; var blurIntensity = layer.OutlineIntensity; EditorGUI.BeginChangeCheck(); // Header { var rc = new Rect(rect.x, y, rect.width, lineHeight); var bgRect = new Rect(rect.x - 2, y - 2, rect.width + 3, lineHeight + 3); // Header background EditorGUI.DrawRect(rc, Color.gray); EditorGUI.DrawRect(new Rect(bgRect.x, bgRect.y, bgRect.width, 1), Color.gray); EditorGUI.DrawRect(new Rect(bgRect.x, bgRect.yMax, bgRect.width, 1), Color.gray); EditorGUI.DrawRect(new Rect(bgRect.x, bgRect.y, 1, bgRect.height), Color.gray); EditorGUI.DrawRect(new Rect(bgRect.xMax, bgRect.y, 1, bgRect.height), Color.gray); obj = (OutlineSettings)EditorGUI.ObjectField(rc, " ", obj, typeof(OutlineSettings), true); enabled = EditorGUI.ToggleLeft(rc, "Layer #" + index.ToString(), enabled, EditorStyles.boldLabel); y += lineOffset; } // Layer properties { name = EditorGUI.TextField(new Rect(rect.x, y, rect.width, lineHeight), "Name", name); y += lineOffset; } // Outline settings { EditorGUI.BeginDisabledGroup(obj != null); color = EditorGUI.ColorField(new Rect(rect.x, y, rect.width, lineHeight), "Color", color); y += lineOffset; width = EditorGUI.IntSlider(new Rect(rect.x, y, rect.width, lineHeight), "Width", width, OutlineResources.MinWidth, OutlineResources.MaxWidth); y += lineOffset; renderMode = (OutlineRenderFlags)EditorGUI.EnumFlagsField(new Rect(rect.x, y, rect.width, lineHeight), "Render Flags", renderMode); y += lineOffset; if ((renderMode & OutlineRenderFlags.Blurred) != 0) { blurIntensity = EditorGUI.Slider(new Rect(rect.x, y, rect.width, lineHeight), "Blur Intensity", blurIntensity, OutlineResources.MinIntensity, OutlineResources.MaxIntensity); } EditorGUI.EndDisabledGroup(); } if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(_layers, "Layers changed"); EditorUtility.SetDirty(_layers); layer.OutlineSettings = obj; layer.Enabled = enabled; layer.NameTag = name; layer.OutlineWidth = width; layer.OutlineColor = color; layer.OutlineRenderMode = renderMode; layer.OutlineIntensity = blurIntensity; } }
private void DrawHandles() { var tf = m_Comp.transform; // Latitude North & Max. Distance. Vector3 fwd = tf.forward; Vector3 normal = Vector3.Cross(fwd, tf.up); Matrix4x4 matrix = Matrix4x4.TRS( tf.position, Quaternion.LookRotation(fwd, normal), Vector3.one ); using (new Handles.DrawingScope(matrix)) { EditorGUI.BeginChangeCheck(); { m_ArcHandleLatN.angle = m_Comp.LatAngleNorth; m_ArcHandleLatN.radius = m_Comp.MaxDistance; m_ArcHandleLatN.DrawHandle(); } if (EditorGUI.EndChangeCheck()) { if (m_Comp.LatAngleNorth != m_ArcHandleLatN.angle) { m_Comp.LatAngleNorth = m_ArcHandleLatN.angle; } else if (m_Comp.MaxDistance != m_ArcHandleLatN.radius) { m_Comp.MaxDistance = m_ArcHandleLatN.radius; } } } // Latitude South & Max. Distance. normal = Vector3.Cross(fwd, -tf.up); matrix = Matrix4x4.TRS( tf.position, Quaternion.LookRotation(fwd, normal), Vector3.one ); using (new Handles.DrawingScope(matrix)) { EditorGUI.BeginChangeCheck(); { m_ArcHandleLatS.angle = m_Comp.LatAngleSouth; m_ArcHandleLatS.radius = m_Comp.MaxDistance; m_ArcHandleLatS.DrawHandle(); } if (EditorGUI.EndChangeCheck()) { if (m_Comp.LatAngleSouth != m_ArcHandleLatS.angle) { m_Comp.LatAngleSouth = m_ArcHandleLatS.angle; } else if (m_Comp.MaxDistance != m_ArcHandleLatS.radius) { m_Comp.MaxDistance = m_ArcHandleLatS.radius; } } } // Longitude & Max. Distance. normal = Vector3.Cross(fwd, tf.right); matrix = Matrix4x4.TRS( tf.position, Quaternion.LookRotation(fwd, normal), Vector3.one ); using (new Handles.DrawingScope(matrix)) { EditorGUI.BeginChangeCheck(); { m_ArcHandleLon.angle = m_Comp.LonAngle; m_ArcHandleLon.radius = m_Comp.MaxDistance; m_ArcHandleLon.DrawHandle(); } if (EditorGUI.EndChangeCheck()) { if (m_Comp.LonAngle != m_ArcHandleLon.angle) { m_Comp.LonAngle = m_ArcHandleLon.angle; } else if (m_Comp.MaxDistance != m_ArcHandleLon.radius) { m_Comp.MaxDistance = m_ArcHandleLon.radius; } } } // Minimum Distance. float min = m_Comp.MinDistance; EditorGUI.BeginChangeCheck(); { min = Handles.RadiusHandle(tf.rotation, tf.position, min); } if (EditorGUI.EndChangeCheck()) { m_Comp.MinDistance = min; } }
private void DrawSetter() { GUILayout.Label(selectedAsset.id, Styles.SetterTitle, GUILayout.MaxHeight(25)); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("ID"); GUILayout.Label(string.Format("<b>{0}</b> (#{1:X})", selectedAsset.id, selectedAsset.index), Styles.SetterFont); } EditorGUILayout.EndHorizontal(); TexChar c = selectedChar; // if (c.supported) { EditorGUILayout.BeginHorizontal(); for (int i = 0; i < 2; i++) { if (GUILayout.Toggle(i == setterState, Styles.SetterHeaderContent[i], Styles.SetterHeader[i])) { setterState = i; } } EditorGUILayout.EndHorizontal(); EditorGUI.BeginChangeCheck(); if (setterState == 0) { // Create an thumbnail switch (selectedAsset.type) { case TexAssetType.Font: EditorGUILayout.LabelField(Styles.GetCharMapContent(selectedAsset.chars[selectedCharIdx].characterIndex), Styles.SetterPreview, GUILayout.Height(selectedFont.asset.lineHeight * 2.2f)); break; case TexAssetType.Sprite: Rect r2 = EditorGUILayout.GetControlRect(GUILayout.Height(selectedSprite.lineHeight * EditorGUIUtility.labelWidth)); EditorGUI.LabelField(r2, GUIContent.none, Styles.SetterPreview); r2.width *= .5f; r2.x += r2.width * .5f; var sprt = selectedSprite.GenerateMetric(selectedChar.characterIndex); GUI.DrawTextureWithTexCoords(r2, selectedSprite.Texture(), sprt.uv); break; #if TEXDRAW_TMP case TexAssetType.FontSigned: r2 = EditorGUILayout.GetControlRect(GUILayout.Height(selectedSigned.LineHeight() * EditorGUIUtility.labelWidth)); EditorGUI.LabelField(r2, GUIContent.none, Styles.SetterPreview); r2.width *= .5f; r2.x += r2.width * .5f; sprt = selectedSigned.GenerateMetric(selectedChar.characterIndex); GUI.DrawTextureWithTexCoords(r2, selectedSigned.asset.atlas, sprt.uv); break; #endif default: break; } // Basic info stuff EditorGUILayout.LabelField("Index", string.Format("<b>{0}</b> (#{0:X2})", selectedCharIdx), Styles.SetterFont); EditorGUILayout.LabelField("Character Index", "<b>" + selectedChar.characterIndex.ToString() + "</b> (#" + ((int)selectedChar.characterIndex).ToString("X2") + ")", Styles.SetterFont); EditorGUILayout.LabelField("Symbol Definition"); EditorGUILayout.BeginHorizontal(); { c.symbolAlt = EditorGUILayout.TextField(c.symbolAlt); //Secondary c.symbolName = EditorGUILayout.TextField(c.symbolName); //Primary } EditorGUILayout.EndHorizontal(); c.type = (CharType)EditorGUILayout.EnumPopup("Symbol Type", c.type); EditorGUILayout.LabelField("In math, this mapped as:"); c.characterMap = EditorGUILayout.IntPopup(c.characterMap, Styles.SetterCharMap, Styles.SetterCharMapInt); } else { SetterScroll = EditorGUILayout.BeginScrollView(SetterScroll, GUILayout.ExpandHeight(true)); { EditorGUILayout.LabelField(string.Format("Hash \t : <b>{0}</b> (#{1:X1}{2:X2})", selectedFontIdx * 256 + selectedCharIdx, selectedFontIdx, selectedCharIdx), Styles.SetterFont); c.nextLargerHash = SubDrawThumbnail(c.nextLargerHash, "Is Larger Character Exist?", Styles.SetterNextLarger); EditorGUILayout.Space(); if (EditorGUILayout.ToggleLeft("Is Part of Extension?", c.extensionExist)) { EditorGUI.indentLevel++; c.extensionExist = true; c.extensionHorizontal = EditorGUILayout.ToggleLeft("Is This Horizontal?", c.extensionHorizontal); c.extentTopHash = SubDrawThumbnail(c.extentTopHash, c.extensionHorizontal ? "Has Left Extension?" : "Has Top Extension?", Styles.SetterExtendTop); c.extentMiddleHash = SubDrawThumbnail(c.extentMiddleHash, "Has Middle Extension?", Styles.SetterExtendMiddle); c.extentBottomHash = SubDrawThumbnail(c.extentBottomHash, c.extensionHorizontal ? "Has Right Extension?" : "Has Bottom Extension?", Styles.SetterExtendBottom); c.extentRepeatHash = SubDrawThumbnail(c.extentRepeatHash, "Has Tiled Extension?", Styles.SetterExtendRepeat); EditorGUI.indentLevel--; } else { c.extensionExist = false; } } EditorGUILayout.EndScrollView(); } if (EditorGUI.EndChangeCheck()) { RecordDirty(); lastCharChanged = true; } } }
void OnGUI() { maxSize = new Vector2(390f, 298f); minSize = maxSize; GUILayout.Space(10f); var centeredStyle = new GUIStyle(GUI.skin.GetStyle("Label")); centeredStyle.alignment = TextAnchor.UpperCenter; GUILayout.Label(logoTex, centeredStyle); GUIStyle contentStyle = new GUIStyle(EditorStyles.label); contentStyle.alignment = TextAnchor.MiddleCenter; UnityEngine.Audio.AudioMixerGroup prevSfxMixerGroup = config.sfxMixerGroup; UnityEngine.Audio.AudioMixerGroup prevBgmMixerGroup = config.bgmMixerGroup; LayerMask prevOccludeCheck = config.occludeCheck; float prevOccludeMultiplier = config.occludeMultiplier; uint prevMaxAudioSources = config.maxAudioSources; string prevRuntimeIdentifierPrefix = config.runtimeIdentifierPrefix; GUIStyle versionStyle = new GUIStyle(EditorStyles.miniLabel); versionStyle.alignment = TextAnchor.MiddleCenter; EditorGUILayout.LabelField("Global Config", versionStyle); GUILayout.Space(5f); EditorGUI.BeginChangeCheck(); UnityEngine.Audio.AudioMixerGroup sfxMixerGroup = EditorGUILayout.ObjectField(new GUIContent("SFX Mixer Group", "Default SFX Mixer Group Output"), config.sfxMixerGroup, typeof(UnityEngine.Audio.AudioMixerGroup), false) as UnityEngine.Audio.AudioMixerGroup; if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(config, "Changed SFX Mixer Group"); config.sfxMixerGroup = sfxMixerGroup; } EditorGUI.BeginChangeCheck(); UnityEngine.Audio.AudioMixerGroup bgmMixerGroup = EditorGUILayout.ObjectField(new GUIContent("BGM Mixer Group", "Default BGM Mixer Group Output"), config.bgmMixerGroup, typeof(UnityEngine.Audio.AudioMixerGroup), false) as UnityEngine.Audio.AudioMixerGroup; if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(config, "Changed BGM Mixer Group"); config.bgmMixerGroup = bgmMixerGroup; } EditorGUI.BeginChangeCheck(); LayerMask occludeCheck = LayerMaskField(new GUIContent("Occlude Check Layer", "Layer Mask used for check whether or not a collider occludes the sound. Tip: Use a unique layer for the occludable colliders, then you can have more control putting invisible triggers on the objects that you want to occludes sound"), config.occludeCheck); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(config, "Changed Occlude Check Layer"); config.occludeCheck = occludeCheck; } EditorGUI.BeginChangeCheck(); float occludeMultiplier = Mathf.Clamp01(EditorGUILayout.Slider(new GUIContent("Occlude Multiplier", "The higher the value, the less the audio is heard when occluded"), Mathf.Clamp01(config.occludeMultiplier), 0f, 1f)); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(config, "Changed Occlude Multiplier"); config.occludeMultiplier = occludeMultiplier; } EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); string prefix = EditorGUILayout.TextField(new GUIContent("Runtime Identifier Prefix", "The prefix used to define Runtime Identifiers"), config.runtimeIdentifierPrefix); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(config, "Changed Runtime Identifier Prefix"); config.runtimeIdentifierPrefix = prefix; } EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); uint maxAudioSources = (uint)Mathf.Clamp(EditorGUILayout.IntField(new GUIContent("Max Audio Sources", "Max pooled Multi Audio Sources"), (int)Mathf.Clamp(config.maxAudioSources, 1, 2048)), 1, 2048); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(config, "Changed Max Audio Sources"); config.maxAudioSources = maxAudioSources; } EditorGUILayout.HelpBox("To get the best performance only increase this value if you are having problems when playing pooled audios, otherwise keep this value as low as possible.", MessageType.Info); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); float dopplerFactor = Mathf.Clamp(EditorGUILayout.FloatField(new GUIContent("Doppler Factor", "Set how audible the Doppler effect is. Use 0 to disable it. Use 1 make it audible for fast moving objects."), Mathf.Clamp(config.dopplerFactor, 0, 10)), 0, 10); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(config, "Changed Doppler Factor"); config.dopplerFactor = dopplerFactor; } if (prevRuntimeIdentifierPrefix != config.runtimeIdentifierPrefix || prevSfxMixerGroup != config.sfxMixerGroup || prevBgmMixerGroup != config.bgmMixerGroup || config.occludeCheck != prevOccludeCheck || prevOccludeMultiplier != config.occludeMultiplier || prevMaxAudioSources != config.maxAudioSources) { EditorUtility.SetDirty(config); } }
override public void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { Material targetMat = materialEditor.target as Material; //get properties FindProperties(properties, targetMat); if (emissionColor.colorValue != Color.black) { showGIField = true; } else { showGIField = false; } EditorGUI.BeginChangeCheck(); //main settings if (HandleBehavior("Main", ref showMainBehavior, materialEditor)) { ColorProperty(mainColor, false, false, new GUIContent(mainColor.displayName)); materialEditor.TexturePropertySingleLine(new GUIContent(mainTex.displayName), mainTex); materialEditor.TexturePropertySingleLine(new GUIContent(bumpMap.displayName), bumpMap); EditorGUI.BeginChangeCheck(); ColorProperty(emissionColor, false, true, new GUIContent(emissionColor.displayName)); if (showGIField) { materialEditor.LightmapEmissionProperty(MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1); } if (EditorGUI.EndChangeCheck()) { SetGIFlags(); } materialEditor.TextureScaleOffsetProperty(mainTex); } //light settings if (HandleBehavior("Light", ref showLightBehavior, materialEditor)) { materialEditor.ShaderProperty(lTreshold, lTreshold.displayName); materialEditor.ShaderProperty(lightSmoothness, lightSmoothness.displayName); } //custom shadow settings if (HandleBehavior("Shadow", ref showShadowBehavior, materialEditor)) { ColorProperty(highlightColor, false, false, new GUIContent(highlightColor.displayName)); ColorProperty(shadowColor, false, false, new GUIContent(shadowColor.displayName)); materialEditor.ShaderProperty(shadowIntensity, shadowIntensity.displayName); } //render settings if (HandleBehavior("Render", ref showRenderBehavior, materialEditor)) { materialEditor.EnableInstancingField(); } //specular settings if (HandleBehavior("Specular", ref showSpecularBehavior, materialEditor)) { ColorProperty(specularColor, false, false, new GUIContent(specularColor.displayName)); materialEditor.ShaderProperty(shininess, shininess.displayName); materialEditor.ShaderProperty(specularIntensity, specularIntensity.displayName); } //rim settings if (HandleBehavior("Rim", ref showRimBehavior, materialEditor)) { ColorProperty(rimColor, false, false, new GUIContent(rimColor.displayName)); materialEditor.ShaderProperty(rimSize, rimSize.displayName); materialEditor.ShaderProperty(rimIntensity, rimIntensity.displayName); materialEditor.ShaderProperty(rimSmoothness, rimSmoothness.displayName); } //set outline if (HandleBehavior("Outline", ref showOutlineBehavior, materialEditor)) { ColorProperty(outlineColor, false, false, new GUIContent(outlineColor.displayName)); materialEditor.ShaderProperty(outlineSize, outlineSize.displayName); } ///Other EditorGUI.EndChangeCheck(); }
private bool DrawCCUISetting(int ccsd, SerializedProperty thisCCSettings, List <string> ccSlotsNamesList) { var changed = false; var startingRect = GUILayoutUtility.GetRect(0.0f, EditorGUIUtility.singleLineHeight, GUILayout.ExpandWidth(true)); var thisSlot = thisCCSettings.GetArrayElementAtIndex(ccsd).FindPropertyRelative("raceSlot").stringValue; var thisSlotIndex = baseSlotsNamesList.IndexOf(thisSlot); var thisCompatibleSlot = thisCCSettings.GetArrayElementAtIndex(ccsd).FindPropertyRelative("compatibleRaceSlot").stringValue; var thisCompatibleSlotIndex = ccSlotsNamesList.IndexOf(thisCompatibleSlot); var thisOverlaysMatch = thisCCSettings.GetArrayElementAtIndex(ccsd).FindPropertyRelative("overlaysMatch").boolValue; var thisSlotRect = startingRect; var thisEqualsLabelRect = startingRect; var thisCompatibleSlotRect = startingRect; //var thisOverlaysLabelRect = startingRect; var thisOverlaysMatchRect = startingRect; var thisDeleteRect = startingRect; thisSlotRect.width = (startingRect.width - 50f - 22f - 22f) / 2; thisEqualsLabelRect.xMin = thisSlotRect.xMax; thisEqualsLabelRect.width = 22f; thisCompatibleSlotRect.xMin = thisEqualsLabelRect.xMax; thisCompatibleSlotRect.width = thisSlotRect.width; thisOverlaysMatchRect.xMin = thisCompatibleSlotRect.xMax + 22f; thisOverlaysMatchRect.width = 50f - 22f; thisDeleteRect.xMin = thisOverlaysMatchRect.xMax; thisDeleteRect.width = 22f; EditorGUI.BeginChangeCheck(); var newSlotIndex = EditorGUI.Popup(thisSlotRect, "", thisSlotIndex, baseSlotsNamesList.ToArray()); if (EditorGUI.EndChangeCheck()) { if (newSlotIndex != thisSlotIndex) { thisCCSettings.GetArrayElementAtIndex(ccsd).FindPropertyRelative("raceSlot").stringValue = baseSlotsNamesList[newSlotIndex]; changed = true; } } EditorGUI.LabelField(thisEqualsLabelRect, "=="); EditorGUI.BeginChangeCheck(); var newCompatibleSlotIndex = EditorGUI.Popup(thisCompatibleSlotRect, "", thisCompatibleSlotIndex, ccSlotsNamesList.ToArray()); if (EditorGUI.EndChangeCheck()) { if (newCompatibleSlotIndex != thisCompatibleSlotIndex) { thisCCSettings.GetArrayElementAtIndex(ccsd).FindPropertyRelative("compatibleRaceSlot").stringValue = ccSlotsNamesList[newCompatibleSlotIndex]; /*var ccSlotsOverlays = ccSlotsList[newCompatibleSlotIndex].GetOverlayList(); * thisCCSettings.GetArrayElementAtIndex(ccsd).FindPropertyRelative("compatibleRaceSlotOverlays").arraySize = ccSlotsOverlays.Count; * for (int ccai = 0; ccai < ccSlotsOverlays.Count; ccai++) * thisCCSettings.GetArrayElementAtIndex(ccsd).FindPropertyRelative("compatibleRaceSlotOverlays").GetArrayElementAtIndex(ccai).stringValue = ccSlotsOverlays[ccai].overlayName;*/ changed = true; } } //we need a gui style for this that centers this horizontally EditorGUI.BeginChangeCheck(); var newOverlaysMatch = EditorGUI.ToggleLeft(thisOverlaysMatchRect, " ", thisOverlaysMatch); if (EditorGUI.EndChangeCheck()) { if (newOverlaysMatch != thisOverlaysMatch) { thisCCSettings.GetArrayElementAtIndex(ccsd).FindPropertyRelative("overlaysMatch").boolValue = newOverlaysMatch; changed = true; } } if (GUI.Button(thisDeleteRect, "X", EditorStyles.miniButton)) { thisCCSettings.DeleteArrayElementAtIndex(ccsd); changed = true; } //******NEEDS TO BE IN THE RETURN***// //if (changed) // serializedObject.ApplyModifiedProperties(); //GUILayout.EndHorizontal(); GUILayout.Space(2f); return(changed); }
private void DrawButtonInfo(ButtonInfo info, bool editingEnabled) { if (editingEnabled) { EditorGUI.BeginChangeCheck(); } var targetBehaviour = (MonoBehaviour)target; bool isOpaque = targetBehaviour.isActiveAndEnabled; float alpha = (isOpaque) ? 1.0f : 0.5f; // START PUSH Handles.color = ApplyAlpha(Color.cyan, alpha); float newStartPushDistance = DrawPlaneAndHandle(startPlaneVertices, info.PlaneExtents * 0.5f, info.StartPushDistance, info, "Start Push Distance", editingEnabled); if (editingEnabled && newStartPushDistance != info.StartPushDistance) { EnforceDistanceOrdering(ref info); info.StartPushDistance = ClampStartPushDistance(Mathf.Min(newStartPushDistance, info.ReleaseDistance)); } // RELEASE DISTANCE Handles.color = ApplyAlpha(Color.red, alpha); float newReleaseDistance = DrawPlaneAndHandle(releasePlaneVertices, info.PlaneExtents * 0.3f, info.ReleaseDistance, info, "Release Distance", editingEnabled); if (editingEnabled && newReleaseDistance != info.ReleaseDistance) { EnforceDistanceOrdering(ref info); info.ReleaseDistance = Mathf.Clamp(newReleaseDistance, info.StartPushDistance, info.PressDistance); } // PRESS DISTANCE Handles.color = ApplyAlpha(Color.yellow, alpha); float newPressDistance = DrawPlaneAndHandle(pressPlaneVertices, info.PlaneExtents * 0.35f, info.PressDistance, info, "Press Distance", editingEnabled); if (editingEnabled && newPressDistance != info.PressDistance) { EnforceDistanceOrdering(ref info); info.PressDistance = Mathf.Clamp(newPressDistance, info.ReleaseDistance, info.MaxPushDistance); } // MAX PUSH var purple = new Color(0.28f, 0.0f, 0.69f); Handles.color = ApplyAlpha(purple, alpha); float newMaxPushDistance = DrawPlaneAndHandle(endPlaneVertices, info.PlaneExtents * 0.5f, info.MaxPushDistance, info, "Max Push Distance", editingEnabled); if (editingEnabled && newMaxPushDistance != info.MaxPushDistance) { EnforceDistanceOrdering(ref info); info.MaxPushDistance = Mathf.Max(newMaxPushDistance, info.PressDistance); } if (editingEnabled && EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, string.Concat("Modify Button Planes of ", button.name)); startPushDistance.floatValue = info.StartPushDistance; maxPushDistance.floatValue = info.MaxPushDistance; pressDistance.floatValue = info.PressDistance; releaseDistanceDelta.floatValue = info.PressDistance - info.ReleaseDistance; serializedObject.ApplyModifiedProperties(); } // Draw dotted lines showing path from beginning to end of button path Handles.color = Color.Lerp(Color.cyan, Color.clear, 0.25f); Handles.DrawDottedLine(startPlaneVertices[0], endPlaneVertices[0], 2.5f); Handles.DrawDottedLine(startPlaneVertices[1], endPlaneVertices[1], 2.5f); Handles.DrawDottedLine(startPlaneVertices[2], endPlaneVertices[2], 2.5f); Handles.DrawDottedLine(startPlaneVertices[3], endPlaneVertices[3], 2.5f); }
public void DrawGraphExplorer(Rect r) { var result = EditorGUILayout.Popup(CurrentViewIndex, ExplorerViewsStrings); if (result != CurrentViewIndex) { CurrentViewIndex = result; TreeModel.Data = CurrentViewProvider.GetItems(Container.Resolve <IRepository>()); } if (_hardDirty) { if (TreeModel == null) { return; } if (WorkspaceService == null || WorkspaceService.CurrentWorkspace == null) { TreeModel.Data = new List <IItem>(); } else { TreeModel.Data = CurrentViewProvider.GetItems(Container.Resolve <IRepository>()); TreeModel.IsDirty = true; } _hardDirty = false; } if (TreeModel == null) { return; } if (TreeModel.IsDirty) { TreeModel.Refresh(); } Rect window = r; var searcbarRect = window.WithHeight(32).Pad(5, 22, 5, 5); var listRect = window.Below(searcbarRect).Clip(window).PadSides(5); var searchIconRect = new Rect().WithSize(32, 32).InnerAlignWithBottomRight(searcbarRect).AlignHorisonallyByCenter(searcbarRect).PadSides(10); PlatformDrawer.DrawImage(searchIconRect, "SearchIcon", true); GUI.SetNextControlName("GraphTreeSearch"); EditorGUI.BeginChangeCheck(); SearchCriteria = GUI.TextField(searcbarRect, SearchCriteria ?? "", ElementDesignerStyles.SearchBarTextStyle); PlatformDrawer.DrawImage(searchIconRect, "SearchIcon", true); if (EditorGUI.EndChangeCheck()) { if (string.IsNullOrEmpty(SearchCriteria)) { TreeModel.Predicate = null; } else { var sc = SearchCriteria.ToLower(); TreeModel.Predicate = i => { if (string.IsNullOrEmpty(i.Title)) { return(false); } if ( CultureInfo.CurrentCulture.CompareInfo.IndexOf(i.Title, SearchCriteria, CompareOptions.IgnoreCase) != -1) { return(true); } if (!string.IsNullOrEmpty(i.SearchTag) && CultureInfo.CurrentCulture.CompareInfo.IndexOf(i.SearchTag, SearchCriteria, CompareOptions.IgnoreCase) != -1) { return(true); } return(false); }; } TreeModel.IsDirty = true; } // PlatformDrawer.DrawTextbox("GraphTreeWindow_Search",searcbarRect,_searchCriterial,GUI.skin.textField.WithFont("Verdana",15), // (val,submit) => // { // _searchCriterial = val; // }); InvertApplication.SignalEvent <IDrawTreeView>(_ => { _.DrawTreeView(listRect, TreeModel, (m, i) => { TryNavigateToItem(i); }); }); GUI.FocusControl("GraphTreeSearch"); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { BlendModePopup(); GUILayout.Space(8f); expandStandardProperties = GUILayout.Toggle(expandStandardProperties, "STANDARD PROPERTIES", EditorStyles.toolbarButton); if (expandStandardProperties) { //Background var vertRect = EditorGUILayout.BeginVertical(); vertRect.xMax += 2; vertRect.xMin--; GUI.Box(vertRect, "", "RL Background"); GUILayout.Space(4f); // Primary properties GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel); DoAlbedoArea(material); DoSpecularMetallicArea(); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, bumpMap, bumpMap.textureValue != null ? bumpScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.heightMapText, heightMap, heightMap.textureValue != null ? heigtMapScale : null); m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionMap, occlusionMap.textureValue != null ? occlusionStrength : null); DoEmissionArea(material); m_MaterialEditor.TexturePropertySingleLine(Styles.detailMaskText, detailMask); EditorGUI.BeginChangeCheck(); m_MaterialEditor.TextureScaleOffsetProperty(albedoMap); if (EditorGUI.EndChangeCheck()) { emissionMap.textureScaleAndOffset = albedoMap.textureScaleAndOffset; } // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake EditorGUILayout.Space(); // Secondary properties GUILayout.Label(Styles.secondaryMapsText, EditorStyles.boldLabel); m_MaterialEditor.TexturePropertySingleLine(Styles.detailAlbedoText, detailAlbedoMap); m_MaterialEditor.TexturePropertySingleLine(Styles.detailNormalMapText, detailNormalMap, detailNormalMapScale); m_MaterialEditor.TextureScaleOffsetProperty(detailAlbedoMap); m_MaterialEditor.ShaderProperty(uvSetSecondary, Styles.uvSetLabel.text); // Third properties /* * if (reflections != null) * GUILayout.Label(Styles.forwardText, EditorStyles.boldLabel); * //if (highlights != null) * //m_MaterialEditor.ShaderProperty(highlights, Styles.highlightsText); * if (reflections != null) * m_MaterialEditor.ShaderProperty(reflections, Styles.reflectionsText); */ GUILayout.Space(8f); EditorGUILayout.EndVertical(); } EditorGUILayout.Space(); //---------------------------------------------------------------- // TOONY COLORS PRO 2 expandTCP2Properties = GUILayout.Toggle(expandTCP2Properties, "TOONY COLORS PRO 2", EditorStyles.toolbarButton); if (expandTCP2Properties) { //Background var vertRect = EditorGUILayout.BeginVertical(); vertRect.xMax += 2; vertRect.xMin--; GUI.Box(vertRect, "", "RL Background"); GUILayout.Space(4f); GUILayout.Label("Base Properties", EditorStyles.boldLabel); m_MaterialEditor.ColorProperty(tcp2_highlightColor, Styles.tcp2_highlightColorText); m_MaterialEditor.ColorProperty(tcp2_shadowColor, Styles.tcp2_shadowColorText); EditorGUILayout.Space(); //Shader Generator Properties for (var i = 0; i < SGProperties.Count; i++) { if (SGProperties[i].type == MaterialProperty.PropType.Texture) { //Compensate margins so that texture slot looks square var fw = EditorGUIUtility.fieldWidth; EditorGUIUtility.fieldWidth = 64f; m_MaterialEditor.ShaderProperty(SGProperties[i], SGProperties[i].displayName); EditorGUIUtility.fieldWidth = fw; } else { m_MaterialEditor.ShaderProperty(SGProperties[i], SGProperties[i].displayName); } } GUILayout.Space(8f); GUILayout.EndVertical(); // TCP2 End //---------------------------------------------------------------- } GUILayout.Space(10f); } if (EditorGUI.EndChangeCheck()) { foreach (var obj in blendMode.targets) { MaterialChanged((Material)obj, m_WorkflowMode); } } }
void BluePrintDataBase() { EditorGUILayout.BeginVertical("Box"); if (inventoryItemList == null) { inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase"); } if (bluePrintDatabase == null) { bluePrintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase"); } GUILayout.BeginHorizontal(); toolbarInt1 = GUILayout.Toolbar(toolbarInt1, toolbarStrings1, GUILayout.Width(position.width - 20)); //creating a toolbar(tabs) to navigate what you wanna do GUILayout.EndHorizontal(); scrollPosition1 = EditorGUILayout.BeginScrollView(scrollPosition1); GUILayout.Space(10); if (toolbarInt1 == 0) //if equal 0 than it is "Create Item" { GUI.color = Color.white; try { GUILayout.BeginVertical("Box"); string[] items = new string[inventoryItemList.itemList.Count]; //create a string array in length of the itemcount for (int i = 1; i < items.Length; i++) //go through the item array { items[i] = inventoryItemList.itemList[i].itemName; //and paste all names into the array } EditorGUILayout.BeginHorizontal(); finalItemID = EditorGUILayout.Popup("Final Item", finalItemID, items, EditorStyles.popup); amountOfFinalItem = EditorGUILayout.IntField("Value", amountOfFinalItem); EditorGUILayout.EndHorizontal(); //timeToCraft = EditorGUILayout.FloatField("Time to craft", timeToCraft); EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); amountofingredients = EditorGUILayout.IntSlider("Ingredients", amountofingredients, 1, 50, GUILayout.Width(position.width - 38)); if (EditorGUI.EndChangeCheck()) { ingredients = new int[amountofingredients]; amount = new int[amountofingredients]; } for (int i = 0; i < amountofingredients; i++) { EditorGUILayout.BeginHorizontal(); ingredients[i] = EditorGUILayout.Popup("Ingredient " + i, ingredients[i], items, EditorStyles.popup, GUILayout.Width((position.width / 2) - 20)); amount[i] = EditorGUILayout.IntField("Value", amount[i], GUILayout.Width((position.width / 2) - 20)); EditorGUILayout.EndHorizontal(); } GUI.color = Color.green; if (GUILayout.Button("Add Blueprint", GUILayout.Width(position.width - 35), GUILayout.Height(50))) { addBlueprint(); } GUILayout.EndVertical(); } catch { } } if (toolbarInt1 == 1) { if (bluePrintDatabase == null) { bluePrintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase"); if (bluePrintDatabase == null) { bluePrintDatabase = CreateBlueprintDatabase.createBlueprintDatabase(); bluePrintDatabase = (BlueprintDatabase)Resources.Load("BlueprintDatabase"); } } if (bluePrintDatabase.blueprints.Count == 1) { GUILayout.Label("There is no Blueprint in the Database!"); } else { GUILayout.BeginVertical(); for (int i = 1; i < bluePrintDatabase.blueprints.Count; i++) { try { manageItem1.Add(false); GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 23)); manageItem1[i] = EditorGUILayout.Foldout(manageItem1[i], "" + bluePrintDatabase.blueprints[i].finalItem.itemName); //create for every item which you have in the itemdatabase a foldout if (manageItem1[i]) //if you press on it you get this { EditorGUI.indentLevel++; EditorUtility.SetDirty(bluePrintDatabase); //message the scriptableobject that you change something now GUI.color = Color.red; //all upcoming GUIelements get changed to red if (GUILayout.Button("Delete Blueprint", GUILayout.Width(position.width - 38))) //create button that deletes the item { bluePrintDatabase.blueprints.RemoveAt(i); //remove the item out of the itemdatabase EditorUtility.SetDirty(bluePrintDatabase); //and message the database again that you changed something } GUI.color = Color.white; EditorUtility.SetDirty(bluePrintDatabase); bluePrintDatabase.blueprints[i].amountOfFinalItem = EditorGUILayout.IntField("Amount of final items", bluePrintDatabase.blueprints[i].amountOfFinalItem, GUILayout.Width(position.width - 35)); //bluePrintDatabase.blueprints[i].timeToCraft = EditorGUILayout.FloatField("Time to craft", bluePrintDatabase.blueprints[i].timeToCraft); EditorUtility.SetDirty(bluePrintDatabase); string[] items = new string[inventoryItemList.itemList.Count]; //create a string array in length of the itemcount for (int z = 1; z < items.Length; z++) //go through the item array { items[z] = inventoryItemList.itemList[z].itemName; //and paste all names into the array } GUILayout.Label("Ingredients"); for (int k = 0; k < bluePrintDatabase.blueprints[i].ingredients.Count; k++) { GUILayout.BeginHorizontal(); GUI.color = Color.red; if (GUILayout.Button("-")) { bluePrintDatabase.blueprints[i].ingredients.RemoveAt(k); } GUI.color = Color.white; bluePrintDatabase.blueprints[i].ingredients[k] = EditorGUILayout.Popup("Ingredient " + (k + 1), bluePrintDatabase.blueprints[i].ingredients[k], items, EditorStyles.popup); bluePrintDatabase.blueprints[i].amount[k] = EditorGUILayout.IntField("Value", bluePrintDatabase.blueprints[i].amount[k]); GUILayout.EndHorizontal(); } GUI.color = Color.green; if (GUILayout.Button("+")) { bluePrintDatabase.blueprints[i].ingredients.Add(0); bluePrintDatabase.blueprints[i].amount.Add(0); } GUI.color = Color.white; EditorGUI.indentLevel--; EditorUtility.SetDirty(bluePrintDatabase); //message scriptable object that you have changed something } GUILayout.EndVertical(); } catch { } } GUILayout.EndVertical(); } } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
public override void OnInspectorGUI() { if (target == null || serializedObject == null) return; serializedObject.Update(); var script = target as PoseEaser; Rect layoutRect; GUI.enabled = false; EditorGUILayout.PropertyField(scriptProp); GUI.enabled = true; EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(priorityProp); EditorGUILayout.PropertyField(durationProp); var fieldWidth = (EditorGUIUtility.currentViewWidth - EditorGUIUtility.labelWidth) / 3f; // ease position layoutRect = EditorGUILayout.GetControlRect(); layoutRect.width = EditorGUIUtility.labelWidth; EditorGUI.LabelField(layoutRect, "Ease Position"); layoutRect.x += layoutRect.width; layoutRect.width = fieldWidth; script.easePositionX = EditorGUI.ToggleLeft(layoutRect, "X", script.easePositionX); layoutRect.x += layoutRect.width; layoutRect.width = fieldWidth; script.easePositionY = EditorGUI.ToggleLeft(layoutRect, "Y", script.easePositionY); layoutRect.x += layoutRect.width; layoutRect.width = fieldWidth; script.easePositionZ = EditorGUI.ToggleLeft(layoutRect, "Z", script.easePositionZ); // ease rotation layoutRect = EditorGUILayout.GetControlRect(); layoutRect.width = EditorGUIUtility.labelWidth; EditorGUI.LabelField(layoutRect, "Ease Rotation"); layoutRect.x += layoutRect.width; layoutRect.width = fieldWidth; script.easeRotationX = EditorGUI.ToggleLeft(layoutRect, "X", script.easeRotationX); layoutRect.x += layoutRect.width; layoutRect.width = fieldWidth; script.easeRotationY = EditorGUI.ToggleLeft(layoutRect, "Y", script.easeRotationY); layoutRect.x += layoutRect.width; layoutRect.width = fieldWidth; script.easeRotationZ = EditorGUI.ToggleLeft(layoutRect, "Z", script.easeRotationZ); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(target, "Pose Easer Changed"); } serializedObject.ApplyModifiedProperties(); }
void ItemDataBase() { EditorGUILayout.BeginVertical("Box"); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); toolbarInt = GUILayout.Toolbar(toolbarInt, toolbarStrings, GUILayout.Width(position.width - 18)); //creating a toolbar(tabs) to navigate what you wanna do GUILayout.EndHorizontal(); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); GUILayout.Space(10); if (toolbarInt == 0) //if equal 0 than it is "Create Item" { GUI.color = Color.green; if (GUILayout.Button("Add Item", GUILayout.Width(position.width - 23))) { addItem(); showItem = true; } if (showItem) { GUI.color = Color.white; GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 23)); try { int currentIndex = inventoryItemList.itemList.Count - 1; inventoryItemList.itemList[currentIndex].itemName = EditorGUILayout.TextField("Item Name", inventoryItemList.itemList[currentIndex].itemName, GUILayout.Width(position.width - 30)); //textfield for the itemname which you wanna create inventoryItemList.itemList[currentIndex].itemID = currentIndex; //itemID getting set automaticly ...its unique...better do not change it :D GUILayout.BeginHorizontal(); GUILayout.Label("Item Description"); //label ItemDescription GUILayout.Space(47); inventoryItemList.itemList[currentIndex].itemDesc = EditorGUILayout.TextArea(inventoryItemList.itemList[currentIndex].itemDesc, GUILayout.Width(position.width - 180), GUILayout.Height(70)); //Text area for the itemDesc GUILayout.EndHorizontal(); inventoryItemList.itemList[currentIndex].itemIcon = (Sprite)EditorGUILayout.ObjectField("Item Icon", inventoryItemList.itemList[currentIndex].itemIcon, typeof(Sprite), false, GUILayout.Width(position.width - 33)); //objectfield for the itemicon for your new item inventoryItemList.itemList[currentIndex].itemModel = (GameObject)EditorGUILayout.ObjectField("Item Model", inventoryItemList.itemList[currentIndex].itemModel, typeof(GameObject), false, GUILayout.Width(position.width - 33)); //objectfield for the itemmodel for your new item inventoryItemList.itemList[currentIndex].itemType = (ItemType)EditorGUILayout.EnumPopup("Item Type", inventoryItemList.itemList[currentIndex].itemType, GUILayout.Width(position.width - 33)); //the itemtype which you want to have can be selected with the enumpopup inventoryItemList.itemList[currentIndex].maxStack = EditorGUILayout.IntField("Max Stack", inventoryItemList.itemList[currentIndex].maxStack, GUILayout.Width(position.width - 33)); inventoryItemList.itemList[currentIndex].rarity = EditorGUILayout.IntSlider("Rarity", inventoryItemList.itemList[currentIndex].rarity, 0, 100); GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 33)); showItemAttributes = EditorGUILayout.Foldout(showItemAttributes, "Item attributes"); if (showItemAttributes) { GUILayout.BeginHorizontal(); addAttributeName = EditorGUILayout.TextField("Name", addAttributeName); GUI.color = Color.green; if (GUILayout.Button("Add")) { addAttribute(); } GUILayout.EndHorizontal(); GUILayout.Space(10); GUI.color = Color.white; EditorGUI.BeginChangeCheck(); attributeAmount = EditorGUILayout.IntSlider("Amount", attributeAmount, 0, 50); if (EditorGUI.EndChangeCheck()) { attributeName = new int[attributeAmount]; attributeValue = new int[attributeAmount]; } string[] attributes = new string[itemAttributeList.itemAttributeList.Count]; for (int i = 1; i < attributes.Length; i++) { attributes[i] = itemAttributeList.itemAttributeList[i].attributeName; } for (int k = 0; k < attributeAmount; k++) { EditorGUILayout.BeginHorizontal(); attributeName[k] = EditorGUILayout.Popup("Attribute " + (k + 1), attributeName[k], attributes, EditorStyles.popup); attributeValue[k] = EditorGUILayout.IntField("Value", attributeValue[k]); EditorGUILayout.EndHorizontal(); } if (GUILayout.Button("Save")) { List <ItemAttribute> iA = new List <ItemAttribute>(); for (int i = 0; i < attributeAmount; i++) { iA.Add(new ItemAttribute(attributes[attributeName[i]], attributeValue[i])); } inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].itemAttributes = iA; showItem = false; } } GUILayout.EndVertical(); inventoryItemList.itemList[inventoryItemList.itemList.Count - 1].indexItemInList = 999; } catch { } GUILayout.EndVertical(); } } if (toolbarInt == 1) //if toolbar equals 1...manage items...alle items are editable here { if (inventoryItemList == null) { inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase"); } if (inventoryItemList.itemList.Count == 1) //if there is no item in the database you get this...yes it is right to have == 1 { GUILayout.Label("There is no Item in the Database!"); //information that you do not have one } else { GUILayout.BeginVertical(); for (int i = 1; i < inventoryItemList.itemList.Count; i++) //get through all items which are there in the itemdatabase { try { manageItem.Add(false); //foldout is closed at default GUILayout.BeginVertical("Box"); manageItem[i] = EditorGUILayout.Foldout(manageItem[i], "" + inventoryItemList.itemList[i].itemName); //create for every item which you have in the itemdatabase a foldout if (manageItem[i]) //if you press on it you get this { EditorUtility.SetDirty(inventoryItemList); //message the scriptableobject that you change something now GUI.color = Color.red; //all upcoming GUIelements get changed to red if (GUILayout.Button("Delete Item")) //create button that deletes the item { inventoryItemList.itemList.RemoveAt(i); //remove the item out of the itemdatabase EditorUtility.SetDirty(inventoryItemList); //and message the database again that you changed something } GUI.color = Color.white; //next GUIElements will be white inventoryItemList.itemList[i].itemName = EditorGUILayout.TextField("Item Name", inventoryItemList.itemList[i].itemName, GUILayout.Width(position.width - 45)); //textfield for the itemname which you wanna create inventoryItemList.itemList[i].itemID = i; //itemID getting set automaticly ...its unique...better do not change it :D GUILayout.BeginHorizontal(); GUILayout.Label("Item ID"); GUILayout.Label("" + i); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Item Description"); //label ItemDescription GUILayout.Space(47); inventoryItemList.itemList[i].itemDesc = EditorGUILayout.TextArea(inventoryItemList.itemList[i].itemDesc, GUILayout.Width(position.width - 195), GUILayout.Height(70)); //Text area for the itemDesc GUILayout.EndHorizontal(); inventoryItemList.itemList[i].itemIcon = (Sprite)EditorGUILayout.ObjectField("Item Icon", inventoryItemList.itemList[i].itemIcon, typeof(Sprite), false, GUILayout.Width(position.width - 45)); //objectfield for the itemicon for your new item inventoryItemList.itemList[i].itemModel = (GameObject)EditorGUILayout.ObjectField("Item Model", inventoryItemList.itemList[i].itemModel, typeof(GameObject), false, GUILayout.Width(position.width - 45)); //objectfield for the itemmodel for your new item inventoryItemList.itemList[i].itemType = (ItemType)EditorGUILayout.EnumPopup("Item Type", inventoryItemList.itemList[i].itemType, GUILayout.Width(position.width - 45)); //the itemtype which you want to have can be selected with the enumpopup inventoryItemList.itemList[i].maxStack = EditorGUILayout.IntField("Max Stack", inventoryItemList.itemList[i].maxStack, GUILayout.Width(position.width - 45)); inventoryItemList.itemList[i].rarity = EditorGUILayout.IntSlider("Rarity", inventoryItemList.itemList[i].rarity, 0, 100); GUILayout.BeginVertical("Box", GUILayout.Width(position.width - 45)); showItemAttributes = EditorGUILayout.Foldout(showItemAttributes, "Item attributes"); if (showItemAttributes) { string[] attributes = new string[itemAttributeList.itemAttributeList.Count]; for (int t = 1; t < attributes.Length; t++) { attributes[t] = itemAttributeList.itemAttributeList[t].attributeName; } if (inventoryItemList.itemList[i].itemAttributes.Count != 0) { for (int t = 0; t < inventoryItemList.itemList[i].itemAttributes.Count; t++) { for (int z = 1; z < attributes.Length; z++) { if (inventoryItemList.itemList[i].itemAttributes[t].attributeName == attributes[z]) { attributeNamesManage[t] = z; attributeValueManage[t] = inventoryItemList.itemList[i].itemAttributes[t].attributeValue; break; } } } } for (int z = 0; z < inventoryItemList.itemList[i].itemAttributes.Count; z++) { EditorGUILayout.BeginHorizontal(); GUI.color = Color.red; if (GUILayout.Button("-")) { inventoryItemList.itemList[i].itemAttributes.RemoveAt(z); } GUI.color = Color.white; attributeNamesManage[z] = EditorGUILayout.Popup(attributeNamesManage[z], attributes, EditorStyles.popup); inventoryItemList.itemList[i].itemAttributes[z].attributeValue = EditorGUILayout.IntField("Value", inventoryItemList.itemList[i].itemAttributes[z].attributeValue); EditorGUILayout.EndHorizontal(); } GUI.color = Color.green; if (GUILayout.Button("+")) { inventoryItemList.itemList[i].itemAttributes.Add(new ItemAttribute()); } GUI.color = Color.white; if (GUILayout.Button("Save")) { List <ItemAttribute> iA = new List <ItemAttribute>(); for (int k = 0; k < inventoryItemList.itemList[i].itemAttributes.Count; k++) { iA.Add(new ItemAttribute(attributes[attributeNamesManage[k]], attributeValueManage[k])); } inventoryItemList.itemList[i].itemAttributes = iA; GameObject[] items = GameObject.FindGameObjectsWithTag("Item"); for (int z = 0; z < items.Length; z++) { ItemOnObject item = items[z].GetComponent <ItemOnObject>(); if (item.item.itemID == inventoryItemList.itemList[i].itemID) { int value = item.item.itemValue; item.item = inventoryItemList.itemList[i]; item.item.itemValue = value; } } manageItem[i] = false; } } GUILayout.EndVertical(); EditorUtility.SetDirty(inventoryItemList); //message scriptable object that you have changed something } GUILayout.EndVertical(); } catch { } } GUILayout.EndVertical(); } } if (inventoryItemList == null) { inventoryItemList = (ItemDataBaseList)Resources.Load("ItemDatabase"); } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); }
public void ShaderPropertiesGUI(Material material) { // Use default labelWidth EditorGUIUtility.labelWidth = 0f; // Detect any changes to the material EditorGUI.BeginChangeCheck(); { //renderMode GUILayout.BeginHorizontal(); GUILayout.Label(Styles.renderModeText, GUILayout.Width(120)); var mode = (RenderMode)renderMode.floatValue; mode = (RenderMode)EditorGUILayout.Popup((int)mode, Styles.renderModeNames); GUILayout.EndHorizontal(); //lightingMode GUILayout.BeginHorizontal(); GUILayout.Label(Styles.lightModeText, GUILayout.Width(120)); var light = (LightingMode)lighting.floatValue; light = (LightingMode)EditorGUILayout.Popup((int)light, Styles.lightingNames); GUILayout.EndHorizontal(); //IsVertexColor m_MaterialEditor.ShaderProperty(isVertexColor, Styles.enableVertexColor); //Primary properties GUILayout.Label(Styles.PrimaryText, EditorStyles.boldLabel); //albedo m_MaterialEditor.TexturePropertySingleLine(Styles.albedoText, albedoTexture, albedoColor); //albedo Intensity m_MaterialEditor.ShaderProperty(albedoIntensity, Styles.albedoIntensityText, MaterialEditor.kMiniTextureFieldLabelIndentLevel); if (lighting.floatValue == 0) { //specular m_MaterialEditor.TexturePropertySingleLine(Styles.specularText, specularTexture, specularColor); //specular Shininess m_MaterialEditor.ShaderProperty(specularShininess, Styles.specularShininessText, MaterialEditor.kMiniTextureFieldLabelIndentLevel); //mormal m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalTexture); } //scaleAndOffset m_MaterialEditor.TextureScaleOffsetProperty(albedoTexture); GUILayout.Box("", GUILayout.Height(1), GUILayout.ExpandWidth(true)); //Advanced properties GUILayout.Label(Styles.AdvancedText, EditorStyles.boldLabel); //alphaTest m_MaterialEditor.ShaderProperty(alphaTest, Styles.alphaTestText); if (alphaTest.floatValue == 1) { m_MaterialEditor.ShaderProperty(alphaCutoff, Styles.alphaCutoffText, MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1); } //alphaBlend m_MaterialEditor.ShaderProperty(alphaBlend, Styles.alphaBlendText); var dstMode = (DstBlendMode)dstBlendMode.floatValue; var srcMode = (SrcBlendMode)srcBlendMode.floatValue; if (alphaBlend.floatValue == 1) { GUILayout.BeginHorizontal(); GUILayout.Label("", GUILayout.Width(20)); srcMode = (SrcBlendMode)EditorGUILayout.Popup((int)srcMode, Styles.srcBlendNames); dstMode = (DstBlendMode)EditorGUILayout.Popup((int)dstMode, Styles.dstBlendNames); GUILayout.EndHorizontal(); } //depthWrite GUILayout.BeginHorizontal(); GUILayout.Label(Styles.depthWriteText, GUILayout.Width(120)); var depthW = (DepthWrite)depthWrite.floatValue; depthW = (DepthWrite)EditorGUILayout.Popup((int)depthW, Styles.depthWriteNames); GUILayout.EndHorizontal(); //depthTest GUILayout.BeginHorizontal(); GUILayout.Label(Styles.depthTestText, GUILayout.Width(120)); var depthT = (DepthTest)depthTest.floatValue; depthT = (DepthTest)EditorGUILayout.Popup((int)depthT, Styles.depthTestNames); GUILayout.EndHorizontal(); //cullMode GUILayout.BeginHorizontal(); GUILayout.Label(Styles.cullModeText, GUILayout.Width(120)); var cull = (CullMode)cullMode.floatValue; cull = (CullMode)EditorGUILayout.Popup((int)cull, Styles.cullModeNames); GUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { m_MaterialEditor.RegisterPropertyChangeUndo("Rendering Mode"); //renderMode renderMode.floatValue = (float)mode; //lightMode lighting.floatValue = (float)light; material.SetInt("_Lighting", (int)light); if (lighting.floatValue == 0) { material.EnableKeyword("EnableLighting"); } else { material.DisableKeyword("EnableLighting"); } //cullMode cullMode.floatValue = (float)cull; material.SetInt("_Cull", (int)cull); if ((RenderMode)material.GetFloat("_Mode") == RenderMode.Custom) { //alphaTest if (alphaTest.floatValue == 1) { material.EnableKeyword("EnableAlphaCutoff"); material.EnableKeyword("_ALPHATEST_ON"); } else { material.DisableKeyword("EnableAlphaCutoff"); material.DisableKeyword("_ALPHATEST_ON"); } //alphaBlend if (alphaBlend.floatValue == 1) { srcBlendMode.floatValue = (float)srcMode; dstBlendMode.floatValue = (float)dstMode; material.SetInt("_SrcBlend", (int)srcMode); material.SetInt("_DstBlend", (int)dstMode); material.EnableKeyword("_ALPHABLEND_ON"); material.SetInt("_AlphaBlend", 1); } else { material.DisableKeyword("_ALPHABLEND_ON"); material.SetInt("_AlphaBlend", 0); material.SetInt("_SrcBlend", (int)1); material.SetInt("_DstBlend", (int)0); } //depthWrite depthWrite.floatValue = (float)depthW; material.SetInt("_ZWrite", (int)depthW); //depthTest depthTest.floatValue = (float)depthT; material.SetInt("_ZTest", (int)depthT); } if (specularTexture.textureValue != null) { material.EnableKeyword("SpecularTexture"); } else { material.DisableKeyword("SpecularTexture"); } if (normalTexture.textureValue != null) { material.EnableKeyword("NormalTexture"); } else { material.DisableKeyword("NormalTexture"); } if (isVertexColor.floatValue == 1) { material.EnableKeyword("ENABLEVERTEXCOLOR"); } else { material.DisableKeyword("ENABLEVERTEXCOLOR"); } onChangeRender(material, (RenderMode)material.GetFloat("_Mode")); } } m_MaterialEditor.RenderQueueField(); }
private void OnGUI() { if (ShaderBaker.window == null) { if (this != null) { base.Close(); } return; } GUILayout.Space(16f); EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUI.BeginChangeCheck(); EditorGUILayout.LabelField(" Shader Name:", new GUILayoutOption[] { GUILayout.MaxWidth(100f) }); GUI.SetNextControlName("textField"); string fullNewShaderPath = ShaderBaker.FindBakedShadersRelativePath() + ShaderBaker.newName + ".shader"; bool shouldOptimizeMaterial = true; bool isShaderNameInvalid = false; bool shaderAlreadyExists = false; if (ShaderContainsInvalidCharacters()) { isShaderNameInvalid = true; shouldOptimizeMaterial = false; } if (File.Exists(fullNewShaderPath)) { shaderAlreadyExists = true; shouldOptimizeMaterial = false; } ShaderBaker.newName = EditorGUILayout.TextField(string.Empty, ShaderBaker.newName, new GUILayoutOption[] { GUILayout.Width(280f) }); EditorGUILayout.EndHorizontal(); EditorGUI.FocusTextInControl("textField"); if (Event.current.keyCode == KeyCode.Return && GUI.GetNameOfFocusedControl() == "textField") { if (shouldOptimizeMaterial) { ShaderBaker.OptimizeMaterial(ShaderBaker.targetMaterial, ShaderBaker.disableBatching); } ShaderBaker.window.Close(); return; } if (Event.current.keyCode == KeyCode.Escape && GUI.GetNameOfFocusedControl() == "textField") { ShaderBaker.window.Close(); return; } using (new UITools.GUIEnable(false)) { GUILayout.Space(5f); if (shouldOptimizeMaterial) { EditorGUILayout.LabelField(fullNewShaderPath, new GUILayoutOption[0]); } else if (isShaderNameInvalid) { EditorGUILayout.LabelField(" Shader name contains unsopported characters", new GUILayoutOption[0]); } else if (shaderAlreadyExists) { EditorGUILayout.LabelField(" Shader with such name already exists", new GUILayoutOption[0]); } } GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(10f); ShaderBaker.disableBatching = EditorGUILayout.ToggleLeft(" Disable Batching", ShaderBaker.disableBatching, new GUILayoutOption[0]); GUILayout.EndHorizontal(); if (shaderAlreadyExists) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Space(10f); ShaderBaker.overrite = EditorGUILayout.ToggleLeft(" Overrite", ShaderBaker.overrite, new GUILayoutOption[0]); GUILayout.EndHorizontal(); if (ShaderBaker.overrite) { shouldOptimizeMaterial = true; } } using (new UITools.GUIEnable(shouldOptimizeMaterial)) { if (GUILayout.Button("Bake Shader", GUILayout.MinHeight(30.0f))) { if (shouldOptimizeMaterial) { ShaderBaker.OptimizeMaterial(ShaderBaker.targetMaterial, ShaderBaker.disableBatching); } ShaderBaker.window.Close(); return; } } using (new UITools.GUIHorizontal()) { using (new UITools.GUIFlexiSpace()) { if (GUILayout.Button("Cancel", GUILayout.ExpandWidth(false), GUILayout.MinWidth(100.0f))) { ShaderBaker.window.Close(); } } } }
public void DrawMaterialInputs(GUIStyle toolbarstyle, bool style = true) { m_propertyOrderChanged = false; Color cachedColor = GUI.color; GUI.color = new Color(cachedColor.r, cachedColor.g, cachedColor.b, 0.5f); EditorGUILayout.BeginHorizontal(toolbarstyle); GUI.color = cachedColor; EditorGUI.BeginChangeCheck(); if (style) { ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedProperties = GUILayoutToggle(ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedProperties, PropertyOrderFoldoutStr, UIUtils.MenuItemToggleStyle); } else { ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedProperties = GUILayoutToggle(ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedProperties, PropertyOrderTemplateFoldoutStr, UIUtils.MenuItemToggleStyle); } if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetBool("ExpandedProperties", ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedProperties); } EditorGUILayout.EndHorizontal(); if (!ContainerGraph.ParentWindow.InnerWindowVariables.ExpandedProperties) { return; } cachedColor = GUI.color; GUI.color = new Color(cachedColor.r, cachedColor.g, cachedColor.b, (EditorGUIUtility.isProSkin ? 0.5f : 0.25f)); EditorGUILayout.BeginVertical(UIUtils.MenuItemBackgroundStyle); GUI.color = cachedColor; List <PropertyNode> nodes = UIUtils.PropertyNodesList(); if (nodes.Count != m_lastCount) { RefreshVisibleList(ref nodes); m_lastCount = nodes.Count; } if (m_propertyReordableList == null) { m_propertyReordableList = new ReorderableList(m_propertyNodesVisibleList, typeof(PropertyNode), true, false, false, false) { headerHeight = 0, footerHeight = 0, showDefaultBackground = false, drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { EditorGUI.LabelField(rect, m_propertyNodesVisibleList[index].PropertyInspectorName); }, onReorderCallback = (list) => { ReorderList(ref nodes); m_propertyOrderChanged = true; //RecursiveLog(); } }; ReorderList(ref nodes); } if (m_propertyReordableList != null) { if (m_propertyAdjustment == null) { m_propertyAdjustment = new GUIStyle(); m_propertyAdjustment.padding.left = 17; } EditorGUILayout.BeginVertical(m_propertyAdjustment); m_propertyReordableList.DoLayoutList(); EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); }
protected override void Inspector() { var isAIPath = typeof(AIPath).IsAssignableFrom(target.GetType()); Section("Shape"); FloatField("radius", min: 0.01f); FloatField("height", min: 0.01f); Section("Pathfinding"); if (PropertyField("canSearch")) { EditorGUI.indentLevel++; FloatField("repathRate", min: 0f); EditorGUI.indentLevel--; } Section("Movement"); PropertyField("canMove"); FloatField("maxSpeed", min: 0f); if (isAIPath) { EditorGUI.BeginChangeCheck(); var acceleration = FindProperty("maxAcceleration"); int acc = acceleration.hasMultipleDifferentValues ? -1 : (acceleration.floatValue >= 0 ? 1 : 0); var nacc = EditorGUILayout.Popup("Max Acceleration", acc, new[] { "Default", "Custom" }); if (EditorGUI.EndChangeCheck()) { if (nacc == 0) { acceleration.floatValue = -2.5f; } else if (acceleration.floatValue < 0) { acceleration.floatValue = 10; } } if (!acceleration.hasMultipleDifferentValues && nacc == 1) { EditorGUI.indentLevel++; PropertyField(acceleration.propertyPath); EditorGUI.indentLevel--; acceleration.floatValue = Mathf.Max(acceleration.floatValue, 0.01f); } Popup("orientation", new[] { new GUIContent("ZAxisForward (for 3D games)"), new GUIContent("YAxisForward (for 2D games)") }); } else { FloatField("acceleration", min: 0f); // The RichAI script doesn't really support any orientation other than Z axis forward, so don't expose it in the inspector FindProperty("orientation").enumValueIndex = (int)OrientationMode.ZAxisForward; } if (PropertyField("enableRotation")) { EditorGUI.indentLevel++; FloatField("rotationSpeed", min: 0f); PropertyField("slowWhenNotFacingTarget"); EditorGUI.indentLevel--; } if (isAIPath) { FloatField("pickNextWaypointDist", min: 0f); FloatField("slowdownDistance", min: 0f); } else { FloatField("slowdownTime", min: 0f); FloatField("wallForce", min: 0f); FloatField("wallDist", min: 0f); PropertyField("funnelSimplification"); } FloatField("endReachedDistance", min: 0f); if (isAIPath) { PropertyField("alwaysDrawGizmos"); PropertyField("whenCloseToDestination"); PropertyField("constrainInsideGraph"); } var mono = target as MonoBehaviour; var rigid = mono.GetComponent <Rigidbody>(); var rigid2D = mono.GetComponent <Rigidbody2D>(); var controller = mono.GetComponent <CharacterController>(); var canUseGravity = (controller != null && controller.enabled) || ((rigid == null || rigid.isKinematic) && (rigid2D == null || rigid2D.isKinematic)); var gravity = FindProperty("gravity"); var groundMask = FindProperty("groundMask"); if (canUseGravity) { EditorGUI.BeginChangeCheck(); int grav = gravity.hasMultipleDifferentValues ? -1 : (gravity.vector3Value == Vector3.zero ? 0 : (float.IsNaN(gravity.vector3Value.x) ? 1 : 2)); var ngrav = EditorGUILayout.Popup("Gravity", grav, new[] { "None", "Use Project Settings", "Custom" }); if (EditorGUI.EndChangeCheck()) { if (ngrav == 0) { gravity.vector3Value = Vector3.zero; } else if (ngrav == 1) { gravity.vector3Value = new Vector3(float.NaN, float.NaN, float.NaN); } else if (float.IsNaN(gravity.vector3Value.x) || gravity.vector3Value == Vector3.zero) { gravity.vector3Value = Physics.gravity; } lastSeenCustomGravity = float.NegativeInfinity; } if (!gravity.hasMultipleDifferentValues) { // A sort of delayed Vector3 field (to prevent the field from dissappearing if you happen to enter zeroes into x, y and z for a short time) // Note: cannot use != in this case because that will not give the correct result in case of NaNs if (!(gravity.vector3Value == Vector3.zero)) { lastSeenCustomGravity = Time.realtimeSinceStartup; } if (Time.realtimeSinceStartup - lastSeenCustomGravity < 2f) { EditorGUI.indentLevel++; if (!float.IsNaN(gravity.vector3Value.x)) { PropertyField(gravity.propertyPath); } if (controller == null || !controller.enabled) { PropertyField(groundMask.propertyPath, "Raycast Ground Mask"); } EditorGUI.indentLevel--; } } } else { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.Popup( new GUIContent(gravity.displayName, "Disabled because a non-kinematic rigidbody is attached"), 0, new[] { new GUIContent("Handled by Rigidbody") }); EditorGUI.EndDisabledGroup(); } if ((rigid != null || rigid2D != null) && (controller != null && controller.enabled)) { EditorGUILayout.HelpBox( "You are using both a Rigidbody and a Character Controller. Those components are not really designed for that. Please use only one of them.", MessageType.Warning); } }
public bool AddExtraStuff() { SerializedProperty baseRaceRecipe = serializedObject.FindProperty("baseRaceRecipe"); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(baseRaceRecipe, true); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } if (wardrobeSlotList == null) { InitWardrobeSlotList(); } EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); wardrobeSlotList.DoLayoutList(); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); if (!race.ValidateWardrobeSlots()) { EditorUtility.SetDirty(race); } } //new CrossCompatibilitySettings //To push any old settings in RaceData.backwardsCompatibleWith into the new crossCompatibilitySettings we have to call GetCrossCompatibleRaces() directly on the target #pragma warning disable 618 if (race.backwardsCompatibleWith.Count > 0) { var cc = race.GetCrossCompatibleRaces(); if (cc.Count > 0) { serializedObject.Update(); } } #pragma warning restore 618 SerializedProperty _crossCompatibilitySettings = serializedObject.FindProperty("_crossCompatibilitySettings"); SerializedProperty _crossCompatibilitySettingsData = _crossCompatibilitySettings.FindPropertyRelative("settingsData"); //draw the new version of the crossCompatibility list that allows users to define what slots in this races base recipe equate to in the backwards compatible races base recipe _crossCompatibilitySettings.isExpanded = EditorGUILayout.Foldout(_crossCompatibilitySettings.isExpanded, "Cross Compatibility Settings"); if (_crossCompatibilitySettings.isExpanded) { //draw an info foldout EditorGUI.indentLevel++; _crossCompatibilitySettingsData.isExpanded = EditorGUILayout.Foldout(_crossCompatibilitySettingsData.isExpanded, "Help"); if (_crossCompatibilitySettingsData.isExpanded) { var helpText = "CrossCompatibilitySettings allows this race to wear wardrobe slots from another race, if this race has a wardrobe slot that the recipe is set to."; helpText += " You can further configure the compatibility settings for each compatible race to define 'equivalent' slotdatas in the races' base recipes."; helpText += " For example you could define that this races 'highpolyMaleChest' slotdata in its base recipe is equivalent to HumanMales 'MaleChest' slot data in its base recipe."; helpText += " This would mean that any recipes which hid or applied an overlay to 'MaleChest' would hide or apply an overlay to 'highPolyMaleChest' on this race."; helpText += " If 'Overlays Match' is unchecked then overlays in a recipe wont be applied."; EditorGUILayout.HelpBox(helpText, MessageType.Info); } EditorGUI.indentLevel--; if (baseRaceRecipe.objectReferenceValue != null) { Rect dropArea = new Rect(); dropArea = GUILayoutUtility.GetRect(0.0f, 50.0f, GUILayout.ExpandWidth(true)); GUI.Box(dropArea, "Drag cross compatible Races here. Click to pick."); CompatibleRacesDropArea(dropArea, _crossCompatibilitySettingsData); EditorGUILayout.Space(); //update the foldouts list if the dropbox changes anything if (_BCFoldouts.Length != _crossCompatibilitySettingsData.arraySize) { Array.Resize <bool>(ref _BCFoldouts, _crossCompatibilitySettingsData.arraySize); } //we need an uptodate list of the slots in THIS races base recipe baseSlotsList.Clear(); baseSlotsNamesList.Clear(); //editing a race will require a context too because we need to get the base recipes and their slots if (UMAContextBase.Instance == null) { EditorUMAContextBase = UMAContextBase.CreateEditorContext(); } UMAData.UMARecipe thisBaseRecipe = (baseRaceRecipe.objectReferenceValue as UMARecipeBase).GetCachedRecipe(UMAContextBase.Instance); SlotData[] thisBaseSlots = thisBaseRecipe.GetAllSlots(); foreach (SlotData slot in thisBaseSlots) { if (slot != null) { baseSlotsList.Add(slot); baseSlotsNamesList.Add(slot.slotName); } } List <int> crossCompatibleSettingsToDelete = new List <int>(); //draw a foldout area for each compatible race that will show an entry for each slot in this races base recipe //with a picker to choose the slot from the compatible race's base recipe that it equates to for (int i = 0; i < _crossCompatibilitySettingsData.arraySize; i++) { bool del = false; var thisCCSettings = _crossCompatibilitySettingsData.GetArrayElementAtIndex(i).FindPropertyRelative("ccSettings"); var ccRaceName = _crossCompatibilitySettingsData.GetArrayElementAtIndex(i).FindPropertyRelative("ccRace").stringValue; //this could be missing- we should show that var label = ccRaceName; if (GetCompatibleRaceData(ccRaceName) == null) { label += " (missing)"; } GUIHelper.FoldoutBar(ref _BCFoldouts[i], label, out del); if (del) { crossCompatibleSettingsToDelete.Add(i); } if (_BCFoldouts[i]) { DrawCCUI(ccRaceName, baseRaceRecipe, thisCCSettings); } } if (crossCompatibleSettingsToDelete.Count > 0) { foreach (int del in crossCompatibleSettingsToDelete) { _crossCompatibilitySettingsData.DeleteArrayElementAtIndex(del); serializedObject.ApplyModifiedProperties(); } } } else { EditorGUILayout.HelpBox("Please define this races baseRaceRecipe before trying to define its cross compatibility settings.", MessageType.Info); } } EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(serializedObject.FindProperty("raceThumbnails"), true); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } return(false); }
public override void OnInspectorGUI() { GraphUpdateScene script = target as GraphUpdateScene; #if !UNITY_LE_4_3 Undo.RecordObject(script, "modify settings on GraphUpdateObject"); #endif if (script.points == null) { script.points = new Vector3[0]; } if (script.points == null || script.points.Length == 0) { if (script.GetComponent <Collider>() != null) { EditorGUILayout.HelpBox("No points, using collider.bounds", MessageType.Info); } else if (script.GetComponent <Renderer>() != null) { EditorGUILayout.HelpBox("No points, using renderer.bounds", MessageType.Info); } else { EditorGUILayout.HelpBox("No points and no collider or renderer attached, will not affect anything", MessageType.Warning); } } Vector3[] prePoints = script.points; #if UNITY_4 EditorGUILayout.PropertyField(serializedObject.FindProperty("points"), true); #else DrawDefaultInspector(); #endif #if UNITY_LE_4_3 EditorGUI.indentLevel = 1; #else EditorGUI.indentLevel = 0; #endif script.updatePhysics = EditorGUILayout.Toggle(new GUIContent("Update Physics", "Perform similar calculations on the nodes as during scan.\n" + "Grid Graphs will update the position of the nodes and also check walkability using collision.\nSee online documentation for more info."), script.updatePhysics); if (script.updatePhysics) { EditorGUI.indentLevel++; script.resetPenaltyOnPhysics = EditorGUILayout.Toggle(new GUIContent("Reset Penalty On Physics", "Will reset the penalty to the default value during the update."), script.resetPenaltyOnPhysics); EditorGUI.indentLevel--; } script.updateErosion = EditorGUILayout.Toggle(new GUIContent("Update Erosion", "Recalculate erosion for grid graphs.\nSee online documentation for more info"), script.updateErosion); if (prePoints != script.points) { script.RecalcConvex(); HandleUtility.Repaint(); } bool preConvex = script.convex; script.convex = EditorGUILayout.Toggle(new GUIContent("Convex", "Sets if only the convex hull of the points should be used or the whole polygon"), script.convex); if (script.convex != preConvex) { script.RecalcConvex(); HandleUtility.Repaint(); } script.minBoundsHeight = EditorGUILayout.FloatField(new GUIContent("Min Bounds Height", "Defines a minimum height to be used for the bounds of the GUO.\nUseful if you define points in 2D (which would give height 0)"), script.minBoundsHeight); script.applyOnStart = EditorGUILayout.Toggle("Apply On Start", script.applyOnStart); script.applyOnScan = EditorGUILayout.Toggle("Apply On Scan", script.applyOnScan); script.modifyWalkability = EditorGUILayout.Toggle(new GUIContent("Modify walkability", "If true, walkability of all nodes will be modified"), script.modifyWalkability); if (script.modifyWalkability) { EditorGUI.indentLevel++; script.setWalkability = EditorGUILayout.Toggle(new GUIContent("Walkability", "Nodes' walkability will be set to this value"), script.setWalkability); EditorGUI.indentLevel--; } script.penaltyDelta = EditorGUILayout.IntField(new GUIContent("Penalty Delta", "A penalty will be added to the nodes, usually you need very large values, at least 1000-10000.\n" + "A higher penalty will mean that agents will try to avoid those nodes."), script.penaltyDelta); if (script.penaltyDelta < 0) { EditorGUILayout.HelpBox("Be careful when lowering the penalty. Negative penalties are not supported and will instead underflow and get really high.\n" + "You can set an initial penalty on graphs (see their settings) and then lower them like this to get regions which are easier to traverse.", MessageType.Warning); } script.modifyTag = EditorGUILayout.Toggle(new GUIContent("Modify Tags", "Should the tags of the nodes be modified"), script.modifyTag); if (script.modifyTag) { EditorGUI.indentLevel++; script.setTag = EditorGUILayout.Popup("Set Tag", script.setTag, AstarPath.FindTagNames()); EditorGUI.indentLevel--; } if (GUILayout.Button("Tags can be used to restrict which units can walk on what ground. Click here for more info", "HelpBox")) { Application.OpenURL(AstarPathEditor.GetURL("tags")); } EditorGUILayout.Separator(); bool worldSpace = EditorGUILayout.Toggle(new GUIContent("Use World Space", "Specify coordinates in world space or local space. When using local space you can move the GameObject " + "around and the points will follow.\n" + "Some operations, like calculating the convex hull, and snapping to Y will change axis depending on how the object is rotated if world space is not used." ), script.useWorldSpace); if (worldSpace != script.useWorldSpace) { #if !UNITY_LE_4_3 Undo.RecordObject(script, "switch use-world-space"); #endif script.ToggleUseWorldSpace(); } #if UNITY_4 EditorGUI.BeginChangeCheck(); #endif script.lockToY = EditorGUILayout.Toggle("Lock to Y", script.lockToY); if (script.lockToY) { EditorGUI.indentLevel++; script.lockToYValue = EditorGUILayout.FloatField("Lock to Y value", script.lockToYValue); EditorGUI.indentLevel--; #if !UNITY_LE_4_3 if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(script, "change Y locking"); } #endif script.LockToY(); } EditorGUILayout.Separator(); if (GUI.changed) { #if UNITY_LE_4_3 Undo.RegisterUndo(script, "Modify Settings on GraphUpdateObject"); #endif EditorUtility.SetDirty(target); } if (GUILayout.Button("Clear all points")) { #if UNITY_LE_4_3 Undo.RegisterUndo(script, "Removed All Points"); #endif script.points = new Vector3[0]; EditorUtility.SetDirty(target); script.RecalcConvex(); } }
public override void OnInspectorGUI() { if (lastActionTime == 0) { lastActionTime = Time.realtimeSinceStartup; } race.raceName = EditorGUILayout.TextField("Race Name", race.raceName); race.umaTarget = (UMA.RaceData.UMATarget)EditorGUILayout.EnumPopup(new GUIContent("UMA Target", "The Mecanim animation rig type."), race.umaTarget); race.genericRootMotionTransformName = EditorGUILayout.TextField("Root Motion Transform", race.genericRootMotionTransformName); race.TPose = EditorGUILayout.ObjectField(new GUIContent("T-Pose", "The UMA T-Pose asset can be created by selecting the race fbx and choosing the Extract T-Pose dropdown. Only needs to be done once per race."), race.TPose, typeof(UmaTPose), false) as UmaTPose; race.expressionSet = EditorGUILayout.ObjectField(new GUIContent("Expression Set", "The Expression Set asset is used by the Expression player."), race.expressionSet, typeof(UMA.PoseTools.UMAExpressionSet), false) as UMA.PoseTools.UMAExpressionSet; EditorGUILayout.HelpBox("Fixup Rotations should be true for Blender FBX slots", MessageType.Info); race.FixupRotations = EditorGUILayout.Toggle("Fixup Rotations", race.FixupRotations); EditorGUILayout.Space(); SerializedProperty dnaConverterListprop = serializedObject.FindProperty("_dnaConverterList"); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(dnaConverterListprop, true); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } SerializedProperty dnaRanges = serializedObject.FindProperty("dnaRanges"); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(dnaRanges, true); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } foreach (var field in race.GetType().GetFields()) { foreach (var attribute in System.Attribute.GetCustomAttributes(field)) { if (attribute is UMAAssetFieldVisible) { SerializedProperty serializedProp = serializedObject.FindProperty(field.Name); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(serializedProp); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } break; } } } try { PreInspectorGUI(ref _needsUpdate); if (_needsUpdate == true) { DoUpdate(); } }catch (UMAResourceNotFoundException e) { _errorMessage = e.Message; } if (GUI.changed) { doSave = true; lastActionTime = Time.realtimeSinceStartup; } }
public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { string keyword = prop.FindPropertyRelative("_key").stringValue; EditorGUI.BeginProperty(position, label, prop); position = EditorGUI.PrefixLabel(position, EditorGUIUtility.GetControlID(FocusType.Passive), label); int originalIndentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; position.width -= 32; string temp; if (isAddingString.Contains(prop.propertyPath)) { position.height = base.GetPropertyHeight(prop, label); currentCategories[prop.propertyPath] = EditorGUI.Popup(position, currentCategories[prop.propertyPath], categories.ToArray()); position.y += position.height; EditorGUI.BeginChangeCheck(); temp = EditorGUI.TextField(position, newValues[prop.propertyPath]); if (EditorGUI.EndChangeCheck()) { newValues[prop.propertyPath] = temp; } } else { temp = keyword; if (temp == "") { temp = "Empty String"; } Color originalColor = GUI.color; int index = keywords.IndexOf(temp); if (index < 0) { index = keywords.Count; keywords.Add(temp + " (Missing)"); GUI.color = Color.red; } EditorGUI.BeginChangeCheck(); index = EditorGUI.Popup(position, index, keywords.ToArray()); temp = keywords[index]; if (temp == "Empty String") { temp = ""; } GUI.color = originalColor; if (EditorGUI.EndChangeCheck()) { prop.FindPropertyRelative("_key").stringValue = temp; } } position.y += 1; position.x += position.width; position.width = 16; if (GUI.Button(position, isAddingString.Contains(prop.propertyPath) ? checkContent : plusContent, "Label")) { if (temp.Contains(" (Missing)")) { KeywordCategory tempCategory = (from c in config where c.name == (keyword.LastIndexOf('/') < 0 ? "" : keyword.Substring(0, keyword.LastIndexOf('/'))) select c).FirstOrDefault(); if (tempCategory == null) { config.Add(new KeywordCategory((keyword.LastIndexOf('/') < 0 ? "" : keyword.Substring(0, keyword.LastIndexOf('/'))))); config.Last().keywords.Add(keyword); } else { tempCategory.keywords.Add(keyword); } EditorUtility.SetDirty(scriptableConfig); PopulateLists(); } else { if (isAddingString.Contains(prop.propertyPath)) { config[currentCategories[prop.propertyPath]].keywords.Add(newValues[prop.propertyPath]); EditorUtility.SetDirty(scriptableConfig); keywords.Add(config[currentCategories[prop.propertyPath]].name + (currentCategories[prop.propertyPath] == 0 ? "" : "/") + newValues[prop.propertyPath]); config[currentCategories[prop.propertyPath]].keywords.Sort(); keywords.RemoveAt(0); keywords.Sort(); keywords.Insert(0, "Empty String"); SetReflectedFieldRecursively(prop, (Keyword)(config[currentCategories[prop.propertyPath]].name + (currentCategories[prop.propertyPath] == 0 ? "" : "/") + newValues[prop.propertyPath])); EditorUtility.SetDirty(prop.serializedObject.targetObject); } if (isAddingString.Contains(prop.propertyPath)) { isAddingString = isAddingString.Replace(prop.propertyPath, string.Empty); } else { isAddingString += prop.propertyPath; if (!newValues.ContainsKey(prop.propertyPath)) { newValues.Add(prop.propertyPath, string.Empty); } if (!currentCategories.ContainsKey(prop.propertyPath)) { currentCategories.Add(prop.propertyPath, 0); } } } } position.x += 16; if (GUI.Button(position, isAddingString.Contains(prop.propertyPath) ? xContent : minusContent, "Label")) { if (isAddingString.Contains(prop.propertyPath)) { newValues[prop.propertyPath] = ""; isAddingString = isAddingString.Replace(prop.propertyPath, string.Empty); } else { if (EditorUtility.DisplayDialog("Remove string?", string.Format("Are you sure you want to remove \"{0}\" from the string list?", temp), "Yes", "No")) { keywords.Remove(temp); if (temp.Contains('/')) { (from c in config where c.name == temp.Substring(0, temp.LastIndexOf('/')) select c.keywords).ToList().FirstOrDefault().Remove(keyword); } else { config[0].keywords.Remove(keyword); } EditorUtility.SetDirty(Keywords.Config); } } } EditorGUI.indentLevel = originalIndentLevel; EditorGUI.EndProperty(); }
public override void OnInspectorGUI() { serializedObject.Update(); if (target != null) { var helpURL = target.GetType().GetCustomAttribute <HelpURLAttribute>(); if (helpURL != null) { InspectorUIUtility.RenderDocumentationButton(helpURL.URL); } } // Ensure there is a touchable. if (touchable == null) { EditorGUILayout.HelpBox($"{target.GetType().Name} requires a {nameof(NearInteractionTouchableSurface)}-derived component on this game object to function.", MessageType.Warning); bool isUnityUI = (button.GetComponent <RectTransform>() != null); var typeToAdd = isUnityUI ? typeof(NearInteractionTouchableUnityUI) : typeof(NearInteractionTouchable); if (GUILayout.Button($"Add {typeToAdd.Name} component")) { Undo.RecordObject(target, string.Concat($"Add {typeToAdd.Name}")); var addedComponent = button.gameObject.AddComponent(typeToAdd); touchable = (NearInteractionTouchableSurface)addedComponent; } else { // It won't work without it, return to avoid nullrefs. return; } } // Ensure that the touchable has EventsToReceive set to Touch if (touchable.EventsToReceive != TouchableEventType.Touch) { EditorGUILayout.HelpBox($"The {nameof(NearInteractionTouchableSurface)}-derived component on this game object currently has its EventsToReceive set to '{touchable.EventsToReceive}'. It must be set to 'Touch' in order for PressableButton to function properly.", MessageType.Warning); if (GUILayout.Button("Set EventsToReceive to 'Touch'")) { Undo.RecordObject(touchable, string.Concat("Set EventsToReceive to Touch on ", touchable.name)); touchable.EventsToReceive = TouchableEventType.Touch; } } EditorGUILayout.Space(); EditorGUILayout.PropertyField(movingButtonVisuals); // Ensure that there is a moving button visuals in the UnityUI case. Even if it is not visible, it must be present to receive GraphicsRaycasts. if (touchable is NearInteractionTouchableUnityUI) { if (movingButtonVisuals.objectReferenceValue == null) { EditorGUILayout.HelpBox($"When used with a NearInteractionTouchableUnityUI, a MovingButtonVisuals is required, as it receives the GraphicsRaycast that allows pressing the button with near/hand interactions. It does not need to be visible, but it must be able to receive GraphicsRaycasts.", MessageType.Warning); } else { var movingVisualGameObject = (GameObject)movingButtonVisuals.objectReferenceValue; var movingGraphic = movingVisualGameObject.GetComponentInChildren <UnityEngine.UI.Graphic>(); if (movingGraphic == null) { EditorGUILayout.HelpBox($"When used with a NearInteractionTouchableUnityUI, the MovingButtonVisuals must contain an Image, RawImage, or other Graphic element so that it can receive a GraphicsRaycast.", MessageType.Warning); } } } EditorGUILayout.LabelField("Press Settings", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); var currentMode = distanceSpaceMode.intValue; EditorGUILayout.PropertyField(distanceSpaceMode); // EndChangeCheck returns true when something was selected in the dropdown, but // doesn't necessarily mean that the value itself changed. Check for that too. if (EditorGUI.EndChangeCheck() && currentMode != distanceSpaceMode.intValue) { // Changing the DistanceSpaceMode requires updating the plane distance values so they stay in the same relative ratio positions Undo.RecordObject(target, string.Concat("Trigger Plane Distance Conversion of ", button.name)); button.DistanceSpaceMode = (PressableButton.SpaceMode)distanceSpaceMode.enumValueIndex; serializedObject.Update(); } DrawPropertiesExcluding(serializedObject, excludeProperties); startPushDistance.floatValue = ClampStartPushDistance(startPushDistance.floatValue); // show button state in play mode { EditorGUI.BeginDisabledGroup(Application.isPlaying == false); EditorGUILayout.Space(); EditorGUILayout.LabelField("Button State", EditorStyles.boldLabel); EditorGUILayout.LabelField("Current Push Distance", button.CurrentPushDistance.ToString()); EditorGUILayout.Toggle("Touching", button.IsTouching); EditorGUILayout.Toggle("Pressing", button.IsPressing); EditorGUI.EndDisabledGroup(); } // editor settings { EditorGUI.BeginDisabledGroup(Application.isPlaying == true); EditorGUILayout.Space(); EditorGUILayout.LabelField("Editor Settings", EditorStyles.boldLabel); var prevVisiblePlanes = SessionState.GetBool(VisiblePlanesKey, true); VisiblePlanes = EditorGUILayout.Toggle("Show Button Event Planes", prevVisiblePlanes); if (VisiblePlanes != prevVisiblePlanes) { SessionState.SetBool(VisiblePlanesKey, VisiblePlanes); EditorUtility.SetDirty(target); } // enable plane editing { EditorGUI.BeginDisabledGroup(VisiblePlanes == false); var prevEditingEnabled = SessionState.GetBool(EditingEnabledKey, false); EditingEnabled = EditorGUILayout.Toggle("Make Planes Editable", EditingEnabled); if (EditingEnabled != prevEditingEnabled) { SessionState.SetBool(EditingEnabledKey, EditingEnabled); EditorUtility.SetDirty(target); } EditorGUI.EndDisabledGroup(); } EditorGUI.EndDisabledGroup(); } serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { UdonBehaviour udonTarget = (UdonBehaviour)target; using (new EditorGUI.DisabledScope(Application.isPlaying)) { EditorGUILayout.LabelField("Specialized Synchronization Behaviour"); //if(udonTarget.GetComponent<Animator>() != null || udonTarget.GetComponent<Animation>() != null) // udonTarget.SynchronizeAnimation = EditorGUILayout.Toggle("Synchronize Animation", udonTarget.SynchronizeAnimation); //else // udonTarget.SynchronizeAnimation = EditorGUILayout.Toggle("Synchronize Animation", false); using (new EditorGUI.DisabledScope(true)) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.Toggle("Synchronize Animation", false); EditorGUILayout.LabelField("Coming Soon!"); EditorGUILayout.EndHorizontal(); } udonTarget.SynchronizePosition = EditorGUILayout.Toggle("Synchronize Position", udonTarget.SynchronizePosition); if (udonTarget.GetComponent <Collider>() != null) { udonTarget.AllowCollisionOwnershipTransfer = EditorGUILayout.Toggle("Allow Ownership Transfer on Collision", udonTarget.AllowCollisionOwnershipTransfer); } else { udonTarget.AllowCollisionOwnershipTransfer = EditorGUILayout.Toggle("Allow Ownership Transfer on Collision", false); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Udon"); bool dirty = false; EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); _programSourceProperty.objectReferenceValue = EditorGUILayout.ObjectField( "Program Source", _programSourceProperty.objectReferenceValue, typeof(AbstractUdonProgramSource), false ); if (EditorGUI.EndChangeCheck()) { dirty = true; serializedObject.ApplyModifiedProperties(); } if (_programSourceProperty.objectReferenceValue == null) { if (_serializedProgramAssetProperty.objectReferenceValue != null) { _serializedProgramAssetProperty.objectReferenceValue = null; serializedObject.ApplyModifiedPropertiesWithoutUndo(); } List <(string displayName, Type newProgramType)> programSourceTypesForNewMenu = GetProgramSourceTypesForNewMenu(); if (GUILayout.Button("New Program")) { (string displayName, Type newProgramType) = programSourceTypesForNewMenu.ElementAt(_newProgramType); string udonBehaviourName = udonTarget.name; Scene scene = udonTarget.gameObject.scene; if (string.IsNullOrEmpty(scene.path)) { Debug.LogError("You need to save the scene before you can create new Udon program assets!"); } else { AbstractUdonProgramSource newProgramSource = CreateUdonProgramSourceAsset(newProgramType, displayName, scene, udonBehaviourName); _programSourceProperty.objectReferenceValue = newProgramSource; _serializedProgramAssetProperty.objectReferenceValue = newProgramSource.SerializedProgramAsset; serializedObject.ApplyModifiedProperties(); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); _newProgramType = EditorGUILayout.Popup( "", Mathf.Clamp(_newProgramType, 0, programSourceTypesForNewMenu.Count), programSourceTypesForNewMenu.Select(t => t.displayName).ToArray(), GUILayout.ExpandWidth(false) ); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetInt(VRC_UDON_NEW_PROGRAM_TYPE_PREF_KEY, _newProgramType); } } else { EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); using (new EditorGUI.DisabledScope(true)) { EditorGUI.indentLevel++; EditorGUILayout.ObjectField( "Serialized Udon Program Asset ID: ", _serializedProgramAssetProperty.objectReferenceValue, typeof(AbstractSerializedUdonProgramAsset), false ); EditorGUI.indentLevel--; } AbstractUdonProgramSource programSource = (AbstractUdonProgramSource)_programSourceProperty.objectReferenceValue; AbstractSerializedUdonProgramAsset serializedUdonProgramAsset = programSource.SerializedProgramAsset; if (_serializedProgramAssetProperty.objectReferenceValue != serializedUdonProgramAsset) { _serializedProgramAssetProperty.objectReferenceValue = serializedUdonProgramAsset; serializedObject.ApplyModifiedPropertiesWithoutUndo(); } } EditorGUILayout.EndHorizontal(); udonTarget.RunEditorUpdate(ref dirty); if (dirty && !Application.isPlaying) { EditorSceneManager.MarkSceneDirty(udonTarget.gameObject.scene); } } }
private bool HandleBehavior(string title, ref MaterialProperty behavior, MaterialEditor materialEditor) { EditorGUI.showMixedValue = behavior.hasMixedValue; var rect = GUILayoutUtility.GetRect(16f, 22f, GuiStyles.header); rect.x -= 10; rect.width += 10; var e = Event.current; GUI.Box(rect, title, GuiStyles.header); var foldoutRect = new Rect(EditorGUIUtility.currentViewWidth * 0.5f, rect.y + 2, 13f, 13f); if (behavior.hasMixedValue) { foldoutRect.x -= 13; foldoutRect.y -= 2; } EditorGUI.BeginChangeCheck(); if (e.type == EventType.MouseDown) { if (rect.Contains(e.mousePosition)) { if (behavior.hasMixedValue) { behavior.floatValue = 0.0f; } else { behavior.floatValue = Convert.ToSingle(!Convert.ToBoolean(behavior.floatValue)); } e.Use(); } } if (EditorGUI.EndChangeCheck()) { if (Convert.ToBoolean(behavior.floatValue)) { materialEditor.RegisterPropertyChangeUndo(behavior.displayName + " Show"); } else { materialEditor.RegisterPropertyChangeUndo(behavior.displayName + " Hide"); } } EditorGUI.showMixedValue = false; if (e.type == EventType.Repaint && behavior.hasMixedValue) { EditorStyles.radioButton.Draw(foldoutRect, "", false, false, true, false); } else { EditorGUI.Foldout(foldoutRect, Convert.ToBoolean(behavior.floatValue), ""); } if (behavior.hasMixedValue) { return(true); } else { return(Convert.ToBoolean(behavior.floatValue)); } }
// ------------------------------------------------------------------- // Private // ------------------------------------------------------------------- private void DrawGraphic(UITransitionBase typedTarget) { this.DrawProperty<UITransitionBase>(x => x.TargetGraphic); switch (typedTarget.TransitionMode) { case UITransitionMode.ColorTint: { if (typedTarget.TargetGraphic == null) { EditorGUILayout.HelpBox("You must have a Graphic target in order to use a color transition.", MessageType.Warning); } else { EditorGUI.BeginChangeCheck(); this.DrawProperty<UITransitionBase>(x => x.NormalColor); if (EditorGUI.EndChangeCheck()) { typedTarget.TargetGraphic.canvasRenderer.SetColor(typedTarget.NormalColor); } this.DrawProperty<UITransitionBase>(x => x.PressedColor); if (this.DrawAllColors) { this.DrawProperty<UITransitionBase>(x => x.HighlightedColor); this.DrawProperty<UITransitionBase>(x => x.SelectedColor); } this.DrawProperty<UITransitionBase>(x => x.ColorMultiplier); this.DrawProperty<UITransitionBase>(x => x.Duration); } break; } case UITransitionMode.TextColor: { if (typedTarget.TargetGraphic == null || typedTarget.TargetGraphic is Text == false) { EditorGUILayout.HelpBox("You must have a Text target in order to use a text color transition.", MessageType.Warning); } else { EditorGUI.BeginChangeCheck(); this.DrawProperty<UITransitionBase>(x => x.NormalColor); if (EditorGUI.EndChangeCheck()) { typedTarget.TargetGraphic.canvasRenderer.SetColor(typedTarget.NormalColor); } this.DrawProperty<UITransitionBase>(x => x.PressedColor); if (this.DrawAllColors) { this.DrawProperty<UITransitionBase>(x => x.HighlightedColor); this.DrawProperty<UITransitionBase>(x => x.SelectedColor); } this.DrawProperty<UITransitionBase>(x => x.Duration); } break; } case UITransitionMode.TextColorTMP: { if (typedTarget.TargetGraphic == null || typedTarget.TargetGraphic is TextMeshProUGUI == false) { EditorGUILayout.HelpBox("You must have a Text target in order to use a text color transition.", MessageType.Warning); } else { EditorGUI.BeginChangeCheck(); this.DrawProperty<UITransitionBase>(x => x.NormalColor); if (EditorGUI.EndChangeCheck()) { typedTarget.TargetGraphic.canvasRenderer.SetColor(typedTarget.NormalColor); } this.DrawProperty<UITransitionBase>(x => x.PressedColor); if (this.DrawAllColors) { this.DrawProperty<UITransitionBase>(x => x.HighlightedColor); this.DrawProperty<UITransitionBase>(x => x.SelectedColor); } this.DrawProperty<UITransitionBase>(x => x.Duration); } break; } case UITransitionMode.SpriteSwap: { if (typedTarget.TargetGraphic == null || typedTarget.TargetGraphic is Image == false) { EditorGUILayout.HelpBox("You must have a Image target in order to use a sprite swap transition.", MessageType.Warning); } else { this.DrawProperty<UITransitionBase>(x => x.PressedColor); if (this.DrawAllColors) { this.DrawProperty<UITransitionBase>(x => x.HighlightedColor); this.DrawProperty<UITransitionBase>(x => x.SelectedColor); } } break; } } }
public override void OnInspectorGUI() { this.serializedObject.Update(); UIHighlightTransition.Transition transition = (UIHighlightTransition.Transition) this.m_TransitionProperty.enumValueIndex; Graphic graphic = this.m_TargetGraphicProperty.objectReferenceValue as Graphic; GameObject targetGameObject = this.m_TargetGameObjectProperty.objectReferenceValue as GameObject; EditorGUILayout.Space(); EditorGUILayout.PropertyField(this.m_TransitionProperty, new GUIContent("Transition")); EditorGUI.indentLevel++; // Check if the transition requires a graphic if (transition == UIHighlightTransition.Transition.ColorTint || transition == UIHighlightTransition.Transition.SpriteSwap || transition == UIHighlightTransition.Transition.TextColor) { EditorGUILayout.PropertyField(this.m_TargetGraphicProperty, new GUIContent("Target Graphic")); if (transition == UIHighlightTransition.Transition.ColorTint) { if (graphic == null) { EditorGUILayout.HelpBox("You must have a Graphic target in order to use a color transition.", MessageType.Info); } else { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(this.m_NormalColorProperty, true); if (EditorGUI.EndChangeCheck()) { graphic.canvasRenderer.SetColor(this.m_NormalColorProperty.colorValue); } EditorGUILayout.PropertyField(this.m_PressedColorProperty, true); EditorGUILayout.PropertyField(this.m_ColorMultiplierProperty, true); EditorGUILayout.PropertyField(this.m_DurationProperty, true); } } else if (transition == UIHighlightTransition.Transition.TextColor) { if ((graphic is Text) == false) { EditorGUILayout.HelpBox("You must have a Text target in order to use a text color transition.", MessageType.Info); } else { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(this.m_NormalColorProperty, true); if (EditorGUI.EndChangeCheck()) { (graphic as Text).color = this.m_NormalColorProperty.colorValue; } EditorGUILayout.PropertyField(this.m_PressedColorProperty, true); EditorGUILayout.PropertyField(this.m_DurationProperty, true); } } else if (transition == UIHighlightTransition.Transition.SpriteSwap) { if (graphic as Image == null) { EditorGUILayout.HelpBox("You must have a Image target in order to use a sprite swap transition.", MessageType.Info); } else { EditorGUILayout.PropertyField(this.m_PressedSpriteProperty, true); } } } else if (transition == UIHighlightTransition.Transition.Animation) { EditorGUILayout.PropertyField(this.m_TargetGameObjectProperty, new GUIContent("Target GameObject")); if (targetGameObject == null) { EditorGUILayout.HelpBox("You must have a Game Object target in order to use a animation transition.", MessageType.Info); } else { EditorGUILayout.PropertyField(this.m_NormalTriggerProperty, true); EditorGUILayout.PropertyField(this.m_PressedTriggerProperty, true); Animator animator = targetGameObject.GetComponent <Animator>(); if (animator == null || animator.runtimeAnimatorController == null) { Rect controlRect = EditorGUILayout.GetControlRect(); controlRect.xMin = (controlRect.xMin + EditorGUIUtility.labelWidth); if (GUI.Button(controlRect, "Auto Generate Animation", EditorStyles.miniButton)) { // Generate the animator controller UnityEditor.Animations.AnimatorController animatorController = this.GenerateAnimatorController(); if (animatorController != null) { if (animator == null) { animator = targetGameObject.AddComponent <Animator>(); } UnityEditor.Animations.AnimatorController.SetAnimatorController(animator, animatorController); } } } } } this.serializedObject.ApplyModifiedProperties(); }
private void PoseBoneDrawer(SerializedProperty property) { EditorGUI.indentLevel++; SerializedProperty bone = property.FindPropertyRelative("bone"); GUIContent boneGUIContent = new GUIContent( bone.stringValue, "The name of the bone being modified by pose."); EditorGUILayout.BeginHorizontal(); bone.isExpanded = EditorGUILayout.Foldout(bone.isExpanded, boneGUIContent); Color currentColor = GUI.color; if (drawBoneIndex == editBoneIndex) { GUI.color = Color.green; if (GUILayout.Button("Editing", EditorStyles.miniButton, GUILayout.Width(60f))) { editBoneIndex = BAD_INDEX; mirrorBoneIndex = BAD_INDEX; } } else if (drawBoneIndex == mirrorBoneIndex) { Color lightBlue = Color.Lerp(Color.blue, Color.cyan, 0.66f); if (mirrorActive) { GUI.color = lightBlue; if (GUILayout.Button("Mirroring", EditorStyles.miniButton, GUILayout.Width(60f))) { mirrorActive = false; } } else { GUI.color = Color.Lerp(lightBlue, Color.white, 0.66f); if (GUILayout.Button("Mirror", EditorStyles.miniButton, GUILayout.Width(60f))) { mirrorActive = true; } } } else { if (GUILayout.Button("Edit", EditorStyles.miniButton, GUILayout.Width(60f))) { editBoneIndex = drawBoneIndex; } } GUI.color = currentColor; EditorGUILayout.EndHorizontal(); if (bone.isExpanded) { EditorGUI.BeginDisabledGroup(drawBoneIndex != editBoneIndex); EditorGUI.indentLevel++; int controlIDLow = GUIUtility.GetControlID(0, FocusType.Passive); // GUI.SetNextControlName("position_" + drawBoneIndex); EditorGUILayout.PropertyField(property.FindPropertyRelative("position"), positionGUIContent); int controlIDHigh = GUIUtility.GetControlID(0, FocusType.Passive); if ((GUIUtility.keyboardControl > controlIDLow) && (GUIUtility.keyboardControl < controlIDHigh)) { if (context != null) { context.activeTool = UMABonePoseEditorContext.EditorTool.Tool_Position; } } // Show Euler angles for rotation SerializedProperty rotation = property.FindPropertyRelative("rotation"); // Use BeginProperty() with fake rect to enable Undo but keep layout correct Rect rotationRect = new Rect(0, 0, 0, 0); EditorGUI.BeginProperty(rotationRect, GUIContent.none, rotation); Vector3 currentRotationEuler = ((Quaternion)rotation.quaternionValue).eulerAngles; Vector3 newRotationEuler = currentRotationEuler; EditorGUI.BeginChangeCheck(); controlIDLow = GUIUtility.GetControlID(0, FocusType.Passive); // GUI.SetNextControlName("rotation_" + drawBoneIndex); newRotationEuler = EditorGUILayout.Vector3Field(rotationGUIContent, newRotationEuler); controlIDHigh = GUIUtility.GetControlID(0, FocusType.Passive); if ((GUIUtility.keyboardControl > controlIDLow) && (GUIUtility.keyboardControl < controlIDHigh)) { if (context != null) { context.activeTool = UMABonePoseEditorContext.EditorTool.Tool_Rotation; } } if (EditorGUI.EndChangeCheck()) { if (newRotationEuler != currentRotationEuler) { rotation.quaternionValue = Quaternion.Euler(newRotationEuler); } } EditorGUI.EndProperty(); SerializedProperty scaleProperty = property.FindPropertyRelative("scale"); controlIDLow = GUIUtility.GetControlID(0, FocusType.Passive); // GUI.SetNextControlName("scale_" + drawBoneIndex); EditorGUILayout.PropertyField(scaleProperty, scaleGUIContent); controlIDHigh = GUIUtility.GetControlID(0, FocusType.Passive); if ((GUIUtility.keyboardControl > controlIDLow) && (GUIUtility.keyboardControl < controlIDHigh)) { if (context != null) { context.activeTool = UMABonePoseEditorContext.EditorTool.Tool_Scale; } } // Warn if there's a non-uniform scale Vector3 scaleValue = scaleProperty.vector3Value; if (!Mathf.Approximately(scaleValue.x, scaleValue.y) || !Mathf.Approximately(scaleValue.y, scaleValue.z)) { EditorGUILayout.BeginHorizontal(); GUILayout.Space(EditorGUIUtility.labelWidth / 2f); if (warningIcon != null) { scaleWarningGUIContent.image = warningIcon; EditorGUILayout.LabelField(scaleWarningGUIContent, GUILayout.MinHeight(warningIcon.height + 4f)); } else { EditorGUILayout.LabelField(scaleWarningGUIContent); } EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel--; EditorGUI.EndDisabledGroup(); } EditorGUI.indentLevel--; }
private void DrawImporter() { //GUILayoutOption max = GUILayout.MaxWidth(EditorGUIUtility.labelWidth); GUILayout.Label(selectedAsset.id, Styles.SetterTitle); // The options for sprite assets if (selectedSprite != null) { EditorGUI.BeginChangeCheck(); float w = EditorGUILayout.FloatField("Line Offset", selectedSprite.lineOffset); float h = EditorGUILayout.FloatField("Line Height", selectedSprite.lineHeight); bool v = EditorGUILayout.Toggle("Alpha Only", selectedSprite.alphaOnly); if (EditorGUI.EndChangeCheck()) { RecordDirty(); selectedSprite.lineOffset = w; selectedSprite.lineHeight = h; selectedSprite.alphaOnly = v; } if (GUILayout.Button("Apply")) { selectedSprite.ImportDictionary(); targetPreference.CallRedraw(); } } // The options for import presets EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); var ctgImport = (ImportCharPresetsType)EditorGUILayout.EnumPopup("Import Preset", TexCharPresets.guessEnumPresets(selectedAsset.catalogRaw)); if (EditorGUI.EndChangeCheck()) { RecordUndo(); selectedAsset.catalogRaw = TexCharPresets.charsFromEnum(ctgImport); selectedAsset.ImportCharacters(selectedAsset.catalogRaw); } selectedAsset.catalogRaw = EditorGUILayout.TextArea(selectedAsset.catalogRaw, Styles.ImporterPresetArea, GUILayout.Height(60)); if (GUILayout.Button("Reimport")) { selectedAsset.ImportCharacters(selectedAsset.catalogRaw); } EditorGUILayout.Space(); #if !TEXDRAW_TMP if (ctgImport == ImportCharPresetsType.Custom) { GUILayout.Label("Preview:"); if (Event.current.type == EventType.Repaint || Event.current.type == EventType.Layout) { GUILayout.Label(string.Join(", ", System.Array.ConvertAll( TexCharPresets.CharsFromString(selectedAsset.catalogRaw), x => x.ToString())), Styles.ImporterOptionFontStyle, GUILayout.ExpandHeight(true)); } else { GUILayout.Label("X"); } EditorGUILayout.Space(); EditorGUILayout.LabelField("Please note that characters outside from the list is still available. Only type on characters that need to be turn into symbols. Max allowed symbol count is 256 per font", Styles.ImporterOptionFontStyle); } #else if (selectedAsset.type != TexAssetType.Sprite) { TexTMPImporter.SetupGUI(selectedAsset); } #endif }
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties) { Material targetMat = materialEditor.target as Material; bool lockInstance = false; if (targetMat.shader != null && targetMat.shader.name.Contains("GPU Instancing")) { lockInstance = true; targetMat.enableInstancing = true; } for (int i = 0; i < properties.Length; i++) { var pop = properties[i]; if (pop.flags == MaterialProperty.PropFlags.HideInInspector) { continue; } string displayName = pop.displayName; bool clearTex = displayName.Contains("{clear}"); if (clearTex) { displayName.Replace("{clear}", ""); } if (IsVisible(ref displayName, targetMat)) { EditorGUI.BeginChangeCheck(); materialEditor.ShaderProperty(pop, displayName); if (EditorGUI.EndChangeCheck()) { OnPorpertyModify(targetMat, pop); //Debug.LogError(pop.name); } } else { if (clearTex) { targetMat.SetTexture(pop.name, null); EditorUtility.SetDirty(targetMat); } } } GUILayout.Space(20); materialEditor.RenderQueueField(); if (lockInstance) { if (targetMat.enableInstancing) { GUILayout.Label("GPU Instancing 已开启"); } else { GUILayout.Label("GPU Instancing 已关闭"); } } else { materialEditor.EnableInstancingField(); } }
private void DrawAdvanced_TriggerSelected(Rect area, SerializedProperty property) { //Draw Target var targRect = new Rect(area.xMin, area.yMin, area.width, EditorGUIUtility.singleLineHeight); var targProp = property.FindPropertyRelative(TriggerTargetProps.PROP_TRIGGERABLETARG); var targLabel = new GUIContent("Triggerable Target"); var targGo = GameObjectUtil.GetGameObjectFromSource(targProp.objectReferenceValue); var newTargGo = EditorGUI.ObjectField(targRect, targLabel, targGo, typeof(GameObject), true) as GameObject; if (newTargGo != targGo) { targGo = newTargGo; targProp.objectReferenceValue = (targGo != null) ? targGo.GetComponentAlt <ITriggerableMechanism>() as Component : null; } var targCompPopupRect = new Rect(area.xMin, targRect.yMax, area.width, EditorGUIUtility.singleLineHeight); if (targProp.objectReferenceValue != null) { var selectedType = targProp.objectReferenceValue.GetType(); var availableMechanismTypes = (from c in targGo.GetComponentsAlt <ITriggerableMechanism>() select c.GetType()).ToArray(); var availableMechanismTypeNames = availableMechanismTypes.Select((tp) => tp.Name).ToArray(); var index = System.Array.IndexOf(availableMechanismTypes, selectedType); EditorGUI.BeginChangeCheck(); index = EditorGUI.Popup(targCompPopupRect, "Target Component", index, availableMechanismTypeNames); if (EditorGUI.EndChangeCheck()) { targProp.objectReferenceValue = (index >= 0) ? targGo.GetComponent(availableMechanismTypes[index]) : null; } } else { EditorGUI.LabelField(targCompPopupRect, "Target Component", "(First Select a Target)"); } //Draw Triggerable Arg var argRect = new Rect(area.xMin, targCompPopupRect.yMax, area.width - ARG_BTN_WIDTH, EditorGUIUtility.singleLineHeight); var btnRect = new Rect(argRect.xMax, argRect.yMin, ARG_BTN_WIDTH, EditorGUIUtility.singleLineHeight); var argArrayProp = property.FindPropertyRelative(TriggerTargetProps.PROP_TRIGGERABLEARGS); if (argArrayProp.arraySize == 0) { EditorGUI.LabelField(argRect, _defaultArgLabel, _undefinedArgLabel); if (GUI.Button(btnRect, _argBtnLabel)) { argArrayProp.arraySize = 1; argArrayProp.serializedObject.ApplyModifiedProperties(); } } else { if (argArrayProp.arraySize > 1) { argArrayProp.arraySize = 1; } var argProp = argArrayProp.GetArrayElementAtIndex(0); //EditorGUI.PropertyField(argRect, argProp, _defaultArgLabel); _variantDrawer.RestrictVariantType = false; _variantDrawer.ForcedObjectType = null; _variantDrawer.OnGUI(argRect, argProp, _defaultArgLabel); if (GUI.Button(btnRect, _argBtnLabel)) { argArrayProp.arraySize = 0; argArrayProp.serializedObject.ApplyModifiedProperties(); } } }
public override void Draw(int aID) { if (Controller.Instance.PlayerMode != Controller.FILE_ADVENTURE_3RDPERSON_PLAYER) { EditorGUILayout.HelpBox("In first person mode there is no destination position.", MessageType.Info); // TODO LANG return; } var exit = Target as ExitDataControl; EditorGUI.BeginChangeCheck(); var has = EditorGUILayout.Toggle(TC.get("NextSceneCell.UsePosition"), exit.hasDestinyPosition()); var scene = exit.getSceneDataControl(); if (EditorGUI.EndChangeCheck()) { var scenes = Controller.Instance.SelectedChapterDataControl.getScenesList(); var destinationScene = scenes.getScenes()[scenes.getSceneIndexByID(exit.getNextSceneId())] ?? scene; var defPlayerPos = destinationScene.getDefaultInitialPosition(); exit.setDestinyPosition(has ? (int)defPlayerPos.x : int.MinValue, has ? (int)defPlayerPos.y : int.MinValue); if (has) { var scale = destinationScene.getPlayerAppropiateScale(); if (scale != 1) { exit.setDestinyScale(scale); } } } if (!has) { EditorGUILayout.HelpBox("Destination position will be based on origin position.", MessageType.Info); // TODO LANG return; } EditorGUI.BeginChangeCheck(); var newPos = EditorGUILayout.Vector2Field(TC.get("Inventory.Position"), new Vector2(exit.getDestinyPositionX(), exit.getDestinyPositionY())); if (EditorGUI.EndChangeCheck()) { exit.setDestinyPosition(Mathf.RoundToInt(newPos.x), Mathf.RoundToInt(newPos.y)); } EditorGUI.BeginChangeCheck(); bool useDestinyScale = EditorGUILayout.Toggle("Use destiny scale", exit.getDestinyScale() >= 0); // TODO LANG if (EditorGUI.EndChangeCheck()) { var sceneScale = (scene != null ? scene.getPlayerAppropiateScale() : 1f); exit.setDestinyScale(useDestinyScale ? sceneScale : float.MinValue); } if (useDestinyScale) { EditorGUI.BeginChangeCheck(); var newScale = Mathf.Max(0.001f, EditorGUILayout.FloatField(TC.get("SceneLocation.Scale"), exit.getDestinyScale())); if (EditorGUI.EndChangeCheck()) { exit.setDestinyScale(newScale); } } else { EditorGUILayout.HelpBox("The player size will stay as before entering the exit.", MessageType.Info); // TODO LANG } var scenesList = Controller.Instance.SelectedChapterDataControl.getScenesList(); var sceneIndex = scenesList.getSceneIndexByID(exit.getNextSceneId()); if (sceneIndex == -1) { EditorGUILayout.HelpBox("Please select a valid destination!", MessageType.Error); // TODO LANG return; } localSceneEditor.Components = SceneEditor.Current.Components; localSceneEditor.Scene = scenesList.getScenes()[sceneIndex]; playerDestination.setValues(exit.getDestinyPositionX(), exit.getDestinyPositionY(), exit.getDestinyScale() < 0 ? 1f : exit.getDestinyScale()); localSceneEditor.Draw(GUILayoutUtility.GetRect(0, 200, GUILayout.ExpandWidth(true))); exit.setDestinyPosition(playerDestination.getX(), playerDestination.getY()); if (useDestinyScale) { exit.setDestinyScale(playerDestination.getScale()); } }