Esempio n. 1
0
        void DrawProfileInspectorGUI()
        {
            EditorGUILayout.Space();

            bool assetHasChanged = false;
            bool showCopy        = m_Profile.objectReferenceValue != null;

            // The layout system sort of break alignement when mixing inspector fields with custom
            // layouted fields, do the layout manually instead
            int   buttonWidth    = showCopy ? 45 : 60;
            float indentOffset   = EditorGUI.indentLevel * 15f;
            var   lineRect       = GUILayoutUtility.GetRect(1, EditorGUIUtility.singleLineHeight);
            var   labelRect      = new Rect(lineRect.x, lineRect.y, EditorGUIUtility.labelWidth - indentOffset, lineRect.height);
            var   fieldRect      = new Rect(labelRect.xMax, lineRect.y, lineRect.width - labelRect.width - buttonWidth * (showCopy ? 2 : 1), lineRect.height);
            var   buttonNewRect  = new Rect(fieldRect.xMax, lineRect.y, buttonWidth, lineRect.height);
            var   buttonCopyRect = new Rect(buttonNewRect.xMax, lineRect.y, buttonWidth, lineRect.height);

            EditorGUI.PrefixLabel(labelRect, m_ProfileLabel);

            using (var scope = new EditorGUI.ChangeCheckScope())
            {
                m_Profile.objectReferenceValue
                    = (PostProcessProfile)EditorGUI.ObjectField(
                          fieldRect, m_Profile.objectReferenceValue, typeof(PostProcessProfile), false);
                assetHasChanged = scope.changed;
            }

            if (GUI.Button(
                    buttonNewRect,
                    EditorUtilities.GetContent("New|Create a new profile."),
                    showCopy ? EditorStyles.miniButtonLeft : EditorStyles.miniButton))
            {
                // By default, try to put assets in a folder next to the currently active
                // scene file. If the user isn't a scene, put them in root instead.
                var targetName = Target.name;
                var scene      = Target.gameObject.scene;
                var asset      = CreatePostProcessProfile(scene, targetName);
                m_Profile.objectReferenceValue = asset;
                assetHasChanged = true;
            }

            if (showCopy && GUI.Button(
                    buttonCopyRect,
                    EditorUtilities.GetContent("Clone|Create a new profile and copy the content of the currently assigned profile."),
                    EditorStyles.miniButtonRight))
            {
                // Duplicate the currently assigned profile and save it as a new profile
                var origin = (PostProcessProfile)m_Profile.objectReferenceValue;
                var path   = AssetDatabase.GetAssetPath(origin);
                path = AssetDatabase.GenerateUniqueAssetPath(path);

                var asset = Instantiate(origin);
                asset.settings.Clear();
                AssetDatabase.CreateAsset(asset, path);

                foreach (var item in origin.settings)
                {
                    var itemCopy = Instantiate(item);
                    itemCopy.hideFlags = HideFlags.HideInInspector | HideFlags.HideInHierarchy;
                    itemCopy.name      = item.name;
                    asset.settings.Add(itemCopy);
                    AssetDatabase.AddObjectToAsset(itemCopy, asset);
                }

                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();

                m_Profile.objectReferenceValue = asset;
                assetHasChanged = true;
            }

            if (m_Profile.objectReferenceValue == null)
            {
                if (assetHasChanged && m_EffectList != null)
                {
                    m_EffectList.Clear(); // Asset wasn't null before, do some cleanup
                }
                EditorGUILayout.HelpBox(
                    "Assign an existing Post-process Profile by choosing an asset, or create a new one by "
                    + "clicking the \"New\" button.\nNew assets are automatically put in a folder next "
                    + "to your scene file. If your scene hasn't been saved yet they will be created "
                    + "at the root of the Assets folder.",
                    MessageType.Info);
            }
            else
            {
                if (assetHasChanged)
                {
                    RefreshEffectListEditor((PostProcessProfile)m_Profile.objectReferenceValue);
                }
                if (m_EffectList != null)
                {
                    m_EffectList.OnGUI();
                }
            }
        }
Esempio n. 2
0
        private static void DrawInjectionSection()
        {
            using (var changed = new EditorGUI.ChangeCheckScope())
            {
                var fold = GUITools.DrawFoldHeader("Injection Detector", ACTkEditorPrefsSettings.InjectionFoldout);
                if (changed.changed)
                {
                    ACTkEditorPrefsSettings.InjectionFoldout = fold;
                }
            }

            if (!ACTkEditorPrefsSettings.InjectionFoldout)
            {
                return;
            }

            GUILayout.Space(-3f);

            using (GUITools.Vertical(GUITools.PanelWithBackground))
            {
                var enableInjectionDetector = ACTkSettings.Instance.InjectionDetectorEnabled;

                if (SettingsUtils.IsIL2CPPEnabled())
                {
                    EditorGUILayout.HelpBox("Injection is not possible in IL2CPP,\n" +
                                            "this detector is not needed in IL2CPP builds", MessageType.Info, true);
                    GUILayout.Space(5f);
                }
                else if (!InjectionRoutines.IsTargetPlatformCompatible())
                {
                    EditorGUILayout.HelpBox(
                        "Injection Detection is only supported in non-IL2CPP Standalone and Android builds",
                        MessageType.Warning, true);
                    GUILayout.Space(5f);
                }

                using (new GUILayout.HorizontalScope())
                {
                    EditorGUI.BeginChangeCheck();
                    enableInjectionDetector = EditorGUILayout.ToggleLeft(new GUIContent(
                                                                             "Add mono injection detection support to build",
                                                                             "Injection Detector checks assemblies against whitelist. " +
                                                                             "Please enable this option if you're using Injection Detector " +
                                                                             "and default whitelist will be generated while Unity builds resulting build.\n" +
                                                                             "Has no effect for IL2CPP or unsupported platforms."), enableInjectionDetector
                                                                         );
                    if (EditorGUI.EndChangeCheck())
                    {
                        ACTkSettings.Instance.InjectionDetectorEnabled = enableInjectionDetector;
                    }
                }

                GUILayout.Space(3);

                if (GUILayout.Button(new GUIContent(
                                         "Edit Custom Whitelist (" + ACTkSettings.Instance.InjectionDetectorWhiteList.Count + ")",
                                         "Fill any external assemblies which are not included into the project to the user-defined whitelist to make Injection Detector aware of them."))
                    )
                {
                    UserWhitelistEditor.ShowWindow();
                }

                GUILayout.Space(3);
            }
        }
Esempio n. 3
0
        private static void DrawConditionalSection()
        {
            var header = "Conditional Compilation Symbols";

            if (EditorApplication.isCompiling)
            {
                var redColor = ColorTools.GetRedString();
                header += " [<color=#" + redColor + ">compiling</color>]";
            }

            using (var changed = new EditorGUI.ChangeCheckScope())
            {
                var fold = GUITools.DrawFoldHeader(header, ACTkEditorPrefsSettings.ConditionalFoldout);
                if (changed.changed)
                {
                    ACTkEditorPrefsSettings.ConditionalFoldout = fold;
                }
            }

            if (EditorApplication.isCompiling)
            {
                GUI.enabled = false;
            }

            if (!ACTkEditorPrefsSettings.ConditionalFoldout)
            {
                return;
            }

            GUILayout.Space(-3f);

            using (GUITools.Vertical(GUITools.PanelWithBackground))
            {
                GUILayout.Label("Here you may switch conditional compilation symbols used in ACTk.\n" +
                                "Check Readme for more details on each symbol.", EditorStyles.wordWrappedLabel);
                EditorGUILayout.Space();
                if (symbolsData == null)
                {
                    symbolsData = SettingsUtils.GetSymbolsData();
                }

                /*if (GUILayout.Button("Reset"))
                 * {
                 *      var groups = (BuildTargetGroup[])Enum.GetValues(typeof(BuildTargetGroup));
                 *      foreach (BuildTargetGroup buildTargetGroup in groups)
                 *      {
                 *              PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, string.Empty);
                 *      }
                 * }*/

                //using (GUITools.Horizontal())
                GUILayout.Label("Debug Symbols", GUITools.LargeBoldLabel);
                GUITools.Separator();

                DrawSymbol(ref symbolsData.injectionDebug,
                           ACTkEditorConstants.Conditionals.InjectionDebug,
                           "Switches the Injection Detector debug.");
                DrawSymbol(ref symbolsData.injectionDebugVerbose,
                           ACTkEditorConstants.Conditionals.InjectionDebugVerbose,
                           "Switches the Injection Detector verbose debug level.");
                DrawSymbol(ref symbolsData.injectionDebugParanoid,
                           ACTkEditorConstants.Conditionals.InjectionDebugParanoid,
                           "Switches the Injection Detector paranoid debug level.");
                DrawSymbol(ref symbolsData.wallhackDebug,
                           ACTkEditorConstants.Conditionals.WallhackDebug,
                           "Switches the WallHack Detector debug - you'll see the WallHack objects in scene and get extra information in console.");
                DrawSymbol(ref symbolsData.detectionBacklogs,
                           ACTkEditorConstants.Conditionals.DetectionBacklogs,
                           "Enables additional logs in some detectors to make it easier to debug false positives.");

                EditorGUILayout.Space();

                GUILayout.Label("Compatibility Symbols", GUITools.LargeBoldLabel);
                GUITools.Separator();

                DrawSymbol(ref symbolsData.exposeThirdPartyIntegration,
                           ACTkEditorConstants.Conditionals.ThirdPartyIntegration,
                           "Enable to let other third-party code in project know you have ACTk added.");
                DrawSymbol(ref symbolsData.excludeObfuscation,
                           ACTkEditorConstants.Conditionals.ExcludeObfuscation,
                           "Enable if you use Unity-unaware obfuscators which support ObfuscationAttribute to help avoid names corruption.");
                DrawSymbol(ref symbolsData.preventReadPhoneState,
                           ACTkEditorConstants.Conditionals.PreventReadPhoneState,
                           "Disables ObscuredPrefs Lock To Device functionality.");
                DrawSymbol(ref symbolsData.preventInternetPermission,
                           ACTkEditorConstants.Conditionals.PreventInternetPermission,
                           "Disables TimeCheatingDetector functionality.");
                DrawSymbol(ref symbolsData.obscuredAutoMigration,
                           ACTkEditorConstants.Conditionals.ObscuredAutoMigration,
                           "Enables automatic migration of ObscuredFloat and ObscuredDouble instances from the ACTk 1.5.2.0-1.5.8.0 to the 1.5.9.0+ format. Reduces these types performance a bit.");
                DrawSymbol(ref symbolsData.usExportCompatible,
                           ACTkEditorConstants.Conditionals.UsExportCompatible,
                           "Enables US Encryption Export Regulations compatibility mode so ACTk do not force you to declare you're using encryption when publishing your application to the Apple App Store.");

                GUILayout.Space(3);
            }

            GUI.enabled = true;
        }
Esempio n. 4
0
        public override void OnInspectorGUI()
        {
            if (initializeException != null)
            {
                ShowLoadErrorExceptionGUI(initializeException);
                ApplyRevertGUI();
                return;
            }

            extraDataSerializedObject.Update();

            var platforms = CompilationPipeline.GetAssemblyDefinitionPlatforms();

            using (new EditorGUI.DisabledScope(false))
            {
                if (targets.Length > 1)
                {
                    using (new EditorGUI.DisabledScope(true))
                    {
                        var value = string.Join(", ", extraDataTargets.Select(t => t.name).ToArray());
                        EditorGUILayout.TextField(Styles.name, value, EditorStyles.textField);
                    }
                }
                else
                {
                    EditorGUILayout.PropertyField(m_AssemblyName, Styles.name);
                }

                GUILayout.Label(Styles.generalOptions, EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);
                EditorGUILayout.PropertyField(m_AllowUnsafeCode, Styles.allowUnsafeCode);
                EditorGUILayout.PropertyField(m_AutoReferenced, Styles.autoReferenced);
                EditorGUILayout.PropertyField(m_OverrideReferences, Styles.overrideReferences);
                EditorGUILayout.PropertyField(m_NoEngineReferences, Styles.noEngineReferences);

                EditorGUILayout.EndVertical();
                GUILayout.Space(10f);

                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(Styles.defineConstraints, EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();

                if (m_DefineConstraints.serializedProperty.arraySize > 0)
                {
                    var defineConstraintsCompatible = true;

                    var defines = CompilationPipeline.GetDefinesFromAssemblyName(m_AssemblyName.stringValue);

                    if (defines != null)
                    {
                        for (var i = 0; i < m_DefineConstraints.serializedProperty.arraySize && defineConstraintsCompatible; ++i)
                        {
                            var defineConstraint = m_DefineConstraints.serializedProperty.GetArrayElementAtIndex(i).FindPropertyRelative("name").stringValue;

                            if (DefineConstraintsHelper.GetDefineConstraintCompatibility(defines, defineConstraint) != DefineConstraintsHelper.DefineConstraintStatus.Compatible)
                            {
                                defineConstraintsCompatible = false;
                            }
                        }

                        var constraintValidityRect = new Rect(GUILayoutUtility.GetLastRect());
                        constraintValidityRect.x += constraintValidityRect.width - 23;
                        var image   = defineConstraintsCompatible ? Styles.validDefineConstraint : Styles.invalidDefineConstraint;
                        var tooltip = Styles.GetTitleTooltipFromDefineConstraintCompatibility(defineConstraintsCompatible);
                        var content = new GUIContent(image, tooltip);

                        constraintValidityRect.width  = Styles.kValidityIconWidth;
                        constraintValidityRect.height = Styles.kValidityIconHeight;
                        EditorGUI.LabelField(constraintValidityRect, content);
                    }
                }

                m_DefineConstraints.DoLayoutList();

                GUILayout.Label(Styles.references, EditorStyles.boldLabel);

                EditorGUILayout.BeginVertical(GUI.skin.box);
                EditorGUILayout.PropertyField(m_UseGUIDs, Styles.useGUIDs);
                EditorGUILayout.EndVertical();

                m_ReferencesList.DoLayoutList();

                if (extraDataTargets.Any(data => ((AssemblyDefinitionState)data).references != null && ((AssemblyDefinitionState)data).references.Any(x => x.asset == null)))
                {
                    EditorGUILayout.HelpBox("The grayed out assembly references are missing and will not be referenced during compilation.", MessageType.Info);
                }

                if (m_OverrideReferences.boolValue && !m_OverrideReferences.hasMultipleDifferentValues)
                {
                    GUILayout.Label(Styles.precompiledReferences, EditorStyles.boldLabel);

                    UpdatePrecompiledReferenceListEntry();
                    m_PrecompiledReferencesList.DoLayoutList();

                    if (extraDataTargets.Any(data => ((AssemblyDefinitionState)data).precompiledReferences.Any(x => string.IsNullOrEmpty(x.path) && !string.IsNullOrEmpty(x.name))))
                    {
                        EditorGUILayout.HelpBox("The grayed out assembly references are missing and will not be referenced during compilation.", MessageType.Info);
                    }
                }

                GUILayout.Label(Styles.platforms, EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);

                using (var change = new EditorGUI.ChangeCheckScope())
                {
                    EditorGUILayout.PropertyField(m_CompatibleWithAnyPlatform, Styles.anyPlatform);
                    if (change.changed)
                    {
                        // Invert state include/exclude compatibility of states that have the opposite compatibility,
                        // so all states are either include or exclude.
                        var compatibleWithAny = m_CompatibleWithAnyPlatform.boolValue;
                        var needToSwap        = extraDataTargets.Cast <AssemblyDefinitionState>().Where(p => p.compatibleWithAnyPlatform != compatibleWithAny).ToList();
                        extraDataSerializedObject.ApplyModifiedProperties();
                        foreach (var state in needToSwap)
                        {
                            InversePlatformCompatibility(state);
                        }

                        extraDataSerializedObject.Update();
                    }
                }

                if (!m_CompatibleWithAnyPlatform.hasMultipleDifferentValues)
                {
                    GUILayout.Label(m_CompatibleWithAnyPlatform.boolValue ? Styles.excludePlatforms : Styles.includePlatforms, EditorStyles.boldLabel);

                    for (int i = 0; i < platforms.Length; ++i)
                    {
                        SerializedProperty property;
                        if (i >= m_PlatformCompatibility.arraySize)
                        {
                            m_PlatformCompatibility.arraySize++;
                            property           = m_PlatformCompatibility.GetArrayElementAtIndex(i);
                            property.boolValue = false;
                        }
                        else
                        {
                            property = m_PlatformCompatibility.GetArrayElementAtIndex(i);
                        }

                        EditorGUILayout.PropertyField(property, new GUIContent(platforms[i].DisplayName));
                    }

                    EditorGUILayout.Space();

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(Styles.selectAll))
                    {
                        var prop = m_PlatformCompatibility.GetArrayElementAtIndex(0);
                        var end  = m_PlatformCompatibility.GetEndProperty();
                        do
                        {
                            prop.boolValue = true;
                        }while (prop.Next(false) && !SerializedProperty.EqualContents(prop, end));
                    }

                    if (GUILayout.Button(Styles.deselectAll))
                    {
                        var prop = m_PlatformCompatibility.GetArrayElementAtIndex(0);
                        var end  = m_PlatformCompatibility.GetEndProperty();
                        do
                        {
                            prop.boolValue = false;
                        }while (prop.Next(false) && !SerializedProperty.EqualContents(prop, end));
                    }

                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }

                EditorGUILayout.EndVertical();
                GUILayout.Space(10f);

                EditorGUILayout.BeginVertical(GUI.skin.box);
                GUILayout.Label(Styles.versionDefines, EditorStyles.boldLabel);
                m_VersionDefineList.DoLayoutList();
                EditorGUILayout.EndVertical();
            }

            extraDataSerializedObject.ApplyModifiedProperties();

            ApplyRevertGUI();
        }
