Esempio n. 1
0
        private void OnAudioImporterGUI(bool selectionContainsTrackerFile)
        {
            if (!selectionContainsTrackerFile)
            {
                EditorGUILayout.PropertyField(m_ForceToMono);
                EditorGUI.indentLevel++;
                using (new EditorGUI.DisabledScope(!m_ForceToMono.boolValue))
                {
                    EditorGUILayout.PropertyField(m_Normalize);
                }
                EditorGUI.indentLevel--;
                EditorGUILayout.PropertyField(m_LoadInBackground);
                EditorGUILayout.PropertyField(m_Ambisonic);
            }

            BuildPlatform[] validPlatforms = BuildPlatforms.instance.GetValidPlatforms().ToArray();
            GUILayout.Space(10);
            int shownSettingsPage = EditorGUILayout.BeginPlatformGrouping(validPlatforms, Style.DefaultPlatform);

            if (shownSettingsPage == -1)
            {
                OnSampleSettingGUI(BuildTargetGroup.Unknown, m_DefaultSampleSettings, selectionContainsTrackerFile);
            }
            else
            {
                BuildTargetGroup   platform         = validPlatforms[shownSettingsPage].targetGroup;
                SerializedProperty platformProperty = extraDataSerializedObject.FindProperty($"sampleSettingOverrides.Array.data[{shownSettingsPage}]");
                var isOverriddenProperty            = platformProperty.FindPropertyRelative("isOverridden");

                // Define the UI state of the override here.
                using (var horizontal = new EditorGUILayout.HorizontalScope())
                {
                    var label = EditorGUIUtility.TrTempContent("Override for " + validPlatforms[shownSettingsPage].title.text);
                    using (var propertyScope = new EditorGUI.PropertyScope(horizontal.rect, label, isOverriddenProperty))
                    {
                        EditorGUI.showMixedValue = isOverriddenProperty.hasMultipleDifferentValues;
                        using (var changed = new EditorGUI.ChangeCheckScope())
                        {
                            var newValue = EditorGUILayout.ToggleLeft(propertyScope.content, isOverriddenProperty.boolValue);
                            if (changed.changed)
                            {
                                isOverriddenProperty.boolValue = newValue;
                            }
                        }

                        EditorGUI.showMixedValue = false;
                    }
                }

                using (new EditorGUI.DisabledScope(isOverriddenProperty.hasMultipleDifferentValues || !isOverriddenProperty.boolValue))
                {
                    OnSampleSettingGUI(platform, platformProperty.FindPropertyRelative("settings"), selectionContainsTrackerFile);
                }
            }

            EditorGUILayout.EndPlatformGrouping();
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            using (var propertyScope = new EditorGUI.PropertyScope(position, label, property))
            {
                var index = Mathf.Clamp(property.intValue, MinIndex, MaxIndex);

                property.intValue = EditorGUI.LayerField(position, label, index);
            }
        }
        protected void UvsGUI()
        {
            EditorGUILayout.PropertyField(m_SwapUVChannels, Styles.SwapUVChannels);
            EditorGUILayout.PropertyField(m_GenerateSecondaryUV, Styles.GenerateSecondaryUV);
            if (m_GenerateSecondaryUV.boolValue)
            {
                m_SecondaryUVAdvancedOptions = EditorGUILayout.Foldout(m_SecondaryUVAdvancedOptions, Styles.GenerateSecondaryUVAdvanced, true, EditorStyles.foldout);
                if (m_SecondaryUVAdvancedOptions)
                {
                    using (new EditorGUI.IndentLevelScope())
                    {
                        EditorGUI.BeginChangeCheck();

                        EditorGUILayout.Slider(m_SecondaryUVHardAngle, 0, 180, Styles.secondaryUVHardAngle);
                        EditorGUILayout.Slider(m_SecondaryUVAngleDistortion, 1, 75, Styles.secondaryUVAngleDistortion);
                        EditorGUILayout.Slider(m_SecondaryUVAreaDistortion, 1, 75, Styles.secondaryUVAreaDistortion);

                        using (var horizontal = new EditorGUILayout.HorizontalScope())
                        {
                            using (var prop = new EditorGUI.PropertyScope(horizontal.rect, Styles.secondaryUVMarginMethod, m_SecondaryUVMarginMethod))
                            {
                                EditorGUI.BeginChangeCheck();
                                var newValue = (int)(ModelImporterSecondaryUVMarginMethod)EditorGUILayout.EnumPopup(prop.content, (ModelImporterSecondaryUVMarginMethod)m_SecondaryUVMarginMethod.intValue);
                                if (EditorGUI.EndChangeCheck())
                                {
                                    m_SecondaryUVMarginMethod.intValue = newValue;
                                }
                            }
                        }
                        if (m_SecondaryUVMarginMethod.intValue == (int)ModelImporterSecondaryUVMarginMethod.Calculate)
                        {
                            EditorGUILayout.PropertyField(m_SecondaryUVMinLightmapResolution, Styles.secondaryUVMinLightmapResolution);
                            if (Lightmapping.GetLightingSettingsOrDefaultsFallback().lightmapResolution < m_SecondaryUVMinLightmapResolution.floatValue)
                            {
                                EditorGUILayout.HelpBox(Styles.secondaryUVMinLightmapResolutionNotice);
                            }

                            EditorGUILayout.PropertyField(m_SecondaryUVMinObjectScale, Styles.secondaryUVMinObjectScale);
                        }
                        else
                        {
                            EditorGUILayout.Slider(m_SecondaryUVPackMargin, 1, 64, Styles.secondaryUVPackMargin);
                        }

                        if (EditorGUI.EndChangeCheck())
                        {
                            m_SecondaryUVHardAngle.floatValue             = Mathf.Round(m_SecondaryUVHardAngle.floatValue);
                            m_SecondaryUVPackMargin.floatValue            = Mathf.Round(m_SecondaryUVPackMargin.floatValue);
                            m_SecondaryUVMinLightmapResolution.floatValue = Mathf.Round(m_SecondaryUVMinLightmapResolution.floatValue);
                            m_SecondaryUVMinObjectScale.floatValue        = m_SecondaryUVMinObjectScale.floatValue;
                            m_SecondaryUVAngleDistortion.floatValue       = Mathf.Round(m_SecondaryUVAngleDistortion.floatValue);
                            m_SecondaryUVAreaDistortion.floatValue        = Mathf.Round(m_SecondaryUVAreaDistortion.floatValue);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
 {
     using (var scopeProperty = new EditorGUI.PropertyScope(position, label, property))
     {
         Color cacheColor = GUI.color;
         var   indent     = EditorGUI.indentLevel;
         position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
         EditorGUI.indentLevel = 0;
         var rect = new Rect(position.x, position.y, position.width, position.height);
         if (property.type == "int")
         {
             animatorHash = animatorHash ?? attribute as AnimatorNameAttribute;
             var serializedObject = property.serializedObject.FindProperty(animatorHash.animatorPropertyName);
             if (serializedObject == null)
             {
                 EditorGUI.HelpBox(rect, NO_SERIALIZABLE_FOUND, MessageType.Error);
             }
             else if (serializedObject.objectReferenceValue == null)
             {
                 EditorGUI.HelpBox(rect, NO_ANIMATOR_REFERENCE, MessageType.Info);
             }
             else
             {
                 Animator animator = serializedObject.objectReferenceValue as Animator;
                 if (animator == null)
                 {
                     EditorGUI.HelpBox(rect, TYPE_NOT_SUPPORT, MessageType.Error);
                 }
                 else
                 {
                     GetAllAnimatorStateHashes(ref animator, out parametersName, out parametersHash);
                     currentIndex = GetCurrentIndex(ref parametersHash, property.intValue);
                     using (var scopeChange = new EditorGUI.ChangeCheckScope())
                     {
                         if (currentIndex < 0)
                         {
                             GUI.color = Color.red;
                         }
                         currentIndex = EditorGUI.Popup(rect, currentIndex, parametersName);
                         GUI.color    = cacheColor;
                         if (scopeChange.changed)
                         {
                             property.intValue = parametersHash[currentIndex];
                             GetAllAnimatorStateHashes(ref animator, out parametersName, out parametersHash);
                         }
                     }
                 }
             }
         }
         else
         {
             EditorGUI.HelpBox(rect, TYPE_NOT_SUPPORT, MessageType.Error);
         }
         EditorGUI.indentLevel = indent;
     }
 }
        private void EncodingSettingsGUI(SerializedProperty videoImporterTargetSettings)
        {
            using (var horizontal = new EditorGUILayout.HorizontalScope())
            {
                var property = videoImporterTargetSettings.FindPropertyRelative("codec");
                using (var propertyScope = new EditorGUI.PropertyScope(horizontal.rect, s_Styles.codecContent, property))
                {
                    using (var changed = new EditorGUI.ChangeCheckScope())
                    {
                        EditorGUI.showMixedValue = property.hasMultipleDifferentValues;
                        var newValue = (VideoCodec)EditorGUILayout.EnumPopup(propertyScope.content, (VideoCodec)property.intValue);
                        EditorGUI.showMixedValue = false;
                        if (changed.changed)
                        {
                            property.intValue = (int)newValue;
                        }
                    }
                }
            }

            using (var horizontal = new EditorGUILayout.HorizontalScope())
            {
                var property = videoImporterTargetSettings.FindPropertyRelative("bitrateMode");
                using (var propertyScope = new EditorGUI.PropertyScope(horizontal.rect, s_Styles.bitrateContent, property))
                {
                    using (var changed = new EditorGUI.ChangeCheckScope())
                    {
                        EditorGUI.showMixedValue = property.hasMultipleDifferentValues;
                        var newValue = (VideoBitrateMode)EditorGUILayout.EnumPopup(propertyScope.content, (VideoBitrateMode)property.intValue);
                        EditorGUI.showMixedValue = false;
                        if (changed.changed)
                        {
                            property.intValue = (int)newValue;
                        }
                    }
                }
            }

            using (var horizontal = new EditorGUILayout.HorizontalScope())
            {
                var property = videoImporterTargetSettings.FindPropertyRelative("spatialQuality");
                using (var propertyScope = new EditorGUI.PropertyScope(horizontal.rect, s_Styles.spatialQualityContent, property))
                {
                    using (var changed = new EditorGUI.ChangeCheckScope())
                    {
                        EditorGUI.showMixedValue = property.hasMultipleDifferentValues;
                        var newValue = (VideoSpatialQuality)EditorGUILayout.EnumPopup(propertyScope.content, (VideoSpatialQuality)property.intValue);
                        EditorGUI.showMixedValue = false;
                        if (changed.changed)
                        {
                            property.intValue = (int)newValue;
                        }
                    }
                }
            }
        }
        void HumanoidGUI()
        {
            using (var horizontal = new EditorGUILayout.HorizontalScope())
            {
                using (var propertyField = new EditorGUI.PropertyScope(horizontal.rect, Styles.AvatarDefinition, m_AvatarSetup))
                {
                    EditorGUI.showMixedValue = m_AvatarSetup.hasMultipleDifferentValues;
                    using (var change = new EditorGUI.ChangeCheckScope())
                    {
                        Rect r     = EditorGUILayout.GetControlRect(true, EditorGUI.kSingleLineHeight, EditorStyles.popup);
                        var  value = (ModelImporterAvatarSetup)EditorGUI.EnumPopup(r, propertyField.content, (ModelImporterAvatarSetup)m_AvatarSetup.intValue, e => (ModelImporterAvatarSetup)e != ModelImporterAvatarSetup.NoAvatar);
                        if (change.changed)
                        {
                            m_AvatarSetup.intValue = (int)value;
                        }
                    }

                    EditorGUI.showMixedValue = false;
                }
            }

            if (!m_AvatarSetup.hasMultipleDifferentValues)
            {
                if (m_AvatarSetup.intValue == (int)ModelImporterAvatarSetup.CreateFromThisModel)
                {
                    ConfigureAvatarGUI();
                }
                else
                {
                    CopyAvatarGUI();
                }
            }

            if (m_IsBiped)
            {
                if (m_BipedMappingReport.Count > 0)
                {
                    string report = "A Biped was detected, but cannot be configured properly because of an unsupported hierarchy. Adjust Biped settings in 3DS Max before exporting to correct this problem.\n";

                    for (int reportIter = 0; reportIter < m_BipedMappingReport.Count; reportIter++)
                    {
                        report += m_BipedMappingReport[reportIter];
                    }

                    EditorGUILayout.HelpBox(report, MessageType.Warning);
                }
                else
                {
                    EditorGUILayout.HelpBox("A Biped was detected. Default Biped mapping and T-Pose have been configured for this avatar. Translation DoFs have been activated. Use Configure to modify default Biped setup.", MessageType.Info);
                }
            }

            EditorGUILayout.Space();
        }
Esempio n. 7
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        if (property.propertyType != SerializedPropertyType.Integer)
        {
            // Integer is expected. Everything else is ignored.
            return;
        }

        using (var scope = new EditorGUI.PropertyScope(position, label, property)) {
            property.intValue = EditorGUI.LayerField(position, scope.content, property.intValue, EditorStyles.popup);
        }
    }
Esempio n. 8
0
        void SceneGUI()
        {
            GUILayout.Label(Styles.Scene, EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(m_GlobalScale, Styles.ScaleFactor);

            using (var horizontalScope = new EditorGUILayout.HorizontalScope())
            {
                using (var propertyField = new EditorGUI.PropertyScope(horizontalScope.rect, Styles.UseFileScale, m_UseFileScale))
                {
                    EditorGUI.showMixedValue = m_UseFileScale.hasMultipleDifferentValues;
                    using (var changed = new EditorGUI.ChangeCheckScope())
                    {
                        var result = EditorGUILayout.Toggle(propertyField.content, m_UseFileScale.boolValue);
                        if (changed.changed)
                        {
                            m_UseFileScale.boolValue = result;
                        }
                    }
                    // Put the unit convertion description on a second line if the Inspector is too small.
                    if (!EditorGUIUtility.wideMode)
                    {
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                    }
                    using (new EditorGUI.DisabledScope(!m_UseFileScale.boolValue))
                    {
                        if (!string.IsNullOrEmpty(m_FileScaleUnit.stringValue))
                        {
                            GUIContent content = m_FileScaleUnit.hasMultipleDifferentValues
                                ? EditorGUI.mixedValueContent
                                : GUIContent.Temp(UnityString.Format(L10n.Tr("1{0} (File) to {1}m (Unity)"), m_FileScaleUnit.stringValue, m_FileScaleFactor.floatValue));
                            EditorGUILayout.LabelField(content, GUILayout.ExpandWidth(true));
                        }
                        else
                        {
                            GUIContent content = m_FileScaleUnit.hasMultipleDifferentValues
                                ? EditorGUI.mixedValueContent
                                : GUIContent.Temp(UnityString.Format(L10n.Tr("1 unit (File) to {0}m (Unity)"), m_FileScale.floatValue));
                            EditorGUILayout.LabelField(content);
                        }
                    }
                }
            }

            EditorGUILayout.PropertyField(m_BakeAxisConversion, Styles.BakeAxisConversion);
            EditorGUILayout.PropertyField(m_ImportBlendShapes, Styles.ImportBlendShapes);
            EditorGUILayout.PropertyField(m_ImportVisibility, Styles.ImportVisibility);
            EditorGUILayout.PropertyField(m_ImportCameras, Styles.ImportCameras);
            EditorGUILayout.PropertyField(m_ImportLights, Styles.ImportLights);
            EditorGUILayout.PropertyField(m_PreserveHierarchy, Styles.PreserveHierarchy);
            EditorGUILayout.PropertyField(m_SortHierarchyByName, Styles.SortHierarchyByName);
        }
        private static void DrawGUI(Rect position, SerializedProperty minProperty, SerializedProperty maxProperty, bool delayed)
        {
            position.height = EditorGUIUtility.singleLineHeight;

            const float spacing    = 2;
            const float labelWidth = 28;
            float       totalWidth = position.width;
            float       fieldWith  = totalWidth / 2 - spacing / 2 - labelWidth;

            using (EditorGUI.PropertyScope propertyScope = new EditorGUI.PropertyScope(position, new GUIContent(nameof(FloatRange.Min)), minProperty))
            {
                position.width = labelWidth;
                EditorGUI.LabelField(position, propertyScope.content);

                position.x    += position.width;
                position.width = fieldWith;

                using (EditorGUI.ChangeCheckScope changeCheckScope = new EditorGUI.ChangeCheckScope())
                {
                    float value = delayed
                                      ? EditorGUI.DelayedFloatField(position, minProperty.floatValue)
                                      : EditorGUI.FloatField(position, minProperty.floatValue);

                    if (changeCheckScope.changed)
                    {
                        minProperty.floatValue = value;
                        maxProperty.floatValue = Mathf.Max(value, maxProperty.floatValue);
                    }
                }
            }

            using (EditorGUI.PropertyScope propertyScope = new EditorGUI.PropertyScope(position, new GUIContent(nameof(FloatRange.Max)), maxProperty))
            {
                position.x    += position.width + spacing;
                position.width = labelWidth;
                EditorGUI.LabelField(position, propertyScope.content);

                position.x    += position.width;
                position.width = fieldWith;

                using (EditorGUI.ChangeCheckScope changeCheckScope = new EditorGUI.ChangeCheckScope())
                {
                    float value = delayed
                                      ? EditorGUI.DelayedFloatField(position, maxProperty.floatValue)
                                      : EditorGUI.FloatField(position, maxProperty.floatValue);

                    if (changeCheckScope.changed)
                    {
                        maxProperty.floatValue = Mathf.Max(value, minProperty.floatValue);
                    }
                }
            }
        }
Esempio n. 10
0
        public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
        {
            // Grab every field
            SerializedProperty key        = property.FindPropertyRelative("key");
            SerializedProperty dictionary = property.FindPropertyRelative("dictionary");

            using (EditorGUI.PropertyScope scope = new EditorGUI.PropertyScope(rect, label, property))
            {
                // Calculate height
                float previewHeight = rect.height;
                rect.height    = EditorGUIUtility.singleLineHeight;
                previewHeight -= rect.height;
                Width          = rect.width;

                // Draw label of object
                property.isExpanded = EditorGUI.Foldout(rect, property.isExpanded, scope.content);
                if (property.isExpanded == true)
                {
                    // Indent
                    using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope())
                    {
                        // Draw the properties regularly
                        rect = DrawFields(rect, key, dictionary);
                    }
                }
            }

            if (property.isExpanded == true)
            {
                // Indent
                using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope())
                {
                    // Update status
                    TranslationDictionary translationDictionary = dictionary.objectReferenceValue as TranslationDictionary;
                    string translationKey = key.stringValue;
                    Status status         = UpdateMessageStatus(translationDictionary, translationKey);

                    // Draw preview
                    rect = DrawPreviewLabel(rect, status);

                    // Draw HelpBox
                    rect = DrawHelpBox(rect);

                    // Draw preview
                    rect = DrawTextPreview(rect, status, translationKey, translationDictionary);

                    // Show button to add a new translation key
                    rect = DrawButton(rect, status, translationDictionary, translationKey, dictionary);
                }
            }
        }
Esempio n. 11
0
        public void DrawAreaMaskPopup(Rect position, SerializedProperty property, GUIContent label)
        {
            using (var scope = new EditorGUI.PropertyScope(position, label, property))
            {
                label = scope.content;
                EditorGUI.BeginChangeCheck();
                int newValue = EditorGUI.MaskField(position, label, property.intValue, areaMaskOptions);

                if (EditorGUI.EndChangeCheck())
                {
                    property.intValue = newValue;
                }
            }
        }
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            using (var property = new EditorGUI.PropertyScope(pos, label, prop))
                using (var change = new EditorGUI.ChangeCheckScope())
                {
                    EditorGUI.showMixedValue = prop.hasMultipleDifferentValues;

                    var flags = EditorGUI.MaskField(pos, property.content, prop.intValue, prop.enumNames);

                    if (change.changed)
                    {
                        prop.intValue = flags;
                    }
                }
        }
            /// <summary>Draws Gate fit related fields on the inspector</summary>
            /// <param name="p"><see cref="ISerializedCamera"/> The serialized camera</param>
            /// <param name="owner"><see cref="Editor"/> The editor owner calling this drawer</param>
            public static void Drawer_PhysicalCamera_CameraBody_GateFit(ISerializedCamera p, Editor owner)
            {
                var cam = p.baseCameraSettings;

                using (var horizontal = new EditorGUILayout.HorizontalScope())
                    using (var propertyScope = new EditorGUI.PropertyScope(horizontal.rect, Styles.gateFit, cam.gateFit))
                        using (var checkScope = new EditorGUI.ChangeCheckScope())
                        {
                            int gateValue = (int)(Camera.GateFitMode)EditorGUILayout.EnumPopup(propertyScope.content, (Camera.GateFitMode)cam.gateFit.intValue);
                            if (checkScope.changed)
                            {
                                cam.gateFit.intValue = gateValue;
                            }
                        }
            }
        public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
        {
            using (var property = new EditorGUI.PropertyScope(pos, label, prop))
                using (var change = new EditorGUI.ChangeCheckScope())
                {
                    EditorGUI.showMixedValue = prop.hasMultipleDifferentValues;

                    var value = EditorGUI.ToggleLeft(pos, property.content, prop.boolValue);

                    if (change.changed)
                    {
                        prop.boolValue = value;
                    }
                }
        }
 static void Drawer_PhysicalCamera_CameraBody_GateFit(SerializedHDCamera p, Editor owner)
 {
     using (var horizontal = new EditorGUILayout.HorizontalScope())
         using (var propertyScope = new EditorGUI.PropertyScope(horizontal.rect, CameraUI.PhysicalCamera.Styles.gateFit, p.gateFit))
             using (var checkScope = new EditorGUI.ChangeCheckScope())
             {
                 int gateValue = (int)(Camera.GateFitMode)EditorGUILayout.EnumPopup(propertyScope.content, (Camera.GateFitMode)p.gateFit.intValue);
                 if (checkScope.changed)
                 {
                     p.gateFit.intValue = gateValue;
                 }
                 // Change same property on base camera
                 p.baseCameraSettings.gateFit.intValue = gateValue;
             }
 }
    // get the latest tags from editor and display them in a dropdown with our drawer getting the selected tag
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        if (property.propertyType != SerializedPropertyType.String)
        {
            EditorGUI.PropertyField(position, property, label);
            return;
        }

        using (var scope = new EditorGUI.PropertyScope(position, label, property))
        {
            Tags.Update();
            property.stringValue = Tags.Select(
                EditorGUI.Popup(position, label.text, Tags.IndexOf(property.stringValue), Tags.DisplayNames));
        }
    }
Esempio n. 17
0
 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
 {
     using (var scopeProperty = new EditorGUI.PropertyScope(position, label, property))
     {
         Color cacheColor = GUI.color;
         var   indent     = EditorGUI.indentLevel;
         position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
         EditorGUI.indentLevel = 0;
         var rect = new Rect(position.x, position.y, position.width, position.height);
         if (property.type == "string")
         {
             var names               = new List <string>();
             var inputManager        = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset");
             SerializedObject   obj  = new SerializedObject(inputManager);
             SerializedProperty axes = obj.FindProperty("m_Axes");
             if (axes.arraySize == 0)
             {
                 Debug.Log("No Axes");
             }
             for (int i = 0; i < axes.arraySize; ++i)
             {
                 var axis = axes.GetArrayElementAtIndex(i);
                 var name = axis.FindPropertyRelative("m_Name").stringValue;
                 names.Add(name);
             }
             axesName     = names.ToArray();
             currentIndex = GetCurrentIndex(property);
             using (var scopeChange = new EditorGUI.ChangeCheckScope())
             {
                 if (currentIndex < 0)
                 {
                     GUI.color = Color.red;
                 }
                 currentIndex = EditorGUI.Popup(rect, currentIndex, axesName);
                 GUI.color    = cacheColor;
                 if (scopeChange.changed)
                 {
                     property.stringValue = axesName[currentIndex];
                 }
             }
         }
         else
         {
             EditorGUI.HelpBox(rect, TYPE_NOT_SUPPORT, MessageType.Error);
         }
         EditorGUI.indentLevel = indent;
     }
 }
Esempio n. 18
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        ComponentReferenceDrawer.PropertyField(EditorGUILayout.GetControlRect(), _vprop);

        if (_vprop.objectReferenceValue != null)
        {
            PropertyBindingEditor.DrawComponentEvents(_vprop, _veprop);
        }

        EditorGUILayout.PropertyField(_vmprop);

        var rect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight);

        using (var propertyScope = new EditorGUI.PropertyScope(rect, null, _parmprop))
        {
            GUI.Label(rect, propertyScope.content);

            //parameter type
            var typeProp = _parmprop.FindPropertyRelative("Type");
            var trect    = rect;
            trect.x     += EditorGUIUtility.labelWidth;
            trect.width -= EditorGUIUtility.labelWidth;
            EditorGUI.PropertyField(trect, typeProp);

            //value field
            var typeValue = (BindingParameterType)Enum.GetValues(typeof(BindingParameterType)).GetValue(typeProp.enumValueIndex);
            SerializedProperty valueProp = null;
            switch (typeValue)
            {
            case BindingParameterType.None:
                break;

            default:
                valueProp = _parmprop.FindPropertyRelative(typeValue.ToString());
                break;
            }
            if (valueProp != null)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.PropertyField(valueProp);
                EditorGUI.indentLevel--;
            }
        }

        serializedObject.ApplyModifiedProperties();
    }
