// Draw the property inside the given rect public override void OnGUI( Rect position, SerializedProperty property, GUIContent label ) { // Now draw the property as a Slider or an IntSlider based on whether it’s a float or integer. if ( property.type != "MinMaxRange" ) Debug.LogWarning( "Use only with MinMaxRange type" ); else { var range = attribute as MinMaxRangeAttribute; var minValue = property.FindPropertyRelative( "rangeStart" ); var maxValue = property.FindPropertyRelative( "rangeEnd" ); var newMin = minValue.floatValue; var newMax = maxValue.floatValue; var xDivision = position.width * 0.33f; var yDivision = position.height * 0.5f; EditorGUI.LabelField( new Rect( position.x, position.y, xDivision, yDivision ), label ); EditorGUI.LabelField( new Rect( position.x, position.y + yDivision, position.width, yDivision ), range.minLimit.ToString( "0.##" ) ); EditorGUI.LabelField( new Rect( position.x + position.width - 28f, position.y + yDivision, position.width, yDivision ), range.maxLimit.ToString( "0.##" ) ); EditorGUI.MinMaxSlider( new Rect( position.x + 24f, position.y + yDivision, position.width - 48f, yDivision ), ref newMin, ref newMax, range.minLimit, range.maxLimit ); EditorGUI.LabelField( new Rect( position.x + xDivision, position.y, xDivision, yDivision ), "From: " ); newMin = Mathf.Clamp( EditorGUI.FloatField( new Rect( position.x + xDivision + 30, position.y, xDivision - 30, yDivision ), newMin ), range.minLimit, newMax ); EditorGUI.LabelField( new Rect( position.x + xDivision * 2f, position.y, xDivision, yDivision ), "To: " ); newMax = Mathf.Clamp( EditorGUI.FloatField( new Rect( position.x + xDivision * 2f + 24, position.y, xDivision - 24, yDivision ), newMax ), newMin, range.maxLimit ); minValue.floatValue = newMin; maxValue.floatValue = newMax; } }
protected virtual void EmitPropertyField(Rect position, UnityEditor.SerializedProperty targetSerializedProperty, GUIContent label) { var multiline = GetMultilineAttribute(); if (multiline == null) { UnityEditor.EditorGUI.PropertyField(position, targetSerializedProperty, label, includeChildren: true); } else { var property = targetSerializedProperty; label = EditorGUI.BeginProperty(position, label, property); var method = typeof(EditorGUI).GetMethod("MultiFieldPrefixLabel", BindingFlags.Static | BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.NonPublic); position = (Rect)method.Invoke(null, new object[] { position, 0, label, 1 }); EditorGUI.BeginChangeCheck(); int indentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; var stringValue = EditorGUI.TextArea(position, property.stringValue); EditorGUI.indentLevel = indentLevel; if (EditorGUI.EndChangeCheck()) { property.stringValue = stringValue; } EditorGUI.EndProperty(); } }
public override void OnGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label) { string fieldName; bool notifyPropertyChanged; { var attr = this.attribute as InspectorDisplayAttribute; fieldName = (attr == null) ? "value" : attr.FieldName; notifyPropertyChanged = (attr == null) ? true : attr.NotifyPropertyChanged; } if (notifyPropertyChanged) { EditorGUI.BeginChangeCheck(); } var targetSerializedProperty = property.FindPropertyRelative(fieldName); if (targetSerializedProperty == null) { UnityEditor.EditorGUI.LabelField(position, label, new GUIContent() { text = "InspectorDisplay can't find target:" + fieldName }); if (notifyPropertyChanged) { EditorGUI.EndChangeCheck(); } return; } else { EmitPropertyField(position, targetSerializedProperty, label); } if (notifyPropertyChanged) { if (EditorGUI.EndChangeCheck()) { property.serializedObject.ApplyModifiedProperties(); // deserialize to field var paths = property.propertyPath.Split('.'); // X.Y.Z... var attachedComponent = property.serializedObject.targetObject; var targetProp = (paths.Length == 1) ? fieldInfo.GetValue(attachedComponent) : GetValueRecursive(attachedComponent, 0, paths); if (targetProp == null) { return; } var propInfo = targetProp.GetType().GetProperty(fieldName, BindingFlags.IgnoreCase | BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); var modifiedValue = propInfo.GetValue(targetProp, null); // retrieve new value var methodInfo = targetProp.GetType().GetMethod("SetValueAndForceNotify", BindingFlags.IgnoreCase | BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (methodInfo != null) { methodInfo.Invoke(targetProp, new object[] { modifiedValue }); } } else { property.serializedObject.ApplyModifiedProperties(); } } }
private static eProp DoPropSwitchDraw(Rect pos, SerProp prop, GUICon cont, bool includeChildren, eProp data) { switch (prop.propertyType) { case SerializedPropertyType.Quaternion: case SerializedPropertyType.Vector4: Vector4PropEditor.Draw(pos, prop, cont); return(data); case SerializedPropertyType.Vector3: Vector3PropEditor.Draw(pos, prop, cont); return(data); case SerializedPropertyType.Vector2: Vector2PropEditor.Draw(pos, prop, cont); return(data); default: EditorGUI.PropertyField(pos, prop, cont, includeChildren); return(data); } }
public override void OnGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label) { var areaIndex = property.intValue; var areaNames = GameObjectUtility.GetNavMeshAreaNames(); /*for (var i = 0; i < areaNames.Length; i++) { * var areaValue = GameObjectUtility.GetNavMeshAreaFromName(areaNames[i]); * if (areaValue == property.intValue) areaIndex = i; * }*/ ArrayUtility.Add(ref areaNames, ""); ArrayUtility.Add(ref areaNames, "Open Area Settings..."); EditorGUI.BeginProperty(position, GUIContent.none, property); EditorGUI.BeginChangeCheck(); areaIndex = EditorGUI.Popup(position, label.text, areaIndex, areaNames); if (EditorGUI.EndChangeCheck()) { if (areaIndex >= 0 && areaIndex < areaNames.Length - 2) { property.intValue = areaIndex;//GameObjectUtility.GetNavMeshAreaFromName(areaNames[areaIndex]); } else if (areaIndex == areaNames.Length - 1) { UnityEditor.AI.NavMeshEditorHelpers.OpenAreaSettings(); } } EditorGUI.EndProperty(); }
void OnEnable() { scriptProp = serializedObject.FindProperty("m_Script"); labelProp = serializedObject.FindProperty("label"); on_Lable_Color = serializedObject.FindProperty("on_Lable_Color"); off_Lable_Color = serializedObject.FindProperty("off_Lable_Color"); }
/// <summary> /// Show the RequiredField inspector. Changes depending on the field being /// empty or not. /// </summary> public override void OnGUI(Rect a_position, SerializedProperty a_property, GUIContent a_label) { // Split the widget position rectangle horizontally. Rect bottom = new Rect(); Rect top = new Rect(); SplitRect(a_position, ref top, ref bottom); // Save the default GUI color for later. Color defaultColor = GUI.color; // If the object pointed by the property is null, then show the error // message, and set the GUI color to red to display the PropertyField in // red. if(a_property.objectReferenceValue == null) { EditorGUI.HelpBox(top, "The field below is required and can't be empty.", MessageType.Error); GUI.color = Color.red; } // Draw the default property field, this drawer does not alter the GUI. if(a_property.objectReferenceValue == null) { EditorGUI.PropertyField(bottom, a_property, a_label); } else { EditorGUI.PropertyField(a_position, a_property, a_label); } // Restore the original colors. GUI.color = defaultColor; }
public static MonoBehaviourData MonoBehaviourDataFromSource(MonoBehaviour target, Hammurabi serializer) { MonoBehaviourData data = new MonoBehaviourData(); data.n = "MonoBehaviour"; SerializedObject serializableTarget = new SerializedObject(target); UnityEditor.SerializedProperty unityProperty = serializableTarget.GetIterator(); List <SerializedProperty> propertiesList = new List <SerializedProperty>(); while (unityProperty.NextVisible(true)) { if (unityProperty.type == "int") { SerializedProperty property = new SerializedProperty(); property.k = unityProperty.name; property.t = SerializablePropertyType.Number; property.v = unityProperty.intValue; propertiesList.Add(property); } else if (unityProperty.type == "PPtr<MonoScript>") { MonoScript script = unityProperty.objectReferenceValue as MonoScript; serializer.LinkScript(script); data.n = script.name; } } data.properties = propertiesList.ToArray(); return(data); }
// 导出ExportAudioTrack private int ExportAudioTrack(AudioTrack audioTrack, JSONObject trackListArr, JSONObject clipListArr) { JSONObject trackJSON = GenerateBaseTrack(audioTrack, PlaybaleTrackTypeMap["AudioTrack"]); #if UNITY_2019_1_OR_NEWER UnityEditor.SerializedObject serializedObject = new UnityEditor.SerializedObject(audioTrack); UnityEditor.SerializedProperty propertiesserializedObject = serializedObject.FindProperty("m_TrackProperties"); float volume = propertiesserializedObject.FindPropertyRelative("volume").floatValue; float stereoPan = propertiesserializedObject.FindPropertyRelative("stereoPan").floatValue; float spatialBlend = propertiesserializedObject.FindPropertyRelative("spatialBlend").floatValue; trackJSON.AddField("volume", volume); trackJSON.AddField("stereoPan", stereoPan); trackJSON.AddField("spatialBlend", spatialBlend); #else trackJSON.AddField("volume", 1); trackJSON.AddField("stereoPan", 0); trackJSON.AddField("spatialBlend", 0); #endif JSONObject clipsIndexArr = trackJSON.GetField("clips"); IEnumerable <TimelineClip> timelineClipList = audioTrack.GetClips(); int num = 0; foreach (TimelineClip timelineClip in timelineClipList) { JSONObject clipJSON = GenerateBaseTimelineClip(timelineClip, PlaybaleClipTypeMap["Audio"]); JSONObject clipData = new JSONObject(JSONObject.Type.OBJECT); clipJSON.AddField("data", clipData); AudioPlayableAsset asset = (AudioPlayableAsset)timelineClip.asset; if ((UnityEngine.Object)asset.clip != (UnityEngine.Object)null) { WXAudioClip converter = new WXAudioClip(asset.clip, gameObject); string clipPath = AddDependencies(converter); clipData.AddField("clip", clipPath); } else { clipData.AddField("clip", JSONObject.nullJO); } // clipData.AddField("clipCaps", ClipCapsMap.ContainsKey(timelineClip.clipCaps) ? ClipCapsMap[timelineClip.clipCaps] : ClipCapsMap[ClipCaps.None]); // clipData.AddField("duration", (float)asset.duration); // 兼容2017没有loop UnityEditor.SerializedObject assetSerializedObject = new UnityEditor.SerializedObject(asset); bool loop = assetSerializedObject.FindProperty("m_Loop").boolValue; clipData.AddField("loop", loop); #if UNITY_2019_1_OR_NEWER UnityEditor.SerializedProperty clipProperties = assetSerializedObject.FindProperty("m_ClipProperties"); float clipVolume = clipProperties.FindPropertyRelative("volume").floatValue; clipData.AddField("volume", clipVolume); #else clipData.AddField("volume", 1); #endif clipsIndexArr.Add(ExportTimelineClip(clipJSON, clipListArr)); num++; } return(ExportTrack(trackJSON, trackListArr)); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); MinMax minMax = attribute as MinMax; if (property.propertyType != SerializedPropertyType.Vector2) { EditorGUI.PropertyField(position, property); Debug.LogWarning("The MinMax property can only be used on Vector2!"); return; } Vector2 value = property.vector2Value; position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); float w = position.width * PERCENT_NUM; Rect leftNum = new Rect(position.x, position.y, w, position.height); Rect slider = new Rect(position.x + w + SPACING, position.y, position.width - 2 * w - SPACING * 2, position.height); Rect rightNum = new Rect(position.x + position.width - w, position.y, w, position.height); float newMin = EditorGUI.FloatField(leftNum, value.x); float newMax = EditorGUI.FloatField(rightNum, value.y); value.x = Mathf.Clamp(newMin, minMax.min, value.y); value.y = Mathf.Clamp(newMax, value.x, minMax.max); EditorGUI.MinMaxSlider(slider, ref value.x, ref value.y, minMax.min, minMax.max); property.vector2Value = value; EditorGUI.EndProperty(); }
public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) { float value = 0f; if (property.propertyType == SerializedPropertyType.Float) { value = property.floatValue; isNumericValue = true; } else if (property.propertyType == SerializedPropertyType.Integer) { value = (float)property.intValue; isNumericValue = true; } else { isNumericValue = false; } if (isNumericValue) { ProgressBarAttribute barAttribute = (ProgressBarAttribute)attribute; EditorGUI.BeginProperty(position, label, property); EditorGUI.ProgressBar(position, (value / barAttribute.max), label.text); EditorGUI.EndProperty(); } else { EditorGUI.BeginProperty(position, label, property); EditorGUI.PropertyField(position, property); EditorGUI.EndProperty(); } }
void DrawHyperLinkInputSection(SP dialog) { if (!isHyperlinkButtonClicked) { return; } if (string.IsNullOrEmpty(hyperlinkSavedText) || hyperLinkSavedStartIndex < 0 || hyperlinkSavedEndIndex < 0) { return; } EGL.BeginVertical(ES.helpBox); EGL.LabelField("Selected Text:", ES.miniBoldLabel); EGL.LabelField(hyperlinkSavedText, ES.helpBox); EGL.LabelField("Link:", ES.miniBoldLabel); savedLink = EGL.TextField(string.IsNullOrEmpty(savedLink) ? HyperlinkPrefix : savedLink); if (GUILayout.Button("Insert hyperlink")) { string newText = string.Format("<a href=\"{0}\">{1}</a>", savedLink, hyperlinkSavedText); ReplaceTextInProperty(dialog, hyperLinkSavedStartIndex, hyperlinkSavedEndIndex, newText); isHyperlinkButtonClicked = false; } EGL.EndVertical(); EGL.Space(); }
void CurveGui ( string name , SerializedProperty animationCurve , Color color ){ // @NOTE: EditorGUILayout.CurveField is buggy and flickers, using PropertyField for now //animationCurve.animationCurveValue = EditorGUILayout.CurveField (GUIContent (name), animationCurve.animationCurveValue, color, Rect (0.0f,0.0f,1.0f,1.0f)); EditorGUILayout.PropertyField (animationCurve, new GUIContent (name)); if (GUI.changed) applyCurveChanges = true; }
public static void construct(SerializedProperty prop){ prop.FindPropertyRelative("name").stringValue = "Animation Set Name"; SerializedProperty animations = prop.FindPropertyRelative ("animations"); animations.arraySize = 1; AnimationDrawer.construct (animations.GetArrayElementAtIndex(0)); prop.serializedObject.ApplyModifiedProperties(); }
void OnEnable() { displayManager = target as RUISDisplayManager; displays = serializedObject.FindProperty("displays"); ruisMenuPrefab = serializedObject.FindProperty("ruisMenuPrefab"); guiX = serializedObject.FindProperty("guiX"); guiY = serializedObject.FindProperty("guiY"); guiZ = serializedObject.FindProperty("guiZ"); guiScaleX = serializedObject.FindProperty("guiScaleX"); guiScaleY = serializedObject.FindProperty("guiScaleY"); hideMouseOnPlay = serializedObject.FindProperty("hideMouseOnPlay"); displayManagerLink = new SerializedObject(displayManager); guiDisplayChoiceLink = displayManagerLink.FindProperty("guiDisplayChoice"); // allowResolutionDialog = serializedObject.FindProperty("allowResolutionDialog"); displayPrefab = Resources.Load("RUIS/Prefabs/Main RUIS/RUISDisplay") as GameObject; displayBoxStyle = new GUIStyle(); displayBoxStyle.normal.textColor = Color.white; displayBoxStyle.alignment = TextAnchor.MiddleCenter; displayBoxStyle.border = new RectOffset(2, 2, 2, 2); displayBoxStyle.margin = new RectOffset(1, 0, 0, 0); displayBoxStyle.wordWrap = true; monoDisplayTexture = Resources.Load("RUIS/Editor/Textures/monodisplay") as Texture2D; stereoDisplayTexture = Resources.Load("RUIS/Editor/Textures/stereodisplay") as Texture2D; menuCursorPrefab = serializedObject.FindProperty("menuCursorPrefab"); menuLayer = serializedObject.FindProperty("menuLayer"); }
/// <summary> /// Override this method to make your own GUI for the property /// </summary> /// <param name="position">Position</param> /// <param name="prop">Property</param> /// <param name="label">Label</param> public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { label = EditorGUI.BeginProperty(position, label, prop); position.height = EditorGUIUtility.singleLineHeight; Rect contents = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); FindProperties(prop); // Draw the preview texture Rect textureRect = new Rect(contents); textureRect.x += textureRect.width - PREVIEW_TEXTURE_SIZE; textureRect.width = PREVIEW_TEXTURE_SIZE; textureRect.height = PREVIEW_TEXTURE_SIZE; EditorGUI.BeginChangeCheck(); HydraEditorUtils.DrawUnindented( () => HydraEditorUtils.TextureField(textureRect, GUIContent.none, m_TextureProp, true)); // Draw the fields Rect contentRect = new Rect(contents); contentRect.width -= textureRect.width + HydraEditorUtils.STANDARD_HORIZONTAL_SPACING * 2.0f; HydraEditorUtils.DrawUnindented( () => HydraEditorUtils.EnumPopupField<Texture2DAttribute.Wrap>(contentRect, GUIContent.none, m_WrapProp, HydraEditorGUIStyles.enumStyle)); // Clear the cache if the texture changes if (EditorGUI.EndChangeCheck()) m_WrappedTextureProp.objectReferenceValue = null; EditorGUI.EndProperty(); }
void OnEnable() { p_Quality = serializedObject.FindProperty("Quality"); p_Samples = serializedObject.FindProperty("Samples"); p_Strength = serializedObject.FindProperty("Strength"); p_Angle = serializedObject.FindProperty("Angle"); }
void OnEnable() { p_RedRefraction = serializedObject.FindProperty("RedRefraction"); p_GreenRefraction = serializedObject.FindProperty("GreenRefraction"); p_BlueRefraction = serializedObject.FindProperty("BlueRefraction"); p_PreserveAlpha = serializedObject.FindProperty("PreserveAlpha"); }
public static void GetClassFieldActions(FieldInfo[] fieldInfos, UnityEditor.SerializedProperty serializedProperty, List <Action> actions) { for (int i = 0; i < fieldInfos.Length; i++) { var fieldInfo = fieldInfos[i]; bool fieldIgnore = false; var customAttrs = fieldInfo.GetCustomAttributes(false); foreach (var attr in customAttrs) { if (attr is IgnoreRelativeAttribute) { fieldIgnore = true; break; } } if (!fieldIgnore) { actions.Add(() => BuildSimple(serializedProperty.FindPropertyRelative(fieldInfo.Name), fieldInfo.Name)); } } // BuildVerticalBox(null, "SourceData"); }
private static System.Reflection.FieldInfo GetFieldInfoFromProperty(UnityEditor.SerializedProperty property) { var serializedProperty = property.serializedObject.FindProperty("m_Script"); if (serializedProperty == null) { return(null); } var monoScript = serializedProperty.objectReferenceValue as UnityEditor.MonoScript; if (monoScript == null) { return(null); } var scriptTypeFromProperty = monoScript.GetClass(); if (scriptTypeFromProperty == null) { return(null); } return(GetFieldInfoFromPropertyPath(scriptTypeFromProperty, property.propertyPath)); }
void Initialize(SerializedProperty property) { if (listedScenes != null && listedScenes.Length > 0) return; var scenes = EditorBuildSettings.scenes; var selectableScenes = new System.Collections.Generic.List<EditorBuildSettingsScene>(); SceneSelectionAttribute attr = (SceneSelectionAttribute)attribute; for (int i = 0; i < scenes.Length; i++) { if (scenes[i].enabled || attr.allowDisabledScenes) selectableScenes.Add(scenes[i]); } listedScenes = new GUIContent[selectableScenes.Count]; for (int i = 0; i < listedScenes.Length; i++) { var path = selectableScenes[i].path; int lastSeparator = path.LastIndexOf("/") + 1; var sceneName = path.Substring(lastSeparator, path.LastIndexOf(".") - lastSeparator); listedScenes[i] = new GUIContent(sceneName, selectableScenes[i].enabled ? "Enabled" : "Disabled"); if (listedScenes[i].text.Equals(property.stringValue)) selectedIndex = i; } }
public void OnEnable() { this.m_UseColliderMask = this.serializedObject.FindProperty("m_UseColliderMask"); this.m_ColliderMask = this.serializedObject.FindProperty("m_ColliderMask"); this.m_ShowColliderMask.value = (this.target as Effector2D).useColliderMask; this.m_ShowColliderMask.valueChanged.AddListener(new UnityAction(((Editor) this).Repaint)); }
void OnEnable () { serObj = new SerializedObject (target); screenBlendMode = serObj.FindProperty("screenBlendMode"); hdr = serObj.FindProperty("hdr"); sepBlurSpread = serObj.FindProperty("sepBlurSpread"); useSrcAlphaAsMask = serObj.FindProperty("useSrcAlphaAsMask"); bloomIntensity = serObj.FindProperty("bloomIntensity"); bloomthreshold = serObj.FindProperty("bloomThreshold"); bloomBlurIterations = serObj.FindProperty("bloomBlurIterations"); lensflares = serObj.FindProperty("lensflares"); lensflareMode = serObj.FindProperty("lensflareMode"); hollywoodFlareBlurIterations = serObj.FindProperty("hollywoodFlareBlurIterations"); hollyStretchWidth = serObj.FindProperty("hollyStretchWidth"); lensflareIntensity = serObj.FindProperty("lensflareIntensity"); lensflarethreshold = serObj.FindProperty("lensflareThreshold"); flareColorA = serObj.FindProperty("flareColorA"); flareColorB = serObj.FindProperty("flareColorB"); flareColorC = serObj.FindProperty("flareColorC"); flareColorD = serObj.FindProperty("flareColorD"); lensFlareVignetteMask = serObj.FindProperty("lensFlareVignetteMask"); tweakMode = serObj.FindProperty("tweakMode"); }
public override void OnGUI (Rect pos, SerializedProperty prop, GUIContent label) { SerializedProperty selection = prop.FindPropertyRelative("selection"); SerializedProperty gameObject = prop.FindPropertyRelative("gameObject"); CacheOwnerGameObject(prop.serializedObject); // draw the enum popup Field int oldEnumIndex = selection.enumValueIndex; EditorGUI.PropertyField( GetRectforRow(pos,0), selection,new GUIContent("Target"),true); if (oldEnumIndex !=selection.enumValueIndex) { if (selection.enumValueIndex==1) { gameObject.objectReferenceValue = ownerGameObject; } } if (selection.enumValueIndex==1) { EditorGUI.indentLevel++; EditorGUI.PropertyField( GetRectforRow(pos,1), gameObject,new GUIContent("Game Object"),true); } }
void OnEnable() { p_aoMode = serializedObject.FindProperty("Mode"); p_noiseTexture = serializedObject.FindProperty("NoiseTexture"); //p_maskTexture = serializedObject.FindProperty("MaskTexture"); #if UNITY_4_X p_useHighPrecisionDepthMap = serializedObject.FindProperty("UseHighPrecisionDepthMap"); #endif p_samples = serializedObject.FindProperty("Samples"); p_downsampling = serializedObject.FindProperty("Downsampling"); p_radius = serializedObject.FindProperty("Radius"); p_intensity = serializedObject.FindProperty("Intensity"); p_distance = serializedObject.FindProperty("Distance"); p_bias = serializedObject.FindProperty("Bias"); p_tag = serializedObject.FindProperty("Tag"); p_lumContribution = serializedObject.FindProperty("LumContribution"); p_occlusionColor = serializedObject.FindProperty("OcclusionColor"); p_cutoffDistance = serializedObject.FindProperty("CutoffDistance"); p_cutoffFalloff = serializedObject.FindProperty("CutoffFalloff"); p_blur = serializedObject.FindProperty("Blur"); p_blurDownsampling = serializedObject.FindProperty("BlurDownsampling"); p_blurPasses = serializedObject.FindProperty("BlurPasses"); p_blurBilateralThreshold = serializedObject.FindProperty("BlurBilateralThreshold"); p_debugAO = serializedObject.FindProperty("DebugAO"); }
void DrawActionButtonArrayElement(SP dialog, int elementIndex) { DrawArrayElement(dialog, elementIndex, "Consent dialog should have at least 1 button.", MinActionButtonsCount, () => SelectedButtonIndex, param => SelectedButtonIndex = param, obj => { var title = obj.FindPropertyRelative("title"); EditorGUI.indentLevel++; string key = obj.propertyPath; if (!privacyFoldoutStates.ContainsKey(key)) { privacyFoldoutStates.Add(key, false); } string titleValue = !string.IsNullOrEmpty(title.stringValue) ? title.stringValue : "[Untitled Button]"; privacyFoldoutStates[key] = EGL.Foldout(privacyFoldoutStates[key], titleValue, true); EditorGUI.indentLevel--; if (privacyFoldoutStates[key]) { EGL.PropertyField(obj.FindPropertyRelative("id")); EGL.PropertyField(title); EGL.PropertyField(obj.FindPropertyRelative("interactable")); EGL.PropertyField(obj.FindPropertyRelative("titleColor")); EGL.PropertyField(obj.FindPropertyRelative("backgroundColor")); EGL.PropertyField(obj.FindPropertyRelative("uninteractableTitleColor")); EGL.PropertyField(obj.FindPropertyRelative("uninteractableBackgroundColor")); } }); }
private static bool ElementExsists(string name, UnityEditor.SerializedProperty currentList) { bool elementExsist = false; for (int i = 0; i < currentList.arraySize; i++) { var element = currentList.GetArrayElementAtIndex(i).Copy(); element.Next(true); do { if (element.name == "m_Name") { if (element.stringValue == name) { elementExsist = true; } break; } } while (element.Next(false)); if (elementExsist) { break; } } return(elementExsist); }
public void OnEnable () { serObj = new SerializedObject (target); reflectionMask = serObj.FindProperty("reflectionMask"); reflectSkybox = serObj.FindProperty("reflectSkybox"); clearColor = serObj.FindProperty("clearColor"); }
public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) { var reference = (FilePathAttribute)attribute; if (!bInitData) { bInitData = true; InitData(reference); } var value = property.stringValue; if ("" == value) { value = "common/behaviour/behaviour.lua"; } int idx = 0; for (int i = 0; i < listPath.Count; ++i) { if (value == listPath[i]) { idx = i; break; } } idx = EditorGUI.Popup(position, property.displayName, idx, listPath.ToArray()); property.stringValue = listPath[idx]; if (GUILayout.Button("refresh", GUILayout.Width(100))) { bInitData = false; } GUILayout.Space(5); }
public override void OnGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label) { var areaIndex = 0; var areaNames = GameObjectUtility.GetNavMeshAreaNames(); for (var i = 0; i < areaNames.Length; i++) { var areaValue = 1 << GameObjectUtility.GetNavMeshAreaFromName(areaNames[i]); if ((property.intValue & areaValue) != 0) { areaIndex |= areaValue; } } //ArrayUtility.Add(ref areaNames, ""); //ArrayUtility.Add(ref areaNames, "Open Area Settings..."); EditorGUI.BeginProperty(position, GUIContent.none, property); EditorGUI.BeginChangeCheck(); areaIndex = EditorGUI.MaskField(position, label, areaIndex, areaNames); if (EditorGUI.EndChangeCheck()) { property.intValue = areaIndex; /*if (areaIndex >= 0 && areaIndex < areaNames.Length - 2) * property.intValue = GameObjectUtility.GetNavMeshAreaFromName(areaNames[areaIndex]); * else if (areaIndex == areaNames.Length - 1) UnityEditor.AI.NavMeshEditorHelpers.OpenAreaSettings();*/ } EditorGUI.EndProperty(); }
public override void OnGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label) { var fp = Helper.GetFPValue(property); var v = UnityEditor.EditorGUI.FloatField(position, label, fp); Helper.SetFPValue(property, v); }
void OnEnable() { serObj = new SerializedObject (target); visualizeFocus = serObj.FindProperty ("visualizeFocus"); focalLength = serObj.FindProperty ("focalLength"); focalSize = serObj.FindProperty ("focalSize"); aperture = serObj.FindProperty ("aperture"); focalTransform = serObj.FindProperty ("focalTransform"); maxBlurSize = serObj.FindProperty ("maxBlurSize"); highResolution = serObj.FindProperty ("highResolution"); blurType = serObj.FindProperty ("blurType"); blurSampleCount = serObj.FindProperty ("blurSampleCount"); nearBlur = serObj.FindProperty ("nearBlur"); foregroundOverlap = serObj.FindProperty ("foregroundOverlap"); dx11BokehThreshold = serObj.FindProperty ("dx11BokehThreshold"); dx11SpawnHeuristic = serObj.FindProperty ("dx11SpawnHeuristic"); dx11BokehTexture = serObj.FindProperty ("dx11BokehTexture"); dx11BokehScale = serObj.FindProperty ("dx11BokehScale"); dx11BokehIntensity = serObj.FindProperty ("dx11BokehIntensity"); }
protected abstract void OnRenderProperty(Rect position, PropertyName exposedPropertyNameString, Object currentReferenceValue, UnityEditor.SerializedProperty exposedPropertyDefault, UnityEditor.SerializedProperty exposedPropertyName, ExposedPropertyMode mode, IExposedPropertyTable exposedProperties);
void OnEnable(){ point = (BezierPoint)target; handleTypeProp = serializedObject.FindProperty("handleStyle"); handle1Prop = serializedObject.FindProperty("_handle1"); handle2Prop = serializedObject.FindProperty("_handle2"); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { rtpc = property.GetValue<AudioRTPC>(); Begin(position, property, label); string rtpcName = string.Format("{4}{0} | {1} [{2}, {3}]", rtpc.Name, rtpc.Type, rtpc.MinValue, rtpc.MaxValue, rtpc.Scope == AudioRTPC.RTPCScope.Global ? "*" : ""); PropertyField(property, rtpcName.ToGUIContent(), false); if (property.isExpanded) { EditorGUI.indentLevel++; PropertyField(property.FindPropertyRelative("Scope"), GUIContent.none); PropertyField(property.FindPropertyRelative("Name")); PropertyField(property.FindPropertyRelative("Type")); PropertyField(property.FindPropertyRelative("MinValue")); PropertyField(property.FindPropertyRelative("MaxValue")); PropertyField(property.FindPropertyRelative("Curve")); EditorGUI.indentLevel--; } End(); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { float height = base.GetPropertyHeight(property, label); CheckRequiredComponents(property.GetValue<EntityBehaviour>()); return height; }
void OnEnable() { script = serializedObject.FindProperty("m_Script"); index = serializedObject.FindProperty("index"); modelOverride = serializedObject.FindProperty("modelOverride"); verbose = serializedObject.FindProperty("verbose"); createComponents = serializedObject.FindProperty("createComponents"); updateDynamically = serializedObject.FindProperty("updateDynamically"); // Load render model names if necessary. if (renderModelNames == null) { renderModelNames = LoadRenderModelNames(); } // Update renderModelIndex based on current modelOverride value. if (modelOverride.stringValue != "") { for (int i = 0; i < renderModelNames.Length; i++) { if (modelOverride.stringValue == renderModelNames[i]) { renderModelIndex = i; break; } } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { WritableAttribute attr = attribute as WritableAttribute; GUI.enabled = attr.Result(DrawerUtil.GetTarget(property)); DrawerUtil.OnGUI(position, property, label); GUI.enabled = true; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); { if (EditorGUI.PropertyField(position, property)) { EditorGUILayout.PropertyField(property.FindPropertyRelative("type")); switch (property.FindPropertyRelative("type").enumValueIndex) { case 0: // None break; case 1: // Sphere EditorGUILayout.PropertyField(property.FindPropertyRelative("center")); EditorGUILayout.PropertyField(property.FindPropertyRelative("radius")); EditorGUILayout.PropertyField(property.FindPropertyRelative("physicsMaterial")); break; case 2: // Box EditorGUILayout.PropertyField(property.FindPropertyRelative("center")); EditorGUILayout.PropertyField(property.FindPropertyRelative("size")); EditorGUILayout.PropertyField(property.FindPropertyRelative("physicsMaterial")); break; case 3: // Capsule EditorGUILayout.PropertyField(property.FindPropertyRelative("center")); EditorGUILayout.PropertyField(property.FindPropertyRelative("direction")); EditorGUILayout.PropertyField(property.FindPropertyRelative("radius")); EditorGUILayout.PropertyField(property.FindPropertyRelative("height")); EditorGUILayout.PropertyField(property.FindPropertyRelative("physicsMaterial")); break; } } } EditorGUI.EndProperty(); }
void OnEnable() { exposure = serializedObject.FindProperty( "Exposure" ); useToneMapping = serializedObject.FindProperty( "UseToneMapping" ); useDithering = serializedObject.FindProperty( "UseDithering" ); qualityLevel = serializedObject.FindProperty( "QualityLevel" ); blendAmount = serializedObject.FindProperty( "BlendAmount" ); lutTexture = serializedObject.FindProperty( "LutTexture" ); lutBlendTexture = serializedObject.FindProperty( "LutBlendTexture" ); maskTexture = serializedObject.FindProperty( "MaskTexture" ); useDepthMask = serializedObject.FindProperty( "UseDepthMask" ); depthMaskCurve = serializedObject.FindProperty( "DepthMaskCurve" ); useVolumes = serializedObject.FindProperty( "UseVolumes" ); exitVolumeBlendTime = serializedObject.FindProperty( "ExitVolumeBlendTime" ); triggerVolumeProxy = serializedObject.FindProperty( "TriggerVolumeProxy" ); volumeCollisionMask = serializedObject.FindProperty( "VolumeCollisionMask" ); if ( !Application.isPlaying ) { AmplifyColorBase effect = target as AmplifyColorBase; bool needsNewID = string.IsNullOrEmpty( effect.SharedInstanceID ); if ( !needsNewID ) needsNewID = FindClone( effect ); if ( needsNewID ) { effect.NewSharedInstanceID(); EditorUtility.SetDirty( target ); } } }
public override void OnGUI(Rect _position, SerializedProperty _property, GUIContent _label) { string valueStr; switch (_property.propertyType) { case SerializedPropertyType.Integer: valueStr = _property.intValue.ToString(); break; case SerializedPropertyType.Boolean: valueStr = _property.boolValue.ToString(); break; case SerializedPropertyType.Float: valueStr = _property.floatValue.ToString("0.00000"); break; case SerializedPropertyType.String: valueStr = _property.stringValue; break; case SerializedPropertyType.Enum: valueStr = _property.enumDisplayNames[_property.enumValueIndex]; break; case SerializedPropertyType.Vector2: valueStr = _property.vector2Value.ToString(); break; case SerializedPropertyType.Vector3: valueStr = _property.vector3Value.ToString(); break; default: valueStr = "(not supported)"; break; } EditorGUI.LabelField(_position, _label.text + ":", valueStr); }
private void OnEnable() { _sendCreationMessageProp = serializedObject.FindProperty("sendCreationMessage"); _useCapProp = serializedObject.FindProperty("useCap"); _capAmountProp = serializedObject.FindProperty("capAmount"); _reuseMessagingProp = serializedObject.FindProperty("reuseMessaging"); }
public override float GetPropertyHeight(SerializedProperty _property, GUIContent _label) { if (_property.isArray) return EditorGUI.GetPropertyHeight(_property); return EditorGUI.GetPropertyHeight(_property) + kButtonHeight + kOffset; }
public static void Show(SerializedProperty list, EditorListOption options = EditorListOption.Default) { if (!list.isArray) { EditorGUILayout.HelpBox(list.name + " is neither an array nor a list!", MessageType.Error); return; } bool showListLabel = (options & EditorListOption.ListLabel) != 0; bool showListSize = (options & EditorListOption.ListSize) != 0; if (showListLabel) { EditorGUILayout.PropertyField(list); EditorGUI.indentLevel += 1; } if (!showListLabel || list.isExpanded) { SerializedProperty size = list.FindPropertyRelative("Array.size"); if (showListSize) { EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size")); } if (size.hasMultipleDifferentValues) { EditorGUILayout.HelpBox("Not showing lists with different sizes.", MessageType.Info); } else { ShowElements(list, options); } } if (showListLabel) { EditorGUI.indentLevel -= 1; } }
void OnEnable() { PrebufferLengthAsMultipleOfDSPBufferProp = serializedObject.FindProperty("PrebufferLengthAsMultipleOfDSPBuffer"); ProcessingPeriodAsMultipleOfDSPBufferProp = serializedObject.FindProperty("ProcessingPeriodAsMultipleOfDSPBuffer"); startUrgencyProp = serializedObject.FindProperty("startUrgency"); themeFolderProp = serializedObject.FindProperty("themeFolder"); startingActionPresetProp = serializedObject.FindProperty ("startActionPreset"); startRendevousProp = serializedObject.FindProperty ("startRendevous"); startMinLevelProp = serializedObject.FindProperty ("startMinLevel"); startMaxLevelProp = serializedObject.FindProperty ("startMaxLevel"); startStingerProp = serializedObject.FindProperty ("startStinger"); startKeyProp = serializedObject.FindProperty ("startKey"); useActionPresetOnStartProp = serializedObject.FindProperty ("useActionPresetOnStart"); startThemeOnStartProp = serializedObject.FindProperty ("startThemeOnStart"); loadTypeProp = serializedObject.FindProperty ("loadType"); showPendingTriggerChangeInfoProp = serializedObject.FindProperty ("showPendingTriggerChangeInfo"); string basePath = Path.Combine(Application.streamingAssetsPath, "ELIAS_Themes"); popup_options = FindSubDirectories(basePath); // Each time this editor is enabled (i.e turns up in the inspector), find // the currently chosen element. popup_index = FindStringIndex(themeFolderProp.stringValue, popup_options); prebufferOptionsIndex = ArrayUtility.IndexOf<int> (prebufferOptionsValues, PrebufferLengthAsMultipleOfDSPBufferProp.intValue); }
internal float GetPropertyHeightSafe(SerializedProperty property, GUIContent label) { ScriptAttributeUtility.s_DrawerStack.Push(this); float propertyHeight = this.GetPropertyHeight(property, label); ScriptAttributeUtility.s_DrawerStack.Pop(); return propertyHeight; }
public override void OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) { if (!_isInitialized) { Init(); } EditorGUI.BeginProperty(position, label, property); { SOEventModeAttribute eventMode = FindEventModeAttribute(); bool shouldDisplayActionMode = (eventMode != null); if (shouldDisplayActionMode) { position.width -= (ActionModeWidth + Space); } EditorGUI.PropertyField(position, property); if (shouldDisplayActionMode) { position.x += position.width + Space; position.width = ActionModeWidth; object[] attributes = fieldInfo.GetCustomAttributes(typeof(SOEventModeAttribute), true); if (attributes.Length > 0) { SOEventModeAttribute eventModeAttribute = attributes[0] as SOEventModeAttribute; string tooltip; Texture selectedIcon; switch (eventModeAttribute.mode) { case SOEventActionMode.Broadcaster: tooltip = "Broadcaster"; selectedIcon = _iconBroadcaster; break; case SOEventActionMode.Listener: tooltip = "Listener"; selectedIcon = _iconListener; break; default: tooltip = string.Empty; selectedIcon = null; break; } if (selectedIcon != null) { GUI.DrawTexture(position, selectedIcon, ScaleMode.ScaleToFit, true, 1.0f); GUI.Label(position, new GUIContent("", tooltip)); } } } } EditorGUI.EndProperty(); }
private void GenerateData() { List <List <int> > levels = new List <List <int> >(); List <Vector2Int> edges = new List <Vector2Int>(); int nodeCountInLevel = 1; int nodeIndex = 0; for (int i = 0; i < levelCount; ++i) { bool lastLevel = (i == levelCount - 1); List <int> nodes = new List <int>(); levels.Add(nodes); int splitTimes = 0; for (int j = 0; j < nodeCountInLevel; ++j) { nodes.Add(nodeIndex); if (!lastLevel) { edges.Add(new Vector2Int(nodeIndex, nodeIndex + nodeCountInLevel + splitTimes)); if (Random.value < splitFactor / i) { splitTimes++; edges.Add(new Vector2Int(nodeIndex, nodeIndex + nodeCountInLevel + splitTimes)); } } nodeIndex++; } nodeCountInLevel += splitTimes; } float height = yInterval * (levels[levelCount - 1].Count - 1); UnityEditor.SerializedProperty spNodes = serializedObject.FindProperty("nodes"); spNodes.arraySize = nodeIndex; for (int i = 0; i < levels.Count; ++i) { List <int> nodes = levels[i]; float yStart = height * 0.5f - (nodes.Count - 1) * yInterval * 0.5f; for (int j = 0; j < nodes.Count; ++j) { spNodes.GetArrayElementAtIndex(nodes[j]).vector2Value = new Vector2(xInterval * i + j, yStart + yInterval * j); } } UnityEditor.SerializedProperty spEdges = serializedObject.FindProperty("edges"); spEdges.arraySize = edges.Count; for (int i = 0; i < edges.Count; ++i) { spEdges.GetArrayElementAtIndex(i).vector2IntValue = edges[i]; } serializedObject.ApplyModifiedProperties(); }
protected virtual Rect DrawPrefixLabel(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) { string tooltip = GetTooltip(property, label); position = EditorGUI.PrefixLabel(position, new GUIContent(label.text, label.image, tooltip)); ClearTooltip(); return(position); }
public virtual bool OnGUILayout(UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, bool includeChildren, UnityEngine.GUILayoutOption[] options) { if (_imp_OnGUILayout == null) { _imp_OnGUILayout = _internalPropertyHandler.GetMethod("OnGUILayout", typeof(System.Func <SerializedProperty, GUIContent, bool, GUILayoutOption[], bool>)) as System.Func <SerializedProperty, GUIContent, bool, GUILayoutOption[], bool>; } return(_imp_OnGUILayout(property, label, includeChildren, options)); }
public virtual bool OnGUI(UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, bool includeChildren) { if (_imp_OnGUI == null) { _imp_OnGUI = _internalPropertyHandler.GetMethod("OnGUI", typeof(System.Func <Rect, SerializedProperty, GUIContent, bool, bool>)) as System.Func <Rect, SerializedProperty, GUIContent, bool, bool>; } return(_imp_OnGUI(position, property, label, includeChildren)); }
public static void BuildEnum(UnityEditor.SerializedProperty serializedProperty, EAudioEventClassify enumTag) { EAudioEventClassify etype = (EAudioEventClassify)serializedProperty.enumValueIndex; etype = (EAudioEventClassify)UnityEditor.EditorGUILayout.EnumPopup("EventClassify: ", etype, GUILayout.ExpandWidth(true)); serializedProperty.enumValueIndex = (int)etype; }
public override void OnGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label) { var rot = property; var euler = rot.quaternionValue.eulerAngles; euler = UnityEditor.EditorGUI.Vector3Field(position, "Rotation", euler); rot.quaternionValue = Quaternion.Euler(euler); }
public static void BuildEnum(UnityEditor.SerializedProperty serializedProperty, EAudioTriggerType enumTag) { EAudioTriggerType etype = (EAudioTriggerType)serializedProperty.enumValueIndex; etype = (EAudioTriggerType)UnityEditor.EditorGUILayout.EnumPopup("TriggerType: ", etype, GUILayout.ExpandWidth(true)); serializedProperty.enumValueIndex = (int)etype; }
public override void OnGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label) { EditorGUI.BeginChangeCheck(); var targetSerializedProperty = property.FindPropertyRelative("component"); UnityEditor.EditorGUI.PropertyField(position, targetSerializedProperty, label, includeChildren: true); EditorGUI.EndChangeCheck(); }
void DrawEditButtons(string selectedText, SP dialog, int startIndex, int endIndex) { Action editBoldTag = () => EditTagInProperty(dialog, startIndex, endIndex, BoldStartTag, BoldEndTag); Action editItalicTag = () => EditTagInProperty(dialog, startIndex, endIndex, ItalicStartTag, ItalicEndTag); DrawEditTextButtons("B", GetBoldButtonStyle(selectedText), editBoldTag); DrawEditTextButtons("I", GetItalicButtonStyle(selectedText), editItalicTag); }
public override void OnGUI(Rect rect, UnityEditor.SerializedProperty prop, GUIContent label) { bool wasEnabled = GUI.enabled; GUI.enabled = false; UnityEditor.EditorGUI.PropertyField(rect, prop); GUI.enabled = wasEnabled; }
public virtual float GetHeight(UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, bool includeChildren) { if (_imp_GetHeight == null) { _imp_GetHeight = _internalPropertyHandler.GetMethod("GetHeight", typeof(System.Func <SerializedProperty, GUIContent, bool, float>)) as System.Func <SerializedProperty, GUIContent, bool, float>; } return(_imp_GetHeight(property, label, includeChildren)); }
public override void OnGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label) { bool wasEnabled = GUI.enabled; GUI.enabled = false; UnityEditor.EditorGUI.PropertyField(position, property, true); GUI.enabled = wasEnabled; }
public void OnEnable() { flagFirstEnable = true; targetComponent = target as VoyagerSettingsComponent; audioLoadTypeWhenStarup = serializedObject.FindProperty("audioLoadTypeWhenStarup"); wiseInstallationPath = serializedObject.FindProperty("wiseInstallationPath"); wiseProjectPath = serializedObject.FindProperty("wiseProjectPath"); }