Esempio n. 5
0
        /// <summary>
        /// Draws the component editors in an inspector.
        /// </summary>
        public void OnGUI()
        {
            if (m_ComponentList == null)
            {
                return;
            }

            if (m_ComponentList.isDirty)
            {
                RefreshEditors();
                m_ComponentList.isDirty = false;
            }

            var isEditable = !UnityEditor.VersionControl.Provider.isActive ||
                             AssetDatabase.IsOpenForEdit(m_ComponentList.self, StatusQueryOptions.UseCachedIfPossible);

            if (!targetRequiresProxyMenu)
            {
                m_MarsInspectorSharedSettings.ComponentTabSelection = 0;
            }

            using (new EditorGUI.DisabledScope(!isEditable))
            {
                EditorGUILayout.LabelField(EditorGUIUtils.GetContent("Components"), EditorStyles.boldLabel);

                var availableWidth         = EditorGUIUtility.currentViewWidth;
                var isWideEnoughForAllTabs = availableWidth > k_MinWidthForAllTabs;
                if (isWideEnoughForAllTabs && targetRequiresProxyMenu)
                {
                    m_MarsInspectorSharedSettings.ComponentTabSelection
                        = GUILayout.Toolbar(m_MarsInspectorSharedSettings.ComponentTabSelection, k_ProxyComponentsStrings);
                }
                else if (targetRequiresProxyMenu)
                {
                    var tabIndex   = m_MarsInspectorSharedSettings.ComponentTabSelection;
                    var shortIndex = (tabIndex == 0) ? 0 : 1;
                    k_ProxyFilterStrings[1] = ((tabIndex == 0) ? k_ProxyFilter : k_ProxyComponentsStrings[tabIndex]) + k_DownArrowPostFix;
                    using (var check = new EditorGUI.ChangeCheckScope())
                    {
                        var selectedShortIndex = GUILayout.Toolbar(shortIndex, k_ProxyFilterStrings);
                        if (shortIndex != selectedShortIndex)
                        {
                            if (selectedShortIndex == 0)
                            {
                                m_MarsInspectorSharedSettings.ComponentTabSelection = 0;
                            }
                            else
                            {
                                ComponentFilterContextMenu();
                            }
                        }
                        else if (check.changed)
                        {
                            ComponentFilterContextMenu();
                        }
                    }
                }

                if (targetRequiresProxyMenu && (MarsInspectorSharedSettings.Instance.ComponentTabSelection == k_ForcesTab))
                {
                    Forces.EditorExtensions.ForcesMenuItemsRegions.DrawForcesInInspectorForMainProxy(m_BaseEditor.target);
                }

                // Override list
                for (var i = 0; i < m_Editors.Count; i++)
                {
                    var editor = m_Editors[i];

                    if (editor.activeProperty.serializedObject.targetObject == null)
                    {
                        continue;
                    }

                    if (CanDrawSelectedOption(editor.target))
                    {
                        var title = string.Format("{0}|{1}", editor.GetDisplayTitle(), editor.GetToolTip());
                        var id    = i; // Needed for closure capture below

                        EditorGUIUtils.DrawSplitter();
                        var displayContent = EditorGUIUtils.DrawHeader(
                            title,
                            editor.baseProperty,
                            editor.activeProperty,
                            () => ResetComponent(editor.target.GetType(), id),
                            () => RemoveComponent(id),
                            () => CopyComponent(id),
                            () => PasteComponent(id),
                            CanPasteComponent(id),
                            editor.HasDisplayProperties()
                            );

                        if (displayContent)
                        {
                            if (beforeDrawComponentInspector != null)
                            {
                                beforeDrawComponentInspector(editor);
                            }

                            using (new EditorGUI.DisabledScope(!editor.activeProperty.boolValue))
                            {
                                editor.OnInternalInspectorGUI();
                            }

                            if (afterDrawComponentInspector != null)
                            {
                                afterDrawComponentInspector(editor);
                            }
                        }
                    }
                }

                if (targetRequiresProxyMenu || (m_BaseEditor.target is ProxyGroup))
                {
                    if (m_Editors.Count > 0)
                    {
                        EditorGUIUtils.DrawSplitter();
                        EditorGUILayout.Space();
                    }
                    AddComponentMenuButton();
                    EditorGUILayout.Space();
                }
            }
        }
        public override void OnInspectorGUI()
        {
            CheckStyles();

            // Display a warning if this settings asset is not currently in use
            if (m_HDPipeline == null || m_HDPipeline.diffusionProfileSettings != m_Target)
            {
                EditorGUILayout.HelpBox("These profiles aren't currently in use, assign this asset to the HD render pipeline asset to use them.", MessageType.Warning);
            }

            serializedObject.Update();

            EditorGUILayout.Space();

            if (m_Profiles == null || m_Profiles.Count == 0)
            {
                return;
            }

            for (int i = 0; i < m_Profiles.Count; i++)
            {
                var profile = m_Profiles[i];

                CoreEditorUtils.DrawSplitter();

                bool state = profile.self.isExpanded;
                state = CoreEditorUtils.DrawHeaderFoldout(profile.name.stringValue, state);

                if (state)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.PropertyField(profile.name);

                    using (var scope = new EditorGUI.ChangeCheckScope())
                    {
                        EditorGUILayout.PropertyField(profile.scatteringDistance, s_Styles.profileScatteringDistance);

                        using (new EditorGUI.DisabledScope(true))
                            EditorGUILayout.FloatField(s_Styles.profileMaxRadius, profile.objReference.maxRadius);

                        EditorGUILayout.Slider(profile.ior, 1.0f, 2.0f, s_Styles.profileIor);
                        EditorGUILayout.PropertyField(profile.worldScale, s_Styles.profileWorldScale);

                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField(s_Styles.SubsurfaceScatteringLabel, EditorStyles.boldLabel);

                        profile.texturingMode.intValue = EditorGUILayout.Popup(s_Styles.texturingMode, profile.texturingMode.intValue, s_Styles.texturingModeOptions);

                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField(s_Styles.TransmissionLabel, EditorStyles.boldLabel);

                        profile.transmissionMode.intValue = EditorGUILayout.Popup(s_Styles.profileTransmissionMode, profile.transmissionMode.intValue, s_Styles.transmissionModeOptions);

                        EditorGUILayout.PropertyField(profile.transmissionTint, s_Styles.profileTransmissionTint);
                        EditorGUILayout.PropertyField(profile.thicknessRemap, s_Styles.profileMinMaxThickness);
                        var thicknessRemap = profile.thicknessRemap.vector2Value;
                        EditorGUILayout.MinMaxSlider(s_Styles.profileThicknessRemap, ref thicknessRemap.x, ref thicknessRemap.y, 0f, 50f);
                        profile.thicknessRemap.vector2Value = thicknessRemap;

                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField(s_Styles.profilePreview0, s_Styles.centeredMiniBoldLabel);
                        EditorGUILayout.LabelField(s_Styles.profilePreview1, EditorStyles.centeredGreyMiniLabel);
                        EditorGUILayout.LabelField(s_Styles.profilePreview2, EditorStyles.centeredGreyMiniLabel);
                        EditorGUILayout.LabelField(s_Styles.profilePreview3, EditorStyles.centeredGreyMiniLabel);
                        EditorGUILayout.Space();

                        serializedObject.ApplyModifiedProperties();

                        if (scope.changed)
                        {
                            // Validate and update the cache for this profile only
                            profile.objReference.Validate();
                            m_Target.UpdateCache(i);
                        }
                    }

                    RenderPreview(profile);

                    EditorGUILayout.Space();
                    EditorGUI.indentLevel--;
                }

                profile.self.isExpanded = state;
            }

            CoreEditorUtils.DrawSplitter();

            serializedObject.ApplyModifiedProperties();
        }
        private void OnGUI()
        {
            using (var check = new EditorGUI.ChangeCheckScope())
            {
                renderer = EditorGUILayout.ObjectField(
                    "SkinnedMeshRenderer",
                    renderer,
                    typeof(SkinnedMeshRenderer),
                    true
                    ) as SkinnedMeshRenderer;


                if (check.changed)
                {
                    if (renderer != null)
                    {
                        shapeKeyNames     = GetBlendShapeListFromRenderer(renderer);
                        selectedShapeKeys = new bool[shapeKeyNames.Count()];
                    }
                }
            }

            if (shapeKeyNames != null)
            {
                isOpenedBlendShape = EditorGUILayout.Foldout(isOpenedBlendShape, "Shape Keys");
                if (isOpenedBlendShape)
                {
                    using (new EditorGUI.IndentLevelScope())
                        using (var scroll = new EditorGUILayout.ScrollViewScope(shapeKeyScrollPos, GUI.skin.box))
                        {
                            shapeKeyScrollPos = scroll.scrollPosition;
                            for (int i = 0; i < shapeKeyNames.Count(); i++)
                            {
                                selectedShapeKeys[i] = EditorGUILayout.ToggleLeft(shapeKeyNames[i], selectedShapeKeys[i]);
                            }
                        }
                }
                deleteOriginShapeKey = EditorGUILayout.Toggle("Delete Origin ShapeKey", deleteOriginShapeKey);
                combinedShapeKeyName = EditorGUILayout.TextField("Mixed ShapeKey Name", combinedShapeKeyName);
            }

            using (new EditorGUI.DisabledScope(renderer == null || combinedShapeKeyName == "" || (selectedShapeKeys != null && selectedShapeKeys.Sum(x => x ? 1 : 0) <= 1)))
            {
                if (GUILayout.Button("Mix ShapeKeys"))
                {
                    // 2つ以上が選択されている
                    if (selectedShapeKeys.Sum(x => x ? 1 : 0) > 1)
                    {
                        // 選択されている要素のインデックスの配列
                        var selectedBlendShapeIndexs = selectedShapeKeys
                                                       .Select((isSelect, index) => new { Index = index, Value = isSelect })
                                                       .Where(x => x.Value)
                                                       .Select(x => x.Index)
                                                       .ToArray();

                        MixShapeKey(renderer, selectedBlendShapeIndexs, combinedShapeKeyName, deleteOriginShapeKey);
                    }

                    shapeKeyNames     = GetBlendShapeListFromRenderer(renderer);
                    selectedShapeKeys = new bool[shapeKeyNames.Count()];
                }
            }
        }
        void DrawEvent()
        {
            // EditorGUILayout.HelpBox(" also the target MonoBahaviour required to assign in GlobalSetting", MessageType.Info);
            // if (GUILayout.Button("Setting"))
            // {
            //     ViewSystemVisualEditor.globalSettingWindow.show = true;
            // }
            using (var horizon = new GUILayout.HorizontalScope(GUILayout.Height(40)))
            {
                EditorGUILayout.HelpBox("Only the method which has \"Component\" parameters will be shown. If you don't see your method in dropdown list, you can try 'Refresh'. (Very slow)", MessageType.Info);
                if (GUILayout.Button(new GUIContent(EditorGUIUtility.FindTexture("d_Refresh@2x"), "Refresh"), Drawer.removeButtonStyle, GUILayout.Width(40)))
                {
                    ViewSystemVisualEditor.RefreshMethodDatabase();
                }
            }

            if (ViewSystemVisualEditor.classMethodInfo.Count == 0)
            {
                return;
            }

            using (var scrollViewScope = new GUILayout.ScrollViewScope(scrollPositionEvent))
            {
                scrollPositionEvent = scrollViewScope.scrollPosition;

                foreach (var item in viewPageItem.eventDatas.ToArray())
                {
                    using (var horizon = new EditorGUILayout.HorizontalScope("box"))
                    {
                        using (var vertical = new EditorGUILayout.VerticalScope())
                        {
                            using (var horizon2 = new EditorGUILayout.HorizontalScope())
                            {
                                Transform targetObject;

                                if (!string.IsNullOrEmpty(item.targetTransformPath))
                                {
                                    targetObject = viewPageItem.viewElement.transform.Find(item.targetTransformPath);
                                }
                                else
                                {
                                    targetObject = viewPageItem.viewElement.transform;
                                }

                                if (targetObject == null)
                                {
                                    using (var vertical2 = new EditorGUILayout.VerticalScope())
                                    {
                                        GUILayout.Label(new GUIContent($"Target GameObject is Missing : [{viewPageItem.viewElement.name}/{item.targetTransformPath}]", Drawer.miniErrorIcon));
                                        item.targetTransformPath = EditorGUILayout.TextField(item.targetTransformPath);
                                        if (GUILayout.Button(new GUIContent("Remove item!")))
                                        {
                                            viewPageItem.eventDatas.RemoveAll(m => m == item);
                                        }
                                    }
                                    continue;
                                }

                                UnityEngine.Object targetComponent = targetObject.GetComponent(item.targetComponentType);

                                if (targetComponent == null)
                                {
                                    using (var vertical2 = new EditorGUILayout.VerticalScope())
                                    {
                                        GUILayout.Label(new GUIContent($"ComponentType : [{item.targetComponentType}] is missing!", Drawer.miniErrorIcon), GUILayout.Height(EditorGUIUtility.singleLineHeight));
                                        GUILayout.Label(new GUIContent($"Use Toolvar>Verifiers>Verify Override to fix the problem."));
                                        if (GUILayout.Button(new GUIContent("Remove item!")))
                                        {
                                            viewPageItem.eventDatas.RemoveAll(m => m == item);
                                        }
                                    }
                                    continue;
                                }
                                using (var vertical2 = new GUILayout.VerticalScope())
                                {
                                    GUIContent l = new GUIContent(target.name + (string.IsNullOrEmpty(item.targetTransformPath) ? "" : ("/" + item.targetTransformPath)), EditorGUIUtility.FindTexture("Prefab Icon"));
                                    GUILayout.Label(l, GUILayout.Height(EditorGUIUtility.singleLineHeight));
                                    // GUILayout.Label(Drawer.arrowIcon, GUILayout.Height(20));
                                    using (var horizon3 = new GUILayout.HorizontalScope())
                                    {
                                        GUILayout.Space(20);
                                        var _cachedContent = new GUIContent(EditorGUIUtility.ObjectContent(targetComponent, targetComponent.GetType()));
                                        GUILayout.Label(_cachedContent, GUILayout.Height(EditorGUIUtility.singleLineHeight));
                                    }
                                }
                            }
                            int currentSelectClass = 0;
                            CMEditorLayout.GroupedPopupData[] groupDatas = null;
                            if (!string.IsNullOrEmpty(item.scriptName) && !ViewSystemVisualEditor.classMethodInfo.TryGetValue(item.scriptName, out groupDatas))
                            {
                                GUILayout.Label("Target class name not found");
                            }
                            else
                            {
                                currentSelectClass = string.IsNullOrEmpty(item.scriptName) ? 0 : ViewSystemVisualEditor.classMethodInfo.Values.ToList().IndexOf(groupDatas);

                                using (var check = new EditorGUI.ChangeCheckScope())
                                {
                                    currentSelectClass = EditorGUILayout.Popup("Event Script", currentSelectClass, ViewSystemVisualEditor.classMethodInfo.Select(m => m.Key).ToArray());
                                    if (check.changed)
                                    {
                                        if (currentSelectClass != 0)
                                        {
                                            var c = ViewSystemVisualEditor.classMethodInfo.ElementAt(currentSelectClass);
                                            item.scriptName = c.Key;
                                            item.methodName = "";
                                        }
                                        else
                                        {
                                            item.scriptName = "";
                                            item.methodName = "";
                                        }
                                    }
                                }
                                if (currentSelectClass != 0)
                                {
                                    using (var check = new EditorGUI.ChangeCheckScope())
                                    {
                                        using (var horizon2 = new EditorGUILayout.HorizontalScope())
                                        {
                                            var c       = ViewSystemVisualEditor.classMethodInfo.ElementAt(currentSelectClass).Value;
                                            var current = c.SingleOrDefault(m => m.name == item.methodName);

                                            CMEditorLayout.GroupedPopupField(item.GetHashCode(), new GUIContent("Event Method"), c, current,
                                                                             (select) =>
                                            {
                                                item.methodName = select.name;
                                            }
                                                                             );
                                        }
                                    }
                                }
                            }
                        }
                        if (GUILayout.Button(ReorderableList.defaultBehaviours.iconToolbarMinus, removeButtonStyle, GUILayout.Height(EditorGUIUtility.singleLineHeight * 2)))
                        {
                            viewPageItem.eventDatas.Remove(item);
                        }
                    }
                }
            }
        }
        private void OnGUI()
        {
#if VRC_SDK_VRCSDK2
            using (var check = new EditorGUI.ChangeCheckScope())
            {
                avatar = EditorGUILayout.ObjectField("Avatar", avatar, typeof(VRC_AvatarDescriptor), true) as VRC_AvatarDescriptor;

                if (check.changed)
                {
                    if (avatar != null)
                    {
                        animator   = avatar.gameObject.GetComponent <Animator>();
                        controller = avatar.CustomStandingAnims;
                    }
                    else
                    {
                        animator   = null;
                        controller = null;
                    }
                }
            }
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Camera", EditorStyles.boldLabel);
            using (new EditorGUILayout.HorizontalScope())
            {
                if (GUILayout.Button("Scene View"))
                {
                    EditorApplication.ExecuteMenuItem("Window/General/Scene");
                }
                if (GUILayout.Button("Game View"))
                {
                    EditorApplication.ExecuteMenuItem("Window/General/Game");
                }
            }

            /*
             * using (new EditorGUI.DisabledGroupScope(animator is null))
             * {
             *      if (GUILayout.Button("Focus on Avatar"))
             *      {
             *              var sceneViewCamera = SceneView.lastActiveSceneView.camera;
             *              sceneViewCamera.transform.position = animator.transform.position;
             *      }
             * }
             */

            GUILayout.Space(15);

            EditorGUILayout.LabelField("Testing", EditorStyles.boldLabel);
            using (new EditorGUILayout.HorizontalScope())
            {
                using (new EditorGUI.DisabledGroupScope(EditorApplication.isPlayingOrWillChangePlaymode || avatar == null))
                {
                    if (GUILayout.Button("Play"))
                    {
                        defaultController = animator.runtimeAnimatorController;
                        animator.runtimeAnimatorController = controller;

                        poseConstraintObj = CreatePoseConstrainterToRootIfNeeded();
                        poseConstraint    = poseConstraintObj.GetComponent <PoseConstraint>();
                        poseConstraint.UpdateBoneInfo(animator);

                        EditorApplication.isPlaying = true;
                    }
                }
                using (new EditorGUI.DisabledGroupScope(!EditorApplication.isPlayingOrWillChangePlaymode))
                {
                    if (GUILayout.Button("Stop"))
                    {
                        EditorApplication.isPlaying        = false;
                        animator.runtimeAnimatorController = defaultController;
                    }
                }
            }

            if (avatar == null && !EditorApplication.isPlaying)
            {
                EditorGUILayout.HelpBox("Avatarを設定してください", MessageType.Error);
            }

            if (avatar != null && animator != null && controller != null)
            {
                EditorGUILayout.HelpBox("Playを選択するとテストが実行できます", MessageType.Info);
            }

            EditorGUILayout.Space();

            using (new EditorGUI.DisabledGroupScope(!EditorApplication.isPlayingOrWillChangePlaymode))
            {
                if (GUILayout.Button("Reset All"))
                {
                    playingType = PlayingType.NONE;
                    playingHand = PlayingHand.NONE;
                }

                EditorGUILayout.Space();

                EditorGUILayout.LabelField("AnimationOverrides", EditorStyles.boldLabel);
                using (new EditorGUI.IndentLevelScope())
                {
                    using (new EditorGUILayout.HorizontalScope())
                    {
                        EditorGUILayout.LabelField("NONE");
                        if (GUILayout.Button("Left"))
                        {
                            if (playingType == PlayingType.OVERRIDE &&
                                playingHand == PlayingHand.BOTH)
                            {
                                playingHand = PlayingHand.RIGHT;
                            }
                            else
                            {
                                playingType = PlayingType.NONE;
                            }
                            PlayOverride("Left", 0, animator);
                        }
                        if (GUILayout.Button("Right"))
                        {
                            if (playingType == PlayingType.OVERRIDE &&
                                playingHand == PlayingHand.BOTH)
                            {
                                playingHand = PlayingHand.LEFT;
                            }
                            else
                            {
                                playingType = PlayingType.NONE;
                            }
                            PlayOverride("Right", 0, animator);
                        }
                    }
                    for (int overrideNumber = 0; overrideNumber < OVERRIDES.Length; overrideNumber++)
                    {
                        AnimationClip overrideAnimation = null;
                        string        overrideName      = string.Empty;

                        if (controller != null)
                        {
                            overrideAnimation = controller[OVERRIDES[overrideNumber]];

                            if (overrideAnimation.name != OVERRIDES[overrideNumber])
                            {
                                overrideName = $"({overrideAnimation.name})";
                            }
                        }

                        // AnimationClipとOVERRIDES[overrideNumber]の名前が同じであれば未設定
                        using (new EditorGUI.DisabledGroupScope(controller == null || overrideAnimation.name == OVERRIDES[overrideNumber]))
                            using (new EditorGUILayout.HorizontalScope())
                            {
                                EditorGUILayout.LabelField(OVERRIDES[overrideNumber], overrideName);

                                if (GUILayout.Button("Left"))
                                {
                                    playingType = PlayingType.OVERRIDE;
                                    if (playingHand == PlayingHand.RIGHT ||
                                        playingHand == PlayingHand.BOTH)
                                    {
                                        playingHand = PlayingHand.BOTH;
                                    }
                                    else
                                    {
                                        playingHand = PlayingHand.LEFT;
                                    }
                                    PlayOverride("Left", overrideNumber, animator);
                                }

                                if (GUILayout.Button("Right"))
                                {
                                    playingType = PlayingType.OVERRIDE;
                                    if (playingHand == PlayingHand.LEFT ||
                                        playingHand == PlayingHand.BOTH)
                                    {
                                        playingHand = PlayingHand.BOTH;
                                    }
                                    else
                                    {
                                        playingHand = PlayingHand.RIGHT;
                                    }
                                    PlayOverride("Right", overrideNumber, animator);
                                }
                            }
                    }
                }
            }

            EditorGUILayout.Space();

            using (new EditorGUI.DisabledGroupScope(!EditorApplication.isPlayingOrWillChangePlaymode))
            {
                EditorGUILayout.LabelField("Emotes", EditorStyles.boldLabel);
                using (new EditorGUI.IndentLevelScope())
                {
                    for (int emoteNumber = 0; emoteNumber < EMOTES.Length; emoteNumber++)
                    {
                        AnimationClip emoteAnimation = null;
                        string        buttonText     = EMOTES[emoteNumber];
                        if (controller != null)
                        {
                            emoteAnimation = controller[EMOTES[emoteNumber]];
                            buttonText     = emoteAnimation.name;
                        }

                        // 取得できるAnimationClipの名前が"EMOTE*"だったら設定されていない
                        using (new EditorGUI.DisabledGroupScope(emoteAnimation == null || emoteAnimation.name == EMOTES[emoteNumber]))
                            using (new EditorGUILayout.HorizontalScope())
                            {
                                EditorGUILayout.LabelField(EMOTES[emoteNumber]);

                                if (GUILayout.Button(buttonText) && emoteAnimation != null)
                                {
                                    if (animator.GetInteger($"Emote") != 0)
                                    {
                                        return;
                                    }

                                    playingType = PlayingType.EMOTE;
                                    playingHand = PlayingHand.NONE;
                                    PlayEmote(emoteNumber + 1, animator, emoteAnimation);
                                }
                            }
                    }
                }
            }
#else
            EditorGUILayout.HelpBox("使用するにはVRCSDK2がプロジェクトにインポートされている必要があります", MessageType.Error);
#endif
        }