Esempio n. 19
0
        static void EnumPropertyField(SerializedProperty property, GUIContent label, GUIContent[] displayedOptions, params GUILayoutOption[] options)
        {
            // This is similar to EditorGUILayout.PropertyField but allows the displayed options of the popup to be specified
            var rect = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight, EditorStyles.popup, options);

            using (var scope = new EditorGUI.PropertyScope(rect, label, property))
                using (var change = new EditorGUI.ChangeCheckScope())
                {
                    var enumValueIndex = property.hasMultipleDifferentValues ? -1 : property.enumValueIndex;
                    enumValueIndex = EditorGUI.Popup(rect, scope.content, enumValueIndex, displayedOptions);
                    if (change.changed)
                    {
                        property.enumValueIndex = enumValueIndex;
                    }
                }
        }
Esempio n. 20
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        if (property.propertyType != SerializedPropertyType.Integer)
        {
            // Integer is expected. Everything else is ignored.
            return;
        }

        using (var scope = new EditorGUI.PropertyScope(position, label, property)) {
            GUIContent[] sortingLayerNames = GetSortingLayerNames();
            int[]        sortingLayerIDs   = GetSortingLayerIDs();

            int sortingLayerIndex = Mathf.Max(0, System.Array.IndexOf <int>(sortingLayerIDs, property.intValue));
            sortingLayerIndex = EditorGUI.Popup(position, scope.content, sortingLayerIndex, sortingLayerNames);
            property.intValue = sortingLayerIDs[sortingLayerIndex];
        }
    }
 private void OnCrossTargetInspectorGUI()
 {
     using (var horizontal = new EditorGUILayout.HorizontalScope())
     {
         using (var property = new EditorGUI.PropertyScope(horizontal.rect, Styles.sRGBTextureContent, m_ColorSpace))
         {
             using (var changed = new EditorGUI.ChangeCheckScope())
             {
                 var sRGB = EditorGUILayout.Toggle(property.content,
                                                   m_ColorSpace.enumValueIndex == (int)VideoColorSpace.sRGB);
                 if (changed.changed)
                 {
                     m_ColorSpace.enumValueIndex = (int)(sRGB ? VideoColorSpace.sRGB : VideoColorSpace.Linear);
                 }
             }
         }
     }
 }