Esempio n. 10
0
        private void OnGUI()
        {
            if (!m_isValid)
            {
                if (GUILayout.Button("Create Settings File"))
                {
                    var settings = CreateInstance <UniSymbolSettings>();
                    AssetDatabase.CreateAsset(settings, "Assets/UniSymbolSettings.asset");
                    OnEnable();
                }

                return;
            }

            if (IsUpdate)
            {
                OnEnable();
            }

            var enabled = GUI.enabled;

            GUI.enabled = !EditorApplication.isCompiling && !EditorApplication.isPlaying;

            using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar))
            {
                if (GUILayout.Button("Save", EditorStyles.toolbarButton))
                {
                    var targetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
                    var defineList  = m_list.Where(c => c.IsEnable).Select(c => c.Name);
                    var defines     = string.Join(";", defineList);

                    PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, defines);
                }

                if (GUILayout.Button("Copy", EditorStyles.toolbarButton))
                {
                    var list = m_list.Where(c => c.IsEnable).Select(c => c.Name);
                    var text = string.Join(";", list);

                    EditorGUIUtility.systemCopyBuffer = text;
                }

                if (GUILayout.Button("Reset", EditorStyles.toolbarButton))
                {
                    foreach (var n in m_list)
                    {
                        n.IsEnable = n.IsDefault;
                    }
                }

                if (GUILayout.Button("Setting", EditorStyles.toolbarButton))
                {
                    var settings = GetSettings();
                    if (settings == null)
                    {
                        return;
                    }
                    EditorGUIUtility.PingObject(settings);
                    Selection.activeObject = settings;
                }

                using (var checkScope = new EditorGUI.ChangeCheckScope())
                {
                    if (m_symbolTreeView != null)
                    {
                        var searchString = m_searchField.OnToolbarGUI(m_symbolTreeView.searchString);

                        if (checkScope.changed)
                        {
                            SessionState.SetString(SEARCH_STRING_STATE_KEY, searchString);
                            m_symbolTreeView.searchString = searchString;
                        }
                    }
                }
            }

            var singleLineHeight = EditorGUIUtility.singleLineHeight;

            var rect = new Rect
            {
                x      = 0,
                y      = singleLineHeight + 1,
                width  = position.width,
                height = position.height - singleLineHeight - 1
            };

            m_symbolTreeView?.OnGUI(rect);

            GUI.enabled = enabled;
        }