Esempio n. 22
0
 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
 {
     using (var scopeProperty = new EditorGUI.PropertyScope(position, label, property))
     {
         var indent = EditorGUI.indentLevel;
         position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
         EditorGUI.indentLevel = 0;
         var rect = new Rect(position.x, position.y, position.width, position.height);
         if (property.type == "int")
         {
             property.intValue = EditorGUI.IntPopup(rect, property.intValue, intPopup.name, intPopup.value);
         }
         else
         {
             EditorGUI.HelpBox(rect, TYPE_NOT_SUPPORT, MessageType.Error);
         }
         EditorGUI.indentLevel = indent;
     }
 }
Esempio n. 23
0
        void MeshesGUI()
        {
            GUILayout.Label(Styles.Meshes, EditorStyles.boldLabel);
            using (var horizontal = new EditorGUILayout.HorizontalScope())
            {
                using (var prop = new EditorGUI.PropertyScope(horizontal.rect, Styles.MeshCompressionLabel, m_MeshCompression))
                {
                    EditorGUI.BeginChangeCheck();
                    var newValue = (int)(ModelImporterMeshCompression)EditorGUILayout.EnumPopup(prop.content, (ModelImporterMeshCompression)m_MeshCompression.intValue);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_MeshCompression.intValue = newValue;
                    }
                }
            }

            EditorGUILayout.PropertyField(m_IsReadable, Styles.IsReadable);
            EditorGUILayout.PropertyField(m_OptimizeMeshForGPU, Styles.OptimizeMeshForGPU);
            EditorGUILayout.PropertyField(m_AddColliders, Styles.GenerateColliders);
        }