Esempio n. 11
0
        private void OnGUI()
        {
            EditorGUILayout.Space();

            if (GUILayout.Button(Content.CreateDeformable, Styles.Button))
            {
                AddOrCreateDeformable <Deformable>();
            }
            if (GUILayout.Button(Content.CreateElasticDeformable, Styles.Button))
            {
                AddOrCreateDeformable <ElasticDeformable>();
            }

            using (new EditorGUILayout.HorizontalScope())
            {
                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    var rect = GUILayoutUtility.GetRect(1, 1, 18, 18, GUILayout.ExpandWidth(true));
                    rect.width -= Styles.MARGIN_X * 2;
                    rect.x     += Styles.MARGIN_X;
                    rect.y     += Styles.MARGIN_Y * 2;

                    var newSearchQuery = searchField.OnToolbarGUI(rect, searchQuery);
                    if (check.changed)
                    {
                        Undo.RecordObject(this, "Changed Search Query");
                        searchQuery = newSearchQuery;
                    }
                }
            }

            EditorGUILayout.Space();

            using (var scroll = new EditorGUILayout.ScrollViewScope(scrollPosition))
            {
                if (DeformerAttributes == null || DeformerAttributes.Count == 0)
                {
                    EditorGUILayout.LabelField("No deformers found.", GUILayout.MinWidth(0));
                }
                else
                {
                    filteredDeformerAttributes =
                        (
                            from d in DeformerAttributes
                            where string.IsNullOrEmpty(searchQuery) || d.Name.ToLower().Contains(searchQuery.ToLower())
                            select d
                        ).ToList();

                    var drawnCount = 0;
                    for (int i = 0; i < filteredDeformerAttributes.Count; i++)
                    {
                        var current = filteredDeformerAttributes[i];

                        if (drawnCount == 0)
                        {
                            var countInCategory = filteredDeformerAttributes.Count(t => t.Category == current.Category);
                            categoryFoldouts[current.Category] = EditorGUILayoutx.FoldoutHeader($"{current.Category.ToString ()} ({countInCategory})", categoryFoldouts[current.Category], EditorStyles.label);
                        }

                        if (categoryFoldouts[current.Category])
                        {
                            if (GUILayout.Button(new GUIContent(current.Name, current.Description), Styles.Button))
                            {
                                CreateDeformerFromAttribute(current, Event.current.modifiers != EventModifiers.Alt);
                            }
                        }

                        drawnCount++;

                        if (i + 1 < filteredDeformerAttributes.Count)
                        {
                            var next = filteredDeformerAttributes[i + 1];
                            if (next.Category != current.Category)
                            {
                                var countInCategory = filteredDeformerAttributes.Count(t => t.Category == next.Category);
                                categoryFoldouts[next.Category] = EditorGUILayoutx.FoldoutHeader($"{next.Category.ToString ()} ({countInCategory})", categoryFoldouts[next.Category], EditorStyles.label);
                            }
                        }
                    }

                    EditorGUILayout.Space();
                }
                scrollPosition = scroll.scrollPosition;
            }
        }
Esempio n. 12
0
            public void DrawProjection()
            {
                ProjectionType projectionType = orthographic.boolValue ? ProjectionType.Orthographic : ProjectionType.Perspective;

                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = orthographic.hasMultipleDifferentValues;
                projectionType           = (ProjectionType)EditorGUILayout.EnumPopup(Styles.projection, projectionType);
                EditorGUI.showMixedValue = false;
                if (EditorGUI.EndChangeCheck())
                {
                    orthographic.boolValue = (projectionType == ProjectionType.Orthographic);
                }

                if (!orthographic.hasMultipleDifferentValues)
                {
                    if (projectionType == ProjectionType.Orthographic)
                    {
                        EditorGUILayout.PropertyField(orthographicSize, Styles.size);
                    }
                    else
                    {
                        float fovCurrentValue;
                        bool  multipleDifferentFovValues = false;
                        bool  isPhysicalCamera           = projectionMatrixMode.intValue == (int)Camera.ProjectionMatrixMode.PhysicalPropertiesBased;

                        var rect       = EditorGUILayout.GetControlRect();
                        var guiContent = EditorGUI.BeginProperty(rect, Styles.FOVAxisMode, fovAxisMode);
                        EditorGUI.showMixedValue = fovAxisMode.hasMultipleDifferentValues;

                        EditorGUI.BeginChangeCheck();
                        var fovAxisNewVal = (int)(Camera.FieldOfViewAxis)EditorGUI.EnumPopup(rect, guiContent, (Camera.FieldOfViewAxis)fovAxisMode.intValue);
                        if (EditorGUI.EndChangeCheck())
                        {
                            fovAxisMode.intValue = fovAxisNewVal;
                        }
                        EditorGUI.EndProperty();

                        bool fovAxisVertical = fovAxisMode.intValue == 0;

                        if (!fovAxisVertical && !fovAxisMode.hasMultipleDifferentValues)
                        {
                            var   targets     = m_SerializedObject.targetObjects;
                            var   camera0     = targets[0] as Camera;
                            float aspectRatio = isPhysicalCamera ? sensorSize.vector2Value.x / sensorSize.vector2Value.y : camera0.aspect;
                            // camera.aspect is not serialized so we have to check all targets.
                            fovCurrentValue = Camera.VerticalToHorizontalFieldOfView(camera0.fieldOfView, aspectRatio);
                            if (m_SerializedObject.targetObjectsCount > 1)
                            {
                                foreach (Camera camera in targets)
                                {
                                    if (camera.fieldOfView != fovCurrentValue)
                                    {
                                        multipleDifferentFovValues = true;
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            fovCurrentValue            = verticalFOV.floatValue;
                            multipleDifferentFovValues = fovAxisMode.hasMultipleDifferentValues;
                        }

                        EditorGUI.showMixedValue = multipleDifferentFovValues;
                        var content = EditorGUI.BeginProperty(EditorGUILayout.BeginHorizontal(), Styles.fieldOfView, verticalFOV);
                        EditorGUI.BeginDisabled(projectionMatrixMode.hasMultipleDifferentValues || isPhysicalCamera && (sensorSize.hasMultipleDifferentValues || fovAxisMode.hasMultipleDifferentValues));
                        EditorGUI.BeginChangeCheck();
                        var fovNewValue = EditorGUILayout.Slider(content, fovCurrentValue, 0.00001f, 179f);
                        var fovChanged  = EditorGUI.EndChangeCheck();
                        EditorGUI.EndDisabled();
                        EditorGUILayout.EndHorizontal();
                        EditorGUI.EndProperty();
                        EditorGUI.showMixedValue = false;

                        content = EditorGUI.BeginProperty(EditorGUILayout.BeginHorizontal(), Styles.physicalCamera, projectionMatrixMode);
                        EditorGUI.showMixedValue = projectionMatrixMode.hasMultipleDifferentValues;

                        EditorGUI.BeginChangeCheck();
                        isPhysicalCamera = EditorGUILayout.Toggle(content, isPhysicalCamera);
                        if (EditorGUI.EndChangeCheck())
                        {
                            projectionMatrixMode.intValue = isPhysicalCamera ? (int)Camera.ProjectionMatrixMode.PhysicalPropertiesBased : (int)Camera.ProjectionMatrixMode.Implicit;
                        }
                        EditorGUILayout.EndHorizontal();
                        EditorGUI.EndProperty();

                        EditorGUI.showMixedValue = false;
                        if (isPhysicalCamera && !projectionMatrixMode.hasMultipleDifferentValues)
                        {
                            using (new EditorGUI.IndentLevelScope())
                            {
                                using (var horizontal = new EditorGUILayout.HorizontalScope())
                                    using (new EditorGUI.PropertyScope(horizontal.rect, Styles.focalLength, focalLength))
                                        using (var checkScope = new EditorGUI.ChangeCheckScope())
                                        {
                                            EditorGUI.showMixedValue = focalLength.hasMultipleDifferentValues;
                                            float sensorLength   = fovAxisVertical ? sensorSize.vector2Value.y : sensorSize.vector2Value.x;
                                            float focalLengthVal = fovChanged ? Camera.FieldOfViewToFocalLength(fovNewValue, sensorLength) : focalLength.floatValue;
                                            focalLengthVal = EditorGUILayout.FloatField(Styles.focalLength, focalLengthVal);
                                            if (checkScope.changed || fovChanged)
                                            {
                                                focalLength.floatValue = focalLengthVal;
                                            }
                                        }

                                EditorGUI.showMixedValue = sensorSize.hasMultipleDifferentValues;
                                EditorGUI.BeginChangeCheck();
                                int filmGateIndex = Array.IndexOf(k_ApertureFormatValues, new Vector2((float)Math.Round(sensorSize.vector2Value.x, 3), (float)Math.Round(sensorSize.vector2Value.y, 3)));
                                if (filmGateIndex == -1)
                                {
                                    filmGateIndex = EditorGUILayout.Popup(Styles.cameraType, k_ApertureFormatNames.Length - 1, k_ApertureFormatNames);
                                }
                                else
                                {
                                    filmGateIndex = EditorGUILayout.Popup(Styles.cameraType, filmGateIndex, k_ApertureFormatNames);
                                }
                                EditorGUI.showMixedValue = false;
                                if (EditorGUI.EndChangeCheck() && filmGateIndex < k_ApertureFormatValues.Length)
                                {
                                    sensorSize.vector2Value = k_ApertureFormatValues[filmGateIndex];
                                }

                                EditorGUILayout.PropertyField(sensorSize, Styles.sensorSize);

                                EditorGUILayout.PropertyField(lensShift, Styles.lensShift);

                                using (var horizontal = new EditorGUILayout.HorizontalScope())
                                    using (var propertyScope = new EditorGUI.PropertyScope(horizontal.rect, Styles.gateFit, gateFit))
                                        using (var checkScope = new EditorGUI.ChangeCheckScope())
                                        {
                                            int gateValue = (int)(Camera.GateFitMode)EditorGUILayout.EnumPopup(propertyScope.content, (Camera.GateFitMode)gateFit.intValue);
                                            if (checkScope.changed)
                                            {
                                                gateFit.intValue = gateValue;
                                            }
                                        }
                            }
                        }
                        else if (fovChanged)
                        {
                            verticalFOV.floatValue = fovAxisVertical ? fovNewValue : Camera.HorizontalToVerticalFieldOfView(fovNewValue, (m_SerializedObject.targetObjects[0] as Camera).aspect);
                        }
                        EditorGUILayout.Space();
                    }
                }
            }
Esempio n. 13
0
    private void DrawEventData(EventData data)
    {
        EditorGUILayout.BeginVertical(EditorStyles.helpBox);

        using (new EditorGUILayout.HorizontalScope())
        {
            EditorGUILayout.LabelField("Display Name: ", GUILayout.MaxWidth(100));
            _selectedName = EditorGUILayout.TextField(_selectedName);
            if (GUILayout.Button("Rename", EditorStyles.toolbarButton, GUILayout.Width(60)))
            {
                data.Name = _selectedName;
            }
        }

        using (new EditorGUILayout.HorizontalScope())
        {
            using (var check = new EditorGUI.ChangeCheckScope())
            {
                EditorGUILayout.LabelField("Target Controller: ", GUILayout.MaxWidth(100));
                data.TargetController = EditorGUILayout.ObjectField(data.TargetController,
                                                                    typeof(AnimatorController), false) as AnimatorController;

                if (check.changed)
                {
                }
            }
        }

        if (data.TargetController != null)
        {
            // Draw Layers
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.LabelField("1. Select Layer", EditorStyles.centeredGreyMiniLabel);

            var animatorController = (AnimatorController)data.TargetController;
            for (var i = 0; i < animatorController.layers.Length; i++)
            {
                var layer = animatorController.layers[i];

                if (i == _selectedLayer)
                {
                    GUI.backgroundColor = Color.green;
                }

                if (GUILayout.Button(i + " - " + layer.name))
                {
                    _selectedLayer = i;
                }

                GUI.backgroundColor = Color.white;
            }

            EditorGUILayout.EndVertical();

            // Draw States
            if (_selectedLayer != -1)
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                EditorGUILayout.LabelField("2. Select State", EditorStyles.centeredGreyMiniLabel);

                var stateMachine = animatorController.layers[_selectedLayer].stateMachine;
                for (var i = 0; i < stateMachine.states.Length; i++)
                {
                    var state = stateMachine.states[i];

                    if (state.state.nameHash == _selectedState)
                    {
                        GUI.backgroundColor = Color.green;
                    }

                    if (GUILayout.Button(state.state.name))
                    {
                        SetupPreview(state.state.motion);
                        previewedMotion = state.state.motion;
                        _selectedState  = state.state.nameHash;
//                        Debug.Log(_selectedState);
                        _selectedEventArg = null;
                    }

                    GUI.backgroundColor = Color.white;
                }

                EditorGUILayout.EndVertical();
            }

            // Draw Events
            if (_selectedState != -1)
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                var index = new StateIndex(_selectedLayer, _selectedState);
                if (!data.Configs.ContainsKey(index))
                {
                    data.Configs.Add(index, new AnimatorEvents());
                }

                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.LabelField("Normalized", GUILayout.Width(100));

                    using (var check = new EditorGUI.ChangeCheckScope())
                    {
                        _normalizedSetting = EditorGUILayout.Slider(_normalizedSetting, 0, 1);
                        if (check.changed)
                        {
                            if (_avatarPreview != null)
                            {
                                _avatarPreview.Animator.Play(0, 0, _normalizedSetting);
                                _avatarPreview.timeControl.normalizedTime = _normalizedSetting;
                            }

                            if (_selectedEventArg != null)
                            {
                                _selectedEventArg.NormalizedTime = _normalizedSetting;
                                data.Configs[index] =
                                    new AnimatorEvents(data.Configs[index].Value.OrderBy(x => x.NormalizedTime));
                            }
                        }
                    }

                    if (GUILayout.Button("Add Event", EditorStyles.toolbarButton))
                    {
                        var countNum = data.Configs[index].Value.Count;

                        var newEventArg = new AnimatorEventArgs
                        {
                            Name           = "New Event " + countNum,
                            NormalizedTime = _normalizedSetting
                        };

                        data.Configs[index].Value.Add(newEventArg);
                        data.Configs[index] = new AnimatorEvents(data.Configs[index].Value.OrderBy(x => x.NormalizedTime));

                        _selectedEventArg = newEventArg;
                        EditorUtility.SetDirty(_dataSet);
                    }
                }

                EditorGUILayout.LabelField("3. Edit Events", EditorStyles.centeredGreyMiniLabel);

                for (var i = 0; i < data.Configs[index].Value.Count; i++)
                {
                    var evt            = data.Configs[index].Value[i];
                    var normalizedTime = evt.NormalizedTime.ToString("F3");

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        if (_selectedEventArg == evt)
                        {
                            GUI.backgroundColor = Color.green;
                        }

                        if (GUILayout.Button(normalizedTime + " - " + evt.Name))
                        {
                            if (_selectedEventArg == evt)
                            {
                                _selectedEventArg = null;
                                continue;
                            }

                            _selectedEventArg  = evt;
                            _selectedEventName = evt.Name;
                            _normalizedSetting = evt.NormalizedTime;

                            if (_avatarPreview != null)
                            {
                                _avatarPreview.Animator.Play(0, 0, evt.NormalizedTime);
                                _avatarPreview.timeControl.normalizedTime = evt.NormalizedTime;
                            }
                        }

                        GUI.backgroundColor = Color.white;

                        if (GUILayout.Button("DEL", GUILayout.Width(45)))
                        {
                            _delayedActions.Add(() => data.Configs[index].Value.Remove(evt));
                            if (_selectedEventArg == evt)
                            {
                                _selectedEventArg = null;
                            }
                        }
                    }
                }

                if (_selectedEventArg != null)
                {
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        EditorGUILayout.LabelField("Display Name: ", GUILayout.MaxWidth(100));
                        _selectedEventName = EditorGUILayout.TextField(_selectedEventName);
                        if (GUILayout.Button("Rename", EditorStyles.toolbarButton, GUILayout.Width(60)))
                        {
                            _selectedEventArg.Name = _selectedEventName;
                        }
                    }

                    _selectedEventArg.Type =
                        (AnimatorEventType)EditorGUILayout.EnumPopup("Event Type", _selectedEventArg.Type);

                    switch (_selectedEventArg.Type)
                    {
                    case AnimatorEventType.Pure:
                        break;

                    case AnimatorEventType.Float:
                        _selectedEventArg.FloatParm =
                            EditorGUILayout.FloatField("Float Parameter", _selectedEventArg.FloatParm);
                        break;

                    case AnimatorEventType.Int:
                        _selectedEventArg.IntParm =
                            EditorGUILayout.IntField("Int Parameter", _selectedEventArg.IntParm);
                        break;

                    case AnimatorEventType.String:
                        _selectedEventArg.StringParm =
                            EditorGUILayout.TextField("String Parameter", _selectedEventArg.StringParm);
                        break;

                    case AnimatorEventType.Object:
                        _selectedEventArg.ObjectParm = EditorGUILayout.ObjectField("Object Parameter",
                                                                                   _selectedEventArg.ObjectParm, typeof(Object), false);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    EditorGUILayout.EndVertical();
                }

                EditorGUILayout.EndVertical();
            }
        }

        EditorGUILayout.EndVertical();
    }