Esempio n. 24
0
        /// <summary>
        /// Draws a <see cref="FloatRange"/>. Optionally also makes it a delayed field.
        /// </summary>
        public static void DrawGUI(Rect position, SerializedProperty property, GUIContent label, bool delayed)
        {
            using EditorGUI.PropertyScope propertyScope = new EditorGUI.PropertyScope(position, label, property);

            position.height = EditorGUIUtility.singleLineHeight;

            Rect labelPosition = position;

            labelPosition.width = EditorGUIUtility.labelWidth;
            EditorGUI.LabelField(labelPosition, propertyScope.content);

            using (new EditorGUI.IndentLevelScope(-EditorGUI.indentLevel))
            {
                position.x     += labelPosition.width;
                position.width -= labelPosition.width;

                SerializedProperty minProperty = property.FindPropertyRelative(MinSerializedProperty);
                SerializedProperty maxProperty = property.FindPropertyRelative(MaxSerializedProperty);
                DrawGUI(position, minProperty, maxProperty, delayed);
            }
        }
Esempio n. 25
0
    void SceneGUI()
    {
        GUILayout.Label(Styles.Scene, EditorStyles.boldLabel);
        EditorGUILayout.PropertyField(m_GlobalScale, Styles.ScaleFactor);

        using (var horizontalScope = new EditorGUILayout.HorizontalScope())
        {
            //EditorGUILayout.LabelField(string.Format(L10n.Tr("1{0} (File) to {1}m (Unity)"), m_FileScaleUnit.stringValue, m_FileScaleFactor.floatValue), GUILayout.ExpandWidth(true));
            using (var propertyField = new EditorGUI.PropertyScope(horizontalScope.rect, Styles.UseFileScale, m_UseFileScale))
            {
                //m_UseFileScale.boolValue = EditorGUILayout.Toggle(propertyField.content, m_UseFileScale.boolValue);
                // Put the unit convertion description on a second line if the Inspector is too small.
                if (!EditorGUIUtility.wideMode)
                {
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                }
                using (new EditorGUI.DisabledScope(!m_UseFileScale.boolValue))
                {
                    if (!string.IsNullOrEmpty(m_FileScaleUnit.stringValue))
                    {
                        GUIContent content = new GUIContent(string.Format(L10n.Tr("1{0} (File) to {1}m (Unity)"), m_FileScaleUnit.stringValue, m_FileScaleFactor.floatValue));
                        EditorGUILayout.LabelField(string.Format(L10n.Tr("1{0} (File) to {1}m (Unity)"), m_FileScaleUnit.stringValue, m_FileScaleFactor.floatValue), GUILayout.ExpandWidth(true));
                    }
                    else
                    {
                        GUIContent content = new GUIContent(string.Format(L10n.Tr("1 unit (File) to {0}m (Unity)"), m_FileScale.floatValue));
                        EditorGUILayout.LabelField(content);
                    }
                }
            }
        }

        /* EditorGUILayout.PropertyField(m_ImportBlendShapes, Styles.ImportBlendShapes);
        *  EditorGUILayout.PropertyField(m_ImportVisibility, Styles.ImportVisibility);
        *  EditorGUILayout.PropertyField(m_ImportCameras, Styles.ImportCameras);
        *  EditorGUILayout.PropertyField(m_ImportLights, Styles.ImportLights);
        *  EditorGUILayout.PropertyField(m_PreserveHierarchy, Styles.PreserveHierarchy); */
    }
        protected void GeometryGUI()
        {
            GUILayout.Label(Styles.Geometry, EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(m_KeepQuads, Styles.KeepQuads);
            EditorGUILayout.PropertyField(m_WeldVertices, Styles.WeldVertices);
            using (var horizontal = new EditorGUILayout.HorizontalScope())
            {
                using (var prop = new EditorGUI.PropertyScope(horizontal.rect, Styles.IndexFormatLabel, m_IndexFormat))
                {
                    EditorGUI.BeginChangeCheck();
                    var newValue = (int)(ModelImporterIndexFormat)EditorGUILayout.EnumPopup(prop.content, (ModelImporterIndexFormat)m_IndexFormat.intValue);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_IndexFormat.intValue = newValue;
                    }
                }
            }

            NormalsTangentsGUI();

            UvsGUI();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(m_Convex, Styles.convexText);

            if (EditorGUI.EndChangeCheck() && m_Convex.boolValue == false)
            {
                m_IsTrigger.boolValue = false;
            }

            EditorGUI.indentLevel++;
            using (new EditorGUI.DisabledScope(!m_Convex.boolValue))
            {
                EditorGUILayout.PropertyField(m_IsTrigger, Styles.isTriggerText);
            }
            EditorGUI.indentLevel--;

            using (var horizontal = new EditorGUILayout.HorizontalScope())
            {
                using (var propertyScope = new EditorGUI.PropertyScope(horizontal.rect, GUIContent.none, m_CookingOptions))
                {
                    EditorGUI.BeginChangeCheck();
                    var newOptions = (MeshColliderCookingOptions)EditorGUILayout.EnumFlagsField(Styles.cookingOptionsText, GetCookingOptions());
                    if (EditorGUI.EndChangeCheck())
                    {
                        SetCookingOptions(newOptions);
                    }
                }
            }

            EditorGUILayout.PropertyField(m_Material, BaseStyles.materialContent);

            EditorGUILayout.PropertyField(m_Mesh, Styles.meshText);

            serializedObject.ApplyModifiedProperties();
        }
        public override void OnGUI(Rect position, SerializedProperty property,
                                   GUIContent label)
        {
            using (var propScope = new EditorGUI.PropertyScope(position, label, property))
            {
                int id        = GUIUtility.GetControlID(FocusType.Keyboard, position);
                var lableRect = position;
                lableRect.y     += (lableRect.height - EditorGUIUtility.singleLineHeight) / 2;
                lableRect.height = EditorGUIUtility.singleLineHeight;
                var toolbarRect = EditorGUI.PrefixLabel(lableRect, id, propScope.content, LABEL_STYLE);
                toolbarRect.width  = EditorGUIUtility.singleLineHeight * 4f;
                toolbarRect.height = position.height;
                toolbarRect.y      = position.y;

                using (var changeScope = new EditorGUI.ChangeCheckScope())
                {
                    var isOn    = GUI.Toolbar(toolbarRect, property.boolValue ? 1 : 0, textures) == 1;
                    var changed = changeScope.changed;

                    if (Event.current.type == EventType.KeyDown &&
                        GUIUtility.keyboardControl == id)
                    {
                        if (Event.current.keyCode == KeyCode.Return ||
                            Event.current.keyCode == KeyCode.KeypadEnter ||
                            Event.current.keyCode == KeyCode.Space)
                        {
                            changed = GUI.changed = true;
                            isOn    = !isOn;
                        }
                    }

                    if (changed)
                    {
                        property.boolValue = isOn;
                    }
                }
            }
        }
Esempio n. 29
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            using (var propScope = new EditorGUI.PropertyScope(position, label, property))
            {
                var labelPos = position;
                if (label.text != "")
                {
                    labelPos.width = labelPos.width / 3;
                    EditorGUI.LabelField(labelPos, propScope.content);
                }
                else
                {
                    labelPos.width = 0;
                }

                var propWidth = position.width - labelPos.width;
                var keyProp   = property.FindPropertyRelative("_key");
                var keyPos    = labelPos;
                keyPos.x    += keyPos.width;
                keyPos.width = propWidth / 3f;
                using (var scope = new EditorGUI.ChangeCheckScope())
                {
                    var p = keyPos;
                    p.width -= WIDTH_OFFSET;
                    var newKey = EditorGUI.TextField(p, keyProp.stringValue);
                    if (scope.changed)
                    {
                        keyProp.stringValue = newKey;
                    }
                }

                var sliderPos = keyPos;
                sliderPos.x    += keyPos.width;
                sliderPos.width = propWidth - keyPos.width;
                OnGUIValue(sliderPos, property, label);
            }
        }
Esempio n. 30
0
 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
 {
     using (var scopeProperty = new EditorGUI.PropertyScope(position, label, property))
     {
         var indent = EditorGUI.indentLevel;
         position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
         EditorGUI.indentLevel = 0;
         var rect       = new Rect(position.x, position.y, position.width, position.height);
         var rectLabel  = new Rect(position.x, position.y, position.width - BUTTON_SIZE, position.height);
         var rectButton = new Rect(position.x + position.width - BUTTON_SIZE, position.y, BUTTON_SIZE, position.height);
         if (property.type == "string")
         {
             bool isEmpty = string.IsNullOrEmpty(property.stringValue);
             if (isEmpty)
             {
                 EditorGUI.LabelField(rectLabel, LABEL_NULL);
             }
             else
             {
                 EditorGUI.LabelField(rectLabel, new GUIContent(property.stringValue));
             }
             if (GUI.Button(rectButton, isEmpty ? BUTTON_LABEL_SELECT : BUTTON_LABEL_CHANGE))
             {
                 string path = GetPath(property.stringValue, stringPath.extension);
                 if (!string.IsNullOrEmpty(path))
                 {
                     property.stringValue = path;
                 }
             }
         }
         else
         {
             EditorGUI.HelpBox(rect, TYPE_NOT_SUPPORT, MessageType.Error);
         }
         EditorGUI.indentLevel = indent;
     }
 }