Esempio n. 14
0
        public virtual void OnGUI()
        {
            GUILayout.Space(15);
            using (var check = new EditorGUI.ChangeCheckScope())
            {
                m_EditorState.useAdvanced = !GUILayout.Toggle(
                    !m_EditorState.useAdvanced, "  Use default parameters", EditorStyles.radioButton);
                EditorGUILayout.LabelField(basicInfo, EditorStyles.wordWrappedLabel);

                m_EditorState.useAdvanced = GUILayout.Toggle(
                    m_EditorState.useAdvanced, "  Use custom parameters", EditorStyles.radioButton);

                if (m_EditorState.useAdvanced)
                {
                    if (m_FieldList == null)
                    {
                        RebuildList();
                    }
                    m_FieldList.displayRemove = m_EditorState.fields.Count > 1;

                    m_FieldList.DoLayoutList();

                    GUILayout.Space(15);
                    if (!string.IsNullOrEmpty(m_ErrorMessage))
                    {
                        EditorGUILayout.HelpBox(m_ErrorMessage, MessageType.Error);
                        GUILayout.Space(5);
                    }
                }

                if (check.changed)
                {
                    CheckValidationErrors();
                    CacheState();
                }
            }

            if (hasChanges)
            {
                EditorGUILayout.HelpBox(
                    "You have unsaved changes.\n" +
                    "Note that saving changes will cause project to recompile.", MessageType.Info);
            }

            GUILayout.Space(5);
            using (new EditorGUI.DisabledGroupScope(!hasChanges))
                using (new EditorGUILayout.HorizontalScope())
                {
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Revert", Styles.button, GUILayout.ExpandWidth(false)))
                    {
                        RevertState();
                    }
                    using (new EditorGUI.DisabledGroupScope(!string.IsNullOrEmpty(m_ErrorMessage)))
                    {
                        if (GUILayout.Button("Apply", Styles.button, GUILayout.ExpandWidth(false)))
                        {
                            SaveState();
                        }
                    }
                }
        }
Esempio n. 15
0
        protected override void DrawVolumeGUI()
        {
            SDFBaker baker = target as SDFBaker;

            if (baker == null)
            {
                return;
            }

            EditorGUI.BeginChangeCheck();

            //disable these when previewing to enforce idea that they are for baking
            EditorGUI.BeginDisabledGroup(baker.IsPreviewing);
            DrawBaseGUI();
            //ray samples
            EditorGUILayout.PropertyField(raySamplesProperty);
            //fit to vertices of mesh, if false the bounds will be used, bounds may be larger than mesh and waste space
            EditorGUILayout.PropertyField(fitToVerticesProperty);
            //jitter seed
            //EditorGUILayout.PropertyField(jitterSeedProperty);
            //jitter scale (0.75 to 1.0 seems good)
            //EditorGUILayout.PropertyField(jitterScaleProperty);
            EditorGUI.EndDisabledGroup();

            //disable these when not previewing
            EditorGUI.BeginDisabledGroup(!baker.IsPreviewing);
            EditorGUILayout.Slider(epsilonProperty, 0.0001f, 0.005f);
            EditorGUILayout.Slider(normalDeltaProperty, 0.0001f, 0.02f);

            using (var check = new EditorGUI.ChangeCheckScope())
            {
                EditorGUILayout.PropertyField(previewModeProperty);
                if (check.changed)
                {
                    SetKeywords((Visualisation)previewModeProperty.enumValueIndex);
                }
            }

            //inverse sign of SDF preview
            EditorGUILayout.PropertyField(sdfFlipProperty);

            EditorGUI.EndDisabledGroup();

            //disable these when previewing
            EditorGUI.BeginDisabledGroup(baker.IsPreviewing);
            EditorGUILayout.PropertyField(useRayDirVertShaderProperty);
            EditorGUI.EndDisabledGroup();

            //TODO if SDF Data assigned via drag & drop, adjust the bounds and settings to match SDF data
            EditorGUILayout.PropertyField(sdfDataProperty);

            BakeControls();
            if (GUILayout.Button("BakeHalfSize"))
            {
                baker.BakeHalfSizeTest();
            }
            if (GUILayout.Button("Log Volume Data"))
            {
                baker.LogDistances();
            }
        }
Esempio n. 16
0
    private void Do2DBlend(Rect r, SerializedProperty sP, Blend2DAttribute nP)
    {
        using (new GUI.GroupScope(r))
        {
            Rect blendRect = new Rect(Vector2.zero, Vector2.one * blendBoxSize);

            Event e = Event.current;
            if (e.isMouse && e.button == 0 && (e.rawType == EventType.MouseDown || e.rawType == EventType.MouseDrag))
            {
                if (blendRect.Contains(e.mousePosition))
                {
                    sP.vector2Value = new Vector2(Mathf.Clamp(e.mousePosition.x, 0, blendBoxSize),
                                                  Mathf.Clamp(blendBoxSize - e.mousePosition.y, 0, blendBoxSize)) / blendBoxSize;
                    e.Use();
                }
            }
            Vector2 v = sP.vector2Value;
            using (EditorGUI.ChangeCheckScope cC = new EditorGUI.ChangeCheckScope())
            {
                Rect labelRect = new Rect(blendBoxSize + 5, blendBoxSize / 2f - 50, Screen.width - blendBoxSize - 5, 15);
                EditorGUI.LabelField(labelRect, sP.displayName, EditorStyles.boldLabel);
                labelRect.y += 20;
                EditorGUI.LabelField(labelRect, nP.xLabel);
                labelRect.y += 15;
                v.x          = EditorGUI.FloatField(labelRect, v.x);
                labelRect.y += 15;
                EditorGUI.LabelField(labelRect, nP.yLabel);
                labelRect.y += 15;
                v.y          = EditorGUI.FloatField(labelRect, v.y);
                if (cC.changed)
                {
                    sP.vector2Value = new Vector2(Mathf.Clamp01(v.x), Mathf.Clamp01(v.y));
                }
            }

            using (new GUI.GroupScope(blendRect))
            {
                GL.Begin(Application.platform == RuntimePlatform.WindowsEditor ? GL.QUADS : GL.LINES);
                ApplyWireMaterial.Invoke(null, new object[] { CompareFunction.Always });
                const float quarter       = 0.25f * blendBoxSize;
                const float half          = quarter * 2;
                const float threeQuarters = half + quarter;
                float       lowGreyVal    = EditorGUIUtility.isProSkin ? 0.25f : 0.75f;
                Color       lowGrey       = new Color(lowGreyVal, lowGreyVal, lowGreyVal);
                DrawLineFast(new Vector2(quarter, 0), new Vector2(quarter, blendBoxSize), lowGrey);
                DrawLineFast(new Vector2(quarter, 0), new Vector2(quarter, blendBoxSize), lowGrey);
                DrawLineFast(new Vector2(threeQuarters, 0), new Vector2(threeQuarters, blendBoxSize), lowGrey);
                DrawLineFast(new Vector2(0, quarter), new Vector2(blendBoxSize, quarter), lowGrey);
                DrawLineFast(new Vector2(0, threeQuarters), new Vector2(blendBoxSize, threeQuarters), lowGrey);
                DrawLineFast(new Vector2(half, 0), new Vector2(half, blendBoxSize), Color.grey);
                DrawLineFast(new Vector2(0, half), new Vector2(blendBoxSize, half), Color.grey);
                GL.End();

                GL.Begin(Application.platform == RuntimePlatform.WindowsEditor ? GL.QUADS : GL.LINES);
                ApplyWireMaterial.Invoke(null, new object[] { CompareFunction.Always });
                Vector2 circlePos = sP.vector2Value;
                circlePos.y = 1 - circlePos.y;
                circlePos  *= blendBoxSize;
                DrawCircleFast(circlePos, blendBoxSize * 0.04f, 2, new Color(1, 0.5f, 0));
                GL.End();
            }
        }
    }
        public void DrawProperties()
        {
            bool enableDashControls = propDashed.boolValue == false;

            EditorGUILayout.PropertyField(propDashed);

            using (new EditorGUI.DisabledScope(enableDashControls)) {
                using (var chChk = new EditorGUI.ChangeCheckScope()) {
                    EditorGUILayout.PropertyField(propSpace, new GUIContent("Length Space"));
                    if (chChk.changed && propSpace.enumValueIndex == DashSpace.FixedCount.GetIndex())
                    {
                        // todo: might want to do per-instance fixup of this, it's a lil wonky
                        // but you know what, the world is wonky
                        // converts from dash+space to count + space ratio
                        float period = propSpacing.floatValue + propSize.floatValue;
                        propSpacing.floatValue = propSpacing.floatValue / period;
                    }
                }

                EditorGUILayout.PropertyField(propSnap);
            }

            bool displayInCountRatioMode = propSpace.hasMultipleDifferentValues == false && propSpace.enumValueIndex == DashSpace.FixedCount.GetIndex();

            using (new EditorGUI.DisabledScope(enableDashControls)) {
                using (ShapesUI.Horizontal) {
                    // size field
                    using (var chchk = new EditorGUI.ChangeCheckScope()) {
                        string sizeLabel = displayInCountRatioMode ? "Count" : "Size";
                        EditorGUILayout.PropertyField(propSize, new GUIContent(sizeLabel));
                        //ShapesUI.PropertyFieldWidth( propSize, sizeLabel, 32 );
                        if (chchk.changed)
                        {
                            propSize.floatValue = Mathf.Max(0.0001f, propSize.floatValue);
                        }
                    }

                    // link button
                    bool mixedLinkStates = dashSizeLinked.hasMultipleDifferentValues;
                    using (var chchk = new EditorGUI.ChangeCheckScope()) {
                        bool newVal = GUILayout.Toggle(mixedLinkStates ? false : dashSizeLinked.boolValue, mixedLinkStates ? "—" : "=", EditorStyles.miniButton, GUILayout.Width(22));
                        if (chchk.changed)
                        {
                            dashSizeLinked.boolValue = newVal;
                        }
                    }
                }


                using (ShapesUI.Horizontal) {
                    DrawSpacingGUI(displayInCountRatioMode);
                }

                using (ShapesUI.Horizontal) {
                    EditorGUILayout.PropertyField(propOffset);
                    GUILayout.FlexibleSpace();
                }

                DrawStyleGUI();
            }
        }
        protected override void OnEnable()
        {
            base.OnEnable();

            if (target == null)
            {
                // Either when we are recompiling, or the inspector window is hidden behind another one, the target can get destroyed (null) and thereby will raise an ArgumentException when accessing serializedObject. For now, just return.
                return;
            }

            MixedRealityToolkitConfigurationProfile mrtkConfigProfile = target as MixedRealityToolkitConfigurationProfile;

            // Experience configuration
            targetExperienceScale = serializedObject.FindProperty("targetExperienceScale");
            // Camera configuration
            enableCameraSystem = serializedObject.FindProperty("enableCameraSystem");
            cameraSystemType   = serializedObject.FindProperty("cameraSystemType");
            cameraProfile      = serializedObject.FindProperty("cameraProfile");
            // Input system configuration
            enableInputSystem  = serializedObject.FindProperty("enableInputSystem");
            inputSystemType    = serializedObject.FindProperty("inputSystemType");
            inputSystemProfile = serializedObject.FindProperty("inputSystemProfile");
            // Boundary system configuration
            enableBoundarySystem         = serializedObject.FindProperty("enableBoundarySystem");
            boundarySystemType           = serializedObject.FindProperty("boundarySystemType");
            boundaryVisualizationProfile = serializedObject.FindProperty("boundaryVisualizationProfile");
            // Teleport system configuration
            enableTeleportSystem = serializedObject.FindProperty("enableTeleportSystem");
            teleportSystemType   = serializedObject.FindProperty("teleportSystemType");
            // Spatial Awareness system configuration
            enableSpatialAwarenessSystem  = serializedObject.FindProperty("enableSpatialAwarenessSystem");
            spatialAwarenessSystemType    = serializedObject.FindProperty("spatialAwarenessSystemType");
            spatialAwarenessSystemProfile = serializedObject.FindProperty("spatialAwarenessSystemProfile");
            // Diagnostics system configuration
            enableDiagnosticsSystem  = serializedObject.FindProperty("enableDiagnosticsSystem");
            enableVerboseLogging     = serializedObject.FindProperty("enableVerboseLogging");
            diagnosticsSystemType    = serializedObject.FindProperty("diagnosticsSystemType");
            diagnosticsSystemProfile = serializedObject.FindProperty("diagnosticsSystemProfile");
            // Scene system configuration
            enableSceneSystem  = serializedObject.FindProperty("enableSceneSystem");
            sceneSystemType    = serializedObject.FindProperty("sceneSystemType");
            sceneSystemProfile = serializedObject.FindProperty("sceneSystemProfile");

            // Additional registered components configuration
            registeredServiceProvidersProfile = serializedObject.FindProperty("registeredServiceProvidersProfile");

            // Editor settings
            useServiceInspectors = serializedObject.FindProperty("useServiceInspectors");
            renderDepthBuffer    = serializedObject.FindProperty("renderDepthBuffer");

            SelectedProfileTab = SessionState.GetInt(SelectedTabPreferenceKey, SelectedProfileTab);

            if (RenderProfileFuncs == null)
            {
                RenderProfileFuncs = new Func <bool>[]
                {
                    () => {
                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(enableCameraSystem);

                            const string service = "Camera System";
                            if (enableCameraSystem.boolValue)
                            {
                                CheckSystemConfiguration(service, mrtkConfigProfile.CameraSystemType, mrtkConfigProfile.CameraProfile != null);

                                EditorGUILayout.PropertyField(cameraSystemType);

                                changed |= RenderProfile(cameraProfile, typeof(MixedRealityCameraProfile), true, false);
                            }
                            else
                            {
                                RenderSystemDisabled(service);
                            }

                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(enableInputSystem);

                            const string service = "Input System";
                            if (enableInputSystem.boolValue)
                            {
                                CheckSystemConfiguration(service, mrtkConfigProfile.InputSystemType, mrtkConfigProfile.InputSystemProfile != null);

                                EditorGUILayout.PropertyField(inputSystemType);

                                // Make sure Unity axis mappings are set.
                                InputMappingAxisUtility.CheckUnityInputManagerMappings(ControllerMappingLibrary.UnityInputManagerAxes);

                                changed |= RenderProfile(inputSystemProfile, null, true, false, typeof(IMixedRealityInputSystem));
                            }
                            else
                            {
                                RenderSystemDisabled(service);

                                InputMappingAxisUtility.RemoveMappings(ControllerMappingLibrary.UnityInputManagerAxes);
                            }

                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        var experienceScale = (ExperienceScale)targetExperienceScale.intValue;
                        if (experienceScale != ExperienceScale.Room)
                        {
                            // Alert the user if the experience scale does not support boundary features.
                            GUILayout.Space(6f);
                            EditorGUILayout.HelpBox("Boundaries are only supported in Room scale experiences.", MessageType.Warning);
                            GUILayout.Space(6f);
                        }

                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(enableBoundarySystem);

                            const string service = "Boundary System";
                            if (enableBoundarySystem.boolValue)
                            {
                                CheckSystemConfiguration(service, mrtkConfigProfile.BoundarySystemSystemType, mrtkConfigProfile.BoundaryVisualizationProfile != null);

                                EditorGUILayout.PropertyField(boundarySystemType);

                                changed |= RenderProfile(boundaryVisualizationProfile, null, true, false, typeof(IMixedRealityBoundarySystem));
                            }
                            else
                            {
                                RenderSystemDisabled(service);
                            }

                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        const string service = "Teleport System";
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(enableTeleportSystem);
                            if (enableTeleportSystem.boolValue)
                            {
                                // Teleport System does not have a profile scriptableobject so auto to true
                                CheckSystemConfiguration(service, mrtkConfigProfile.TeleportSystemSystemType, true);

                                EditorGUILayout.PropertyField(teleportSystemType);
                            }
                            else
                            {
                                RenderSystemDisabled(service);
                            }

                            return(c.changed);
                        }
                    },
                    () => {
                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            const string service = "Spatial Awareness System";
                            EditorGUILayout.PropertyField(enableSpatialAwarenessSystem);

                            if (enableSpatialAwarenessSystem.boolValue)
                            {
                                CheckSystemConfiguration(service, mrtkConfigProfile.SpatialAwarenessSystemSystemType, mrtkConfigProfile.SpatialAwarenessSystemProfile != null);

                                EditorGUILayout.PropertyField(spatialAwarenessSystemType);

                                EditorGUILayout.HelpBox("Spatial Awareness settings are configured per observer.", MessageType.Info);

                                changed |= RenderProfile(spatialAwarenessSystemProfile, null, true, false, typeof(IMixedRealitySpatialAwarenessSystem));
                            }
                            else
                            {
                                RenderSystemDisabled(service);
                            }

                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        EditorGUILayout.HelpBox("It is recommended to enable the Diagnostics system during development. Be sure to disable prior to building your shipping product.", MessageType.Warning);

                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(enableVerboseLogging);
                            EditorGUILayout.PropertyField(enableDiagnosticsSystem);

                            const string service = "Diagnostics System";
                            if (enableDiagnosticsSystem.boolValue)
                            {
                                CheckSystemConfiguration(service, mrtkConfigProfile.DiagnosticsSystemSystemType, mrtkConfigProfile.DiagnosticsSystemProfile != null);

                                EditorGUILayout.PropertyField(diagnosticsSystemType);

                                changed |= RenderProfile(diagnosticsSystemProfile, typeof(MixedRealityDiagnosticsProfile));
                            }
                            else
                            {
                                RenderSystemDisabled(service);
                            }

                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        bool changed = false;
                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(enableSceneSystem);
                            const string service = "Scene System";
                            if (enableSceneSystem.boolValue)
                            {
                                CheckSystemConfiguration(service, mrtkConfigProfile.SceneSystemSystemType, mrtkConfigProfile.SceneSystemProfile != null);

                                EditorGUILayout.PropertyField(sceneSystemType);

                                changed |= RenderProfile(sceneSystemProfile, typeof(MixedRealitySceneSystemProfile), true, true, typeof(IMixedRealitySceneSystem));
                            }

                            changed |= c.changed;
                        }
                        return(changed);
                    },
                    () => {
                        return(RenderProfile(registeredServiceProvidersProfile, typeof(MixedRealityRegisteredServiceProvidersProfile), true, false));
                    },
                    () => {
                        EditorGUILayout.PropertyField(useServiceInspectors);

                        using (var c = new EditorGUI.ChangeCheckScope())
                        {
                            EditorGUILayout.PropertyField(renderDepthBuffer);
                            if (c.changed)
                            {
                                if (renderDepthBuffer.boolValue)
                                {
                                    CameraCache.Main.gameObject.AddComponent <DepthBufferRenderer>();
                                }
                                else
                                {
                                    foreach (var dbr in FindObjectsOfType <DepthBufferRenderer>())
                                    {
                                        UnityObjectExtensions.DestroyObject(dbr);
                                    }
                                }
                            }
                        }
                        return(false);
                    },
                };
            }
        }
        public override void OnInspectorGUI()
        {
            AddProperty(m_Source, () =>
            {
                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    if (m_MaskedSourceNames == null)
                    {
                        m_MaskedSourceNames = EnumHelper.MaskOutEnumNames <EImageSource>((int)m_SupportedSources);
                    }
                    var index = EnumHelper.GetMaskedIndexFromEnumValue <EImageSource>(m_Source.intValue, (int)m_SupportedSources);
                    index     = EditorGUILayout.Popup("Object(s) of interest", index, m_MaskedSourceNames);

                    if (check.changed)
                    {
                        m_Source.intValue = EnumHelper.GetEnumValueFromMaskedIndex <EImageSource>(index, (int)m_SupportedSources);
                    }
                }
            });

            var inputType = (EImageSource)m_Source.intValue;

            if ((EImageSource)m_Source.intValue == EImageSource.TaggedCamera)
            {
                ++EditorGUI.indentLevel;
                AddProperty(m_CameraTag, () => EditorGUILayout.PropertyField(m_CameraTag, new GUIContent("Tag")));
                --EditorGUI.indentLevel;
            }

            AddProperty(m_AspectRatio, () => EditorGUILayout.PropertyField(m_AspectRatio, new GUIContent("Aspect Ratio")));
            AddProperty(m_SuperSampling, () => EditorGUILayout.PropertyField(m_SuperSampling, new GUIContent("Super sampling")));

            var renderSize = m_RenderSize;

            AddProperty(m_RenderSize, () =>
            {
                if (inputType != EImageSource.RenderTexture)
                {
                    EditorGUILayout.PropertyField(m_RenderSize, new GUIContent("Rendering resolution"));
                    if (m_FinalSize.intValue > renderSize.intValue)
                    {
                        m_FinalSize.intValue = renderSize.intValue;
                    }
                }
            });

            AddProperty(m_FinalSize, () =>
            {
                m_ResSelector.OnInspectorGUI((target as ImageInputSettings).maxSupportedSize, m_FinalSize);
                if (m_FinalSize.intValue > renderSize.intValue)
                {
                    renderSize.intValue = m_FinalSize.intValue;
                }
            });

            if (Verbose.enabled)
            {
                using (new EditorGUI.DisabledScope(true))
                {
                    EditorGUILayout.TextField("Color Space", (target as RenderTextureSamplerSettings).m_ColorSpace.ToString());
                    EditorGUILayout.PropertyField(m_FlipFinalOutput, new GUIContent("Flip output"));
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 20
0
        public override void OnInspectorGUI()
        {
            AddProperty(m_Source, () =>
            {
                using (var check = new EditorGUI.ChangeCheckScope())
                {
                    if (m_MaskedSourceNames == null)
                    {
                        m_MaskedSourceNames = EnumHelper.MaskOutEnumNames <EImageSource>((int)m_SupportedSources);
                    }
                    var index = EnumHelper.GetMaskedIndexFromEnumValue <EImageSource>(m_Source.intValue, (int)m_SupportedSources);
                    index     = EditorGUILayout.Popup("Source", index, m_MaskedSourceNames);

                    if (check.changed)
                    {
                        m_Source.intValue = EnumHelper.GetEnumValueFromMaskedIndex <EImageSource>(index, (int)m_SupportedSources);
                    }
                }
            });

            var inputType = (EImageSource)m_Source.intValue;

            if ((EImageSource)m_Source.intValue == EImageSource.TaggedCamera)
            {
                ++EditorGUI.indentLevel;
                AddProperty(m_CameraTag, () => EditorGUILayout.PropertyField(m_CameraTag, new GUIContent("Tag")));
                --EditorGUI.indentLevel;
            }

            AddProperty(m_OutputWidth, () =>
            {
                AddProperty(m_OutputWidth, () => EditorGUILayout.PropertyField(m_OutputWidth, new GUIContent("Output width")));
            });

            AddProperty(m_OutputHeight, () =>
            {
                AddProperty(m_OutputWidth, () => EditorGUILayout.PropertyField(m_OutputHeight, new GUIContent("Output height")));
            });

            AddProperty(m_CubeMapSz, () =>
            {
                AddProperty(m_CubeMapSz, () => EditorGUILayout.PropertyField(m_CubeMapSz, new GUIContent("Cube map width")));
            });

            AddProperty(m_RenderStereo, () =>
            {
                AddProperty(m_RenderStereo, () => EditorGUILayout.PropertyField(m_RenderStereo, new GUIContent("Render in Stereo")));
            });

            AddProperty(m_StereoSeparation, () =>
            {
                ++EditorGUI.indentLevel;
                using (new EditorGUI.DisabledScope(!m_RenderStereo.boolValue))
                {
                    AddProperty(m_StereoSeparation, () => EditorGUILayout.PropertyField(m_StereoSeparation, new GUIContent("Stereo Separation")));
                }
                --EditorGUI.indentLevel;
            });

            if (Verbose.enabled)
            {
                using (new EditorGUI.DisabledScope(true))
                {
                    EditorGUILayout.PropertyField(m_FlipFinalOutput, new GUIContent("Flip output"));
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 21
0
        protected void ShaderSSSAndTransmissionInputGUI(Material material)
        {
            var hdPipeline = RenderPipelineManager.currentPipeline as HDRenderPipeline;

            if (hdPipeline == null)
            {
                return;
            }

            var diffusionProfileSettings = hdPipeline.diffusionProfileSettings;

            if (hdPipeline.IsInternalDiffusionProfile(diffusionProfileSettings))
            {
                EditorGUILayout.HelpBox("No diffusion profile Settings have been assigned to the render pipeline asset.", MessageType.Warning);
                return;
            }


            // Enable transmission toggle
            m_MaterialEditor.ShaderProperty(enableTransmission, Styles.transmissionToggleText);

            // Subsurface toggle and options
            m_MaterialEditor.ShaderProperty(enableSubsurfaceScattering, Styles.subsurfaceToggleText);
            if (enableSubsurfaceScattering.floatValue == 1.0f)
            {
                m_MaterialEditor.ShaderProperty(subsurfaceMask, Styles.subsurfaceMaskText);
                m_MaterialEditor.TexturePropertySingleLine(Styles.subsurfaceMaskMapText, subsurfaceMaskMap);
            }

            // The thickness sub-menu is toggled if either the transmission or subsurface are requested
            if (enableSubsurfaceScattering.floatValue == 1.0f || enableTransmission.floatValue == 1.0f)
            {
                m_MaterialEditor.TexturePropertySingleLine(Styles.thicknessMapText, thicknessMap);
                if (thicknessMap.textureValue != null)
                {
                    // Display the remap of texture values.
                    Vector2 remap = thicknessRemap.vectorValue;
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.MinMaxSlider(Styles.thicknessRemapText, ref remap.x, ref remap.y, 0.0f, 1.0f);
                    if (EditorGUI.EndChangeCheck())
                    {
                        thicknessRemap.vectorValue = remap;
                    }
                }
                else
                {
                    // Allow the user to set the constant value of thickness if no thickness map is provided.
                    m_MaterialEditor.ShaderProperty(thickness, Styles.thicknessText);
                }
            }

            // We only need to display the diffusion profile if we have either transmission or diffusion
            // TODO: Optimize me
            if (enableSubsurfaceScattering.floatValue == 1.0f || enableTransmission.floatValue == 1.0f)
            {
                var profiles = diffusionProfileSettings.profiles;
                var names    = new GUIContent[profiles.Length + 1];
                names[0] = new GUIContent("None");

                var values = new int[names.Length];
                values[0] = DiffusionProfileConstants.DIFFUSION_PROFILE_NEUTRAL_ID;

                for (int i = 0; i < profiles.Length; i++)
                {
                    names[i + 1]  = new GUIContent(profiles[i].name);
                    values[i + 1] = i + 1;
                }

                using (var scope = new EditorGUI.ChangeCheckScope())
                {
                    int profileID = (int)diffusionProfileID.floatValue;

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        EditorGUILayout.PrefixLabel(Styles.diffusionProfileText);

                        using (new EditorGUILayout.HorizontalScope())
                        {
                            profileID = EditorGUILayout.IntPopup(profileID, names, values);

                            if (GUILayout.Button("Goto", EditorStyles.miniButton, GUILayout.Width(50f)))
                            {
                                Selection.activeObject = diffusionProfileSettings;
                            }
                        }
                    }

                    if (scope.changed)
                    {
                        diffusionProfileID.floatValue = profileID;
                    }
                }
            }
        }
Esempio n. 22
0
        protected virtual void LayoutTagsField()
        {
            using (new EditorGUI.DisabledScope(this.gameProfile == null))
            {
                EditorGUILayout.BeginHorizontal();
                this.isTagsExpanded = EditorGUILayout.Foldout(this.isTagsExpanded, "Tags", true);
                GUILayout.FlexibleSpace();
                bool isUndoRequested = EditorGUILayoutExtensions.UndoButton(isUndoEnabled);
                EditorGUILayout.EndHorizontal();

                if (this.isTagsExpanded)
                {
                    if (this.gameProfile == null)
                    {
                        EditorGUILayout.HelpBox("The Game's Profile is not yet loaded, and thus tags cannot be displayed. Please wait...", MessageType.Warning);
                    }
                    else if (this.gameProfile.tagCategories.Length == 0)
                    {
                        EditorGUILayout.HelpBox("The developers of "
                                                + this.gameProfile.name
                                                + " have not designated any tagging options",
                                                MessageType.Info);
                    }
                    else
                    {
                        var  tagsProperty    = editableProfileProperty.FindPropertyRelative("tags.value");
                        var  oldSelectedTags = new List <string>(EditorUtilityExtensions.GetSerializedPropertyStringArray(tagsProperty));
                        var  newSelectedTags = new List <string>();
                        bool isDirty         = false;

                        ++EditorGUI.indentLevel;
                        foreach (ModTagCategory tagCategory in this.gameProfile.tagCategories)
                        {
                            if (!tagCategory.isHidden)
                            {
                                using (var check = new EditorGUI.ChangeCheckScope())
                                {
                                    var categoryTags = LayoutTagCategoryField(tagCategory, oldSelectedTags);
                                    newSelectedTags.AddRange(categoryTags);

                                    isDirty |= check.changed;
                                }
                            }
                        }
                        --EditorGUI.indentLevel;

                        if (isDirty || newSelectedTags.Count < oldSelectedTags.Count)
                        {
                            EditorUtilityExtensions.SetSerializedPropertyStringArray(tagsProperty, newSelectedTags.ToArray());
                            editableProfileProperty.FindPropertyRelative("tags.isDirty").boolValue = true;
                        }
                    }

                    if (isUndoRequested)
                    {
                        var tagsProperty = editableProfileProperty.FindPropertyRelative("tags.value");
                        EditorUtilityExtensions.SetSerializedPropertyStringArray(tagsProperty,
                                                                                 profile.tagNames.ToArray());
                        editableProfileProperty.FindPropertyRelative("tags.isDirty").boolValue = false;
                    }
                }
            }
        }
Esempio n. 23
0
        public void OnGUI()
        {
            using (new EditorGUILayout.HorizontalScope())
            {
                using (new EditorGUILayout.VerticalScope(GUILayout.Width(300)))
                {
                    using (var check = new EditorGUI.ChangeCheckScope())
                    {
                        _captureObject = (GameObject)EditorGUILayout.ObjectField("Capture Object", _captureObject, typeof(GameObject));
                        _size          = EditorGUILayout.Vector2IntField("Size", _size);

                        if (check.changed)
                        {
                            if (_captureObject == null)
                            {
                                return;
                            }

                            if (_size.x <= 0 && _size.y <= 0)
                            {
                                return;
                            }

                            var anim = _captureObject.GetComponent <Animator>();
                            if (anim == null)
                            {
                                Debug.LogWarning("Require Animator");
                                return;
                            }

                            SetUp(_captureObject, _size);
                        }
                    }

                    if (!SetParam())
                    {
                        return;
                    }

                    using (var check = new EditorGUI.ChangeCheckScope())
                    {
                        _backgroundColor = EditorGUILayout.ColorField("BackgroundColor", _backgroundColor);
                        _cameraPosition  = EditorGUILayout.Vector3Field("CameraPosition", _cameraPosition);
                        _cameraRotation  = EditorGUILayout.Vector3Field("CameraRotation", _cameraRotation);
                        if (check.changed)
                        {
                            _objectCapture.Camera.backgroundColor            = _backgroundColor;
                            _objectCapture.Camera.transform.localPosition    = _cameraPosition;
                            _objectCapture.Camera.transform.localEulerAngles = _cameraRotation;
                        }
                    }

                    var clips = _animator.runtimeAnimatorController.animationClips.Select(ac => ac.name).ToArray();
                    if (_animationIndex >= clips.Length)
                    {
                        _animationIndex = 0;
                    }

                    using (var check = new EditorGUI.ChangeCheckScope())
                    {
                        _animationIndex = EditorGUILayout.Popup("Animation", _animationIndex, clips);
                        if (check.changed)
                        {
                            _maxLength = _animator.runtimeAnimatorController.animationClips[_animationIndex].length;
                        }
                    }

                    using (var check = new EditorGUI.ChangeCheckScope())
                    {
                        _length = EditorGUILayout.Slider("NormarizedTime", _length, 0f, _maxLength);
                        if (check.changed)
                        {
                            PlayAnimation(clips[_animationIndex], _length);
                        }
                    }

                    using (new EditorGUILayout.HorizontalScope())
                    {
                        if (GUILayout.Button("Play"))
                        {
                            PlayAnimation(clips[_animationIndex]);
                        }
                        if (GUILayout.Button("Stop"))
                        {
                            StopAnimation();
                        }
                    }
                    if (GUILayout.Button("Capture"))
                    {
                        _info?.Capture();
                    }
                }

                _info?.DrawRenderTexture();
            }
        }
        public override void OnInspectorGUI()
        {
            CheckStyles();

            serializedObject.Update();

            EditorGUILayout.Space();

            var profile = m_Profile;

            EditorGUI.indentLevel++;

            using (var scope = new EditorGUI.ChangeCheckScope())
            {
                EditorGUILayout.PropertyField(profile.scatteringDistance, s_Styles.profileScatteringDistance);

                using (new EditorGUI.DisabledScope(true))
                    EditorGUILayout.FloatField(s_Styles.profileMaxRadius, profile.objReference.filterRadius);

                EditorGUILayout.Slider(profile.ior, 1.0f, 2.0f, s_Styles.profileIor);
                EditorGUILayout.PropertyField(profile.worldScale, s_Styles.profileWorldScale);

                EditorGUILayout.Space();
                EditorGUILayout.LabelField(s_Styles.SubsurfaceScatteringLabel, EditorStyles.boldLabel);

                profile.texturingMode.intValue = EditorGUILayout.Popup(s_Styles.texturingMode, profile.texturingMode.intValue, s_Styles.texturingModeOptions);

                EditorGUILayout.Space();
                EditorGUILayout.LabelField(s_Styles.TransmissionLabel, EditorStyles.boldLabel);

                profile.transmissionMode.intValue = EditorGUILayout.Popup(s_Styles.profileTransmissionMode, profile.transmissionMode.intValue, s_Styles.transmissionModeOptions);

                EditorGUILayout.PropertyField(profile.transmissionTint, s_Styles.profileTransmissionTint);
                EditorGUILayout.PropertyField(profile.thicknessRemap, s_Styles.profileMinMaxThickness);
                var thicknessRemap = profile.thicknessRemap.vector2Value;
                EditorGUILayout.MinMaxSlider(s_Styles.profileThicknessRemap, ref thicknessRemap.x, ref thicknessRemap.y, 0f, 50f);
                profile.thicknessRemap.vector2Value = thicknessRemap;

                EditorGUILayout.Space();
                EditorGUILayout.LabelField(s_Styles.profilePreview0, s_Styles.centeredMiniBoldLabel);
                EditorGUILayout.LabelField(s_Styles.profilePreview1, EditorStyles.centeredGreyMiniLabel);
                EditorGUILayout.LabelField(s_Styles.profilePreview2, EditorStyles.centeredGreyMiniLabel);
                EditorGUILayout.LabelField(s_Styles.profilePreview3, EditorStyles.centeredGreyMiniLabel);
                EditorGUILayout.Space();

                serializedObject.ApplyModifiedProperties();

                if (scope.changed)
                {
                    // Validate and update the cache for this profile only
                    profile.objReference.Validate();
                    m_Target.UpdateCache();
                }
            }

            RenderPreview(profile);

            EditorGUILayout.Space();
            EditorGUI.indentLevel--;

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 25
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Initialize(property);

            using (var check = new EditorGUI.ChangeCheckScope())
            {
                if (m_MaskedSourceNames == null)
                {
                    m_MaskedSourceNames = EnumHelper.MaskOutEnumNames <ImageSource>((int)m_SupportedSources);
                }
                var index = EnumHelper.GetMaskedIndexFromEnumValue <ImageSource>(m_Source.intValue, (int)m_SupportedSources);
                index = EditorGUILayout.Popup("Source", index, m_MaskedSourceNames);

                if (check.changed)
                {
                    m_Source.intValue = EnumHelper.GetEnumValueFromMaskedIndex <ImageSource>(index, (int)m_SupportedSources);
                }
            }

            if ((ImageSource)m_Source.intValue == ImageSource.TaggedCamera)
            {
                ++EditorGUI.indentLevel;
                EditorGUILayout.PropertyField(m_CameraTag, Styles.TagLabel);
                --EditorGUI.indentLevel;
            }

            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.PropertyField(m_AspectRatio, Styles.AspectRatioLabel);
            EditorGUILayout.PropertyField(m_SuperSampling, Styles.SuperSamplingLabel);

            m_RenderHeight.intValue = m_RenderHeightSelector.Popup(Styles.RenderingResolutionLabel, m_RenderHeight.intValue, (int)ImageHeight.x4320p_8K);

            if (m_FinalHeight.intValue > m_RenderHeight.intValue)
            {
                m_FinalHeight.intValue = m_RenderHeight.intValue;
            }

            m_FinalHeight.intValue = m_FinalHeightSelector.Popup(Styles.OutputResolutionLabel, m_FinalHeight.intValue, target.kMaxSupportedSize);

            if (m_FinalHeight.intValue > m_RenderHeight.intValue)
            {
                m_RenderHeight.intValue = m_FinalHeight.intValue;
            }
            EditorGUILayout.Space();

            EditorGUILayout.PropertyField(m_FlipFinalOutput, Styles.FlipVerticalLabel);

            if (Options.verboseMode)
            {
                EditorGUILayout.LabelField("Color Space", target.colorSpace.ToString());
            }

            if (EditorGUI.EndChangeCheck())
            {
                property.serializedObject.ApplyModifiedProperties();

                var aspect = target.outputAspectRatio.GetAspect();
                target.outputWidth = (int)(aspect * target.outputHeight);
                target.renderWidth = (int)(aspect * target.renderHeight);
            }
        }
Esempio n. 26
0
        private static void DrawHeaderBlock(string searchContext)
        {
            if (BuildManagerUtility.TryMatchSearch(searchContext, ShowProjectSettingsLabel.text))
            {
                if (GUILayout.Button(ShowProjectSettingsLabel))
                {
                    SettingsService.OpenProjectSettings(BuildManagerUtility.ProjectSettingsPath);
                }

                EditorGUILayout.Separator();
            }

            using (EditorGUI.ChangeCheckScope changeCheckScope = new EditorGUI.ChangeCheckScope())
            {
                if (BuildManagerUtility.TryMatchSearch(searchContext, OpenBuiltPlayerOptionsLabel.text))
                {
                    OpenBuiltPlayerOptionsSetting.value = (OpenBuiltPlayerOptions)EditorGUILayout.EnumFlagsField(OpenBuiltPlayerOptionsLabel, OpenBuiltPlayerOptionsSetting);
                    SettingsGUILayout.DoResetContextMenuForLastRect(OpenBuiltPlayerOptionsSetting);
                }

                CreateStandardizedBuildOutputSetting.value = SettingsGUILayout.SettingsToggle(CreateStandardizedBuildOutputLabel, CreateStandardizedBuildOutputSetting, searchContext);

                if (changeCheckScope.changed)
                {
                    Settings.Save();
                }
            }

            using (new EditorGUI.DisabledScope(!CreateStandardizedBuildOutputSetting))
            {
                using (EditorGUI.ChangeCheckScope changeCheckScope = new EditorGUI.ChangeCheckScope())
                {
                    using (new EditorGUI.IndentLevelScope())
                    {
                        GroupByBuildNameSetting.value   = SettingsGUILayout.SettingsToggle(GroupByBuildNameLabel, GroupByBuildNameSetting, searchContext);
                        GroupByBuildTargetSetting.value = SettingsGUILayout.SettingsToggle(GroupByBuildTargetLabel, GroupByBuildTargetSetting, searchContext);

                        if (changeCheckScope.changed)
                        {
                            Settings.Save();
                        }

                        if (!BuildManagerUtility.TryMatchSearch(searchContext, StandardizedBuildOutputPathLabel.text) &&
                            !BuildManagerUtility.TryMatchSearch(searchContext, ChangeButtonLabel.text))
                        {
                            return;
                        }

                        Rect position = EditorGUILayout.GetControlRect();
                        position = EditorGUI.PrefixLabel(position, StandardizedBuildOutputPathLabel);

                        if (GUI.Button(position, ChangeButtonLabel, EditorStyles.miniButton))
                        {
                            string value = EditorUtility.OpenFolderPanel("Builds folder location", Path.GetDirectoryName(StandardizedBuildOutputPath), Path.GetFileName(StandardizedBuildOutputPath));

                            if (string.IsNullOrEmpty(value) == false)
                            {
                                StandardizedBuildOutputPathSetting.SetValue(value, true);
                            }
                        }

                        SettingsGUILayout.DoResetContextMenuForLastRect(StandardizedBuildOutputPathSetting);
                        position = EditorGUILayout.GetControlRect();

                        if (Event.current.type == EventType.MouseUp && Event.current.button == 0 && position.Contains(Event.current.mousePosition))
                        {
                            string path = Directory.Exists(StandardizedBuildOutputPath) ? StandardizedBuildOutputPath : Path.GetDirectoryName(Application.dataPath);
                            Assert.IsFalse(string.IsNullOrWhiteSpace(path));
                            Process.Start(path);
                        }

                        string outputLabel = StandardizedBuildOutputPathSetting == DefaultStandardizedBuildOutputPath
                                                 ? $"./{DefaultStandardizedBuildOutputPath}"
                                                 : StandardizedBuildOutputPath;

                        EditorGUI.LabelField(position, outputLabel, EditorStyles.miniLabel);
                        SettingsGUILayout.DoResetContextMenuForLastRect(StandardizedBuildOutputPathSetting);
                    }
                }
            }
        }
Esempio n. 27
0
        private static void DrawWallHackSection()
        {
            using (var changed = new EditorGUI.ChangeCheckScope())
            {
                var fold = GUITools.DrawFoldHeader("WallHack Detector", ACTkEditorPrefsSettings.WallHackFoldout);
                if (changed.changed)
                {
                    ACTkEditorPrefsSettings.WallHackFoldout = fold;
                }
            }

            if (!ACTkEditorPrefsSettings.WallHackFoldout)
            {
                return;
            }

            GUILayout.Space(-3f);

            using (GUITools.Vertical(GUITools.PanelWithBackground))
            {
                GUILayout.Label(
                    "Wireframe module uses own shader under the hood and it should be included into the build.",
                    EditorStyles.wordWrappedLabel);

                ReadGraphicsAsset();

                if (graphicsSettingsAsset != null && includedShaders != null)
                {
                    // outputs whole included shaders list, use for debug
                    //EditorGUILayout.PropertyField(includedShaders, true);

                    var shaderIndex = GetWallhackDetectorShaderIndex();

                    EditorGUI.BeginChangeCheck();

                    var status = shaderIndex != -1 ? ColorTools.GetGreenString() + ">included" : ColorTools.GetRedString() + ">not included";
                    GUILayout.Label("Shader status: <color=#" + status + "</color>", GUITools.RichLabel);

                    GUILayout.Space(5f);
                    EditorGUILayout.HelpBox("You don't need to include it if you're not going to use Wireframe module",
                                            MessageType.Info, true);
                    GUILayout.Space(5f);

                    if (shaderIndex != -1)
                    {
                        if (GUILayout.Button("Remove shader"))
                        {
                            includedShaders.DeleteArrayElementAtIndex(shaderIndex);
                            includedShaders.DeleteArrayElementAtIndex(shaderIndex);
                        }

                        GUILayout.Space(3);
                    }
                    else
                    {
                        using (GUITools.Horizontal())
                        {
                            if (GUILayout.Button("Auto Include"))
                            {
                                var shader = Shader.Find(WallHackDetector.WireframeShaderName);
                                if (shader != null)
                                {
                                    includedShaders.InsertArrayElementAtIndex(includedShaders.arraySize);
                                    var newItem = includedShaders.GetArrayElementAtIndex(includedShaders.arraySize - 1);
                                    newItem.objectReferenceValue = shader;
                                }
                                else
                                {
                                    Debug.LogError(EditorTools.ConstructError("Can't find " + WallHackDetector.WireframeShaderName +
                                                                              " shader!"));
                                }
                            }

                            if (GUILayout.Button("Include manually (see readme.pdf)"))
                            {
#if UNITY_2018_3_OR_NEWER
                                SettingsService.OpenProjectSettings("Project/Graphics");
#else
                                EditorApplication.ExecuteMenuItem("Edit/Project Settings/Graphics");
#endif
                            }
                        }

                        GUILayout.Space(3);
                    }

                    if (EditorGUI.EndChangeCheck())
                    {
                        graphicsSettingsAsset.ApplyModifiedProperties();
                    }
                }
                else
                {
                    GUILayout.Label("Can't automatically control " + WallHackDetector.WireframeShaderName +
                                    " shader existence at the Always Included Shaders list. Please, manage this manually in Graphics Settings.");
                    if (GUILayout.Button("Open Graphics Settings"))
                    {
                        EditorApplication.ExecuteMenuItem("Edit/Project Settings/Graphics");
                    }
                }
            }
        }
Esempio n. 28
0
        void DrawBezierPathInspector()
        {
            using (var check = new EditorGUI.ChangeCheckScope()) {
                // Path options:
                data.showPathOptions = EditorGUILayout.Foldout(data.showPathOptions, new GUIContent("Bézier Path Options"), true, boldFoldoutStyle);
                if (data.showPathOptions)
                {
                    bezierPath.Space            = (PathSpace)EditorGUILayout.Popup("Space", (int)bezierPath.Space, spaceNames);
                    bezierPath.ControlPointMode = (BezierPath.ControlMode)EditorGUILayout.EnumPopup(new GUIContent("Control Mode"), bezierPath.ControlPointMode);
                    if (bezierPath.ControlPointMode == BezierPath.ControlMode.Automatic)
                    {
                        bezierPath.AutoControlLength = EditorGUILayout.Slider(new GUIContent("Control Spacing"), bezierPath.AutoControlLength, 0, 1);
                    }

                    bezierPath.IsClosed    = EditorGUILayout.Toggle("Closed Path", bezierPath.IsClosed);
                    data.showTransformTool = EditorGUILayout.Toggle(new GUIContent("Enable Transforms"), data.showTransformTool);

                    Tools.hidden = !data.showTransformTool;

                    // Check if out of bounds (can occur after undo operations)
                    if (handleIndexToDisplayAsTransform >= bezierPath.NumPoints)
                    {
                        handleIndexToDisplayAsTransform = -1;
                    }

                    // If a point has been selected
                    if (handleIndexToDisplayAsTransform != -1)
                    {
                        EditorGUILayout.LabelField("Selected Point:");

                        using (new EditorGUI.IndentLevelScope()) {
                            var currentPosition = creator.bezierPath[handleIndexToDisplayAsTransform];
                            var newPosition     = EditorGUILayout.Vector3Field("Position", currentPosition);
                            if (newPosition != currentPosition)
                            {
                                Undo.RecordObject(creator, "Move point");
                                creator.bezierPath.MovePoint(handleIndexToDisplayAsTransform, newPosition);
                            }
                            // Don't draw the angle field if we aren't selecting an anchor point/not in 3d space
                            if (handleIndexToDisplayAsTransform % 3 == 0 && creator.bezierPath.Space == PathSpace.xyz)
                            {
                                var anchorIndex  = handleIndexToDisplayAsTransform / 3;
                                var currentAngle = creator.bezierPath.GetAnchorNormalAngle(anchorIndex);
                                var newAngle     = EditorGUILayout.FloatField("Angle", currentAngle);
                                if (newAngle != currentAngle)
                                {
                                    Undo.RecordObject(creator, "Set Angle");
                                    creator.bezierPath.SetAnchorNormalAngle(anchorIndex, newAngle);
                                }
                            }
                        }
                    }

                    if (data.showTransformTool & (handleIndexToDisplayAsTransform == -1))
                    {
                        if (GUILayout.Button("Centre Transform"))
                        {
                            Vector3 worldCentre  = bezierPath.CalculateBoundsWithTransform(creator.transform).center;
                            Vector3 transformPos = creator.transform.position;
                            if (bezierPath.Space == PathSpace.xy)
                            {
                                transformPos = new Vector3(transformPos.x, transformPos.y, 0);
                            }
                            else if (bezierPath.Space == PathSpace.xz)
                            {
                                transformPos = new Vector3(transformPos.x, 0, transformPos.z);
                            }
                            Vector3 worldCentreToTransform = transformPos - worldCentre;

                            if (worldCentre != creator.transform.position)
                            {
                                //Undo.RecordObject (creator, "Centralize Transform");
                                if (worldCentreToTransform != Vector3.zero)
                                {
                                    Vector3 localCentreToTransform = MathUtility.InverseTransformVector(worldCentreToTransform, creator.transform, bezierPath.Space);
                                    for (int i = 0; i < bezierPath.NumPoints; i++)
                                    {
                                        bezierPath.SetPoint(i, bezierPath.GetPoint(i) + localCentreToTransform, true);
                                    }
                                }

                                creator.transform.position = worldCentre;
                                bezierPath.NotifyPathModified();
                            }
                        }
                    }

                    if (GUILayout.Button("Reset Path"))
                    {
                        Undo.RecordObject(creator, "Reset Path");
                        bool in2DEditorMode = EditorSettings.defaultBehaviorMode == EditorBehaviorMode.Mode2D;
                        data.ResetBezierPath(creator.transform.position, in2DEditorMode);
                        EditorApplication.QueuePlayerLoopUpdate();
                    }

                    GUILayout.Space(inspectorSectionSpacing);
                }

                data.showNormals = EditorGUILayout.Foldout(data.showNormals, new GUIContent("Normals Options"), true, boldFoldoutStyle);
                if (data.showNormals)
                {
                    bezierPath.FlipNormals = EditorGUILayout.Toggle(new GUIContent("Flip Normals"), bezierPath.FlipNormals);
                    if (bezierPath.Space == PathSpace.xyz)
                    {
                        bezierPath.GlobalNormalsAngle = EditorGUILayout.Slider(new GUIContent("Global Angle"), bezierPath.GlobalNormalsAngle, 0, 360);

                        if (GUILayout.Button("Reset Normals"))
                        {
                            Undo.RecordObject(creator, "Reset Normals");
                            bezierPath.FlipNormals = false;
                            bezierPath.ResetNormalAngles();
                        }
                    }
                    GUILayout.Space(inspectorSectionSpacing);
                }

                // Editor display options
                data.showDisplayOptions = EditorGUILayout.Foldout(data.showDisplayOptions, new GUIContent("Display Options"), true, boldFoldoutStyle);
                if (data.showDisplayOptions)
                {
                    data.showPathBounds       = GUILayout.Toggle(data.showPathBounds, new GUIContent("Show Path Bounds"));
                    data.showPerSegmentBounds = GUILayout.Toggle(data.showPerSegmentBounds, new GUIContent("Show Segment Bounds"));
                    data.displayAnchorPoints  = GUILayout.Toggle(data.displayAnchorPoints, new GUIContent("Show Anchor Points"));
                    if (!(bezierPath.ControlPointMode == BezierPath.ControlMode.Automatic && globalDisplaySettings.hideAutoControls))
                    {
                        data.displayControlPoints = GUILayout.Toggle(data.displayControlPoints, new GUIContent("Show Control Points"));
                    }
                    data.keepConstantHandleSize = GUILayout.Toggle(data.keepConstantHandleSize, new GUIContent("Constant Point Size", constantSizeTooltip));
                    data.bezierHandleScale      = Mathf.Max(0, EditorGUILayout.FloatField(new GUIContent("Handle Scale"), data.bezierHandleScale));
                    DrawGlobalDisplaySettingsInspector();
                }

                if (check.changed)
                {
                    SceneView.RepaintAll();
                    EditorApplication.QueuePlayerLoopUpdate();
                }
            }
        }
        public override void OnInspectorGUI()
        {
            using (var check = new EditorGUI.ChangeCheckScope())
            {
                EditorGUILayout.PropertyField(m_DefaultIslandProperty);
                m_ShowIslands = EditorGUILayout.Foldout(m_ShowIslands, "Current Islands", true);
                if (m_ShowIslands)
                {
                    DrawCurrentIslands();
                }

                if (check.changed)
                {
                    serializedObject.ApplyModifiedProperties();
                }
            }

            const float providerColumnWidthRatio = 0.5f;
            var         providerWidth            = EditorGUIUtility.currentViewWidth * providerColumnWidthRatio;
            var         foldoutStyle             = styles.ProviderTypesFoldoutStyle;

            styles.ProviderTypesFoldoutStyle.fixedWidth = providerWidth;
            var providerColumnWidth = GUILayout.Width(providerWidth);
            var priorityColumnWidth = GUILayout.Width(k_PriorityColumnWidth);

            using (new EditorGUILayout.HorizontalScope())
            {
                m_ShowProviderTypeList = EditorGUILayout.Foldout(m_ShowProviderTypeList, "Provider Types", true, foldoutStyle);
                if (m_ShowProviderTypeList)
                {
                    GUILayout.Space(providerWidth - k_PriorityHeaderOffset);
                    GUILayout.Label("Priorities", priorityColumnWidth);
                    GUILayout.Label("Excluded Platforms");
                }
            }

            if (m_ShowProviderTypeList)
            {
                using (new EditorGUI.IndentLevelScope())
                {
                    foreach (var type in k_AllProviderTypes)
                    {
                        using (new EditorGUILayout.HorizontalScope())
                        {
                            var priority          = 0;
                            var excludedPlatforms = string.Empty;
                            var priorityAttribute = FunctionalityIsland.GetProviderSelectionOptions(type);
                            if (priorityAttribute != null)
                            {
                                priority = priorityAttribute.Priority;
                                var platforms = priorityAttribute.ExcludedPlatforms;
                                if (platforms != null)
                                {
                                    excludedPlatforms = String.Join(", ", platforms);
                                }
                            }

                            MonoScript script;
                            if (k_MonoScripts.TryGetValue(type, out script))
                            {
                                EditorGUILayout.ObjectField(script, typeof(MonoScript), false, providerColumnWidth);
                            }
                            else
                            {
                                EditorGUILayout.LabelField(type.GetFullNameWithGenericArguments(), providerColumnWidth);
                            }

                            EditorGUILayout.LabelField(priority.ToString(), priorityColumnWidth);
                            EditorGUILayout.LabelField(string.Join(", ", excludedPlatforms));
                        }
                    }
                }
            }

            m_ShowSubscriberTypeList = EditorGUILayout.Foldout(m_ShowSubscriberTypeList, "Subscriber Types", true);
            if (m_ShowSubscriberTypeList)
            {
                using (new EditorGUI.IndentLevelScope())
                {
                    foreach (var type in k_AllSubscriberTypes)
                    {
                        MonoScript script;
                        if (k_MonoScripts.TryGetValue(type, out script))
                        {
                            EditorGUILayout.ObjectField(script, typeof(MonoScript), false);
                        }
                        else
                        {
                            EditorGUILayout.LabelField(type.GetFullNameWithGenericArguments());
                        }
                    }
                }
            }
        }
        public override void OnInspectorGUI()
        {
            CheckStyles();

            serializedObject.Update();

            EditorGUILayout.Space();

            var profile = m_Profile;

            EditorGUI.indentLevel++;

            using (var scope = new EditorGUI.ChangeCheckScope())
            {
                EditorGUILayout.PropertyField(profile.scatteringDistance, s_Styles.profileScatteringDistance);

                using (new EditorGUI.DisabledScope(true))
                    EditorGUILayout.FloatField(s_Styles.profileMaxRadius, profile.objReference.filterRadius);

                EditorGUILayout.Slider(profile.ior, 1.0f, 2.0f, s_Styles.profileIor);
                EditorGUILayout.PropertyField(profile.worldScale, s_Styles.profileWorldScale);

                EditorGUILayout.Space();
                EditorGUILayout.LabelField(s_Styles.SubsurfaceScatteringLabel, EditorStyles.boldLabel);

                profile.texturingMode.intValue = EditorGUILayout.Popup(s_Styles.texturingMode, profile.texturingMode.intValue, s_Styles.texturingModeOptions);

                EditorGUILayout.Space();
                EditorGUILayout.LabelField(s_Styles.TransmissionLabel, EditorStyles.boldLabel);

                profile.transmissionMode.intValue = EditorGUILayout.Popup(s_Styles.profileTransmissionMode, profile.transmissionMode.intValue, s_Styles.transmissionModeOptions);

                EditorGUILayout.PropertyField(profile.transmissionTint, s_Styles.profileTransmissionTint);
                EditorGUILayout.PropertyField(profile.thicknessRemap, s_Styles.profileMinMaxThickness);
                var thicknessRemap = profile.thicknessRemap.vector2Value;
                EditorGUILayout.MinMaxSlider(s_Styles.profileThicknessRemap, ref thicknessRemap.x, ref thicknessRemap.y, 0f, 50f);
                profile.thicknessRemap.vector2Value = thicknessRemap;

                EditorGUILayout.Space();
                EditorGUILayout.LabelField(s_Styles.profilePreview0, s_Styles.centeredMiniBoldLabel);
                EditorGUILayout.LabelField(s_Styles.profilePreview1, EditorStyles.centeredGreyMiniLabel);
                EditorGUILayout.LabelField(s_Styles.profilePreview2, EditorStyles.centeredGreyMiniLabel);
                EditorGUILayout.LabelField(s_Styles.profilePreview3, EditorStyles.centeredGreyMiniLabel);
                EditorGUILayout.Space();

                serializedObject.ApplyModifiedProperties();

                // NOTE: We cannot change only upon scope changed since there is no callback when Reset is triggered for Editor and the scope is not changed when Reset is called.
                // The following operations are not super cheap, but are not overly expensive, so we instead trigger the change every time inspector is drawn.
                //    if (scope.changed)
                {
                    // Validate and update the cache for this profile only
                    profile.objReference.Validate();
                    m_Target.UpdateCache();
                }
            }

            RenderPreview(profile);

            EditorGUILayout.Space();
            EditorGUI.indentLevel--;

            serializedObject.ApplyModifiedProperties();
        }