コード例 #1
0
        public void DrawControl(IAudioEffectPlugin plugin)
        {
            if (loudness == null)
            {
                loudness = new AudioSignalSmoothAnalyzer();
            }

            if (_loudnessTree == null)
            {
                _loudnessTree = PropertyTree.Create(loudness);
            }

            plugin.GetFloatParameter("Instance", out var instance);

            var i = GAC.ChannelMonitor_GetLoudnessData_dB((int)instance);

            loudness.Add(GAC.dBToNormalized(i));

            var guie = GUI.enabled;

            GUI.enabled = true;
            _loudnessTree.Draw(false);
            _loudnessTree.ApplyChanges();
            GUI.enabled = guie;
        }
            private void DrawBaseEditor()
            {
#if ODIN_INSPECTOR
                _propertyTree?.Draw();
                _propertyTree?.ApplyChanges();
#else
                base.OnInspectorGUI();
#endif
            }
コード例 #3
0
        private void ApplyChanges()
        {
            _drawerTree.ApplyChanges();

            for (var i = 0; i < rules.Count; i++)
            {
                var rule  = rules[i];
                var index = _importSettings.rules.IndexOf(rule);
                if (index < 0)
                {
                    continue;
                }
                _importSettings.rules[index] = rules[i];
            }
        }
コード例 #4
0
        private bool DrawWithOdin()
        {
            var hasOdinAsset = false;

#if ODIN_INSPECTOR_3
            hasOdinAsset = true;
#endif
            if (!hasOdinAsset)
            {
                return(false);
            }

#if ODIN_INSPECTOR
            _propertyTree?.Draw();
            _propertyTree?.ApplyChanges();
#endif

            return(true);
        }
コード例 #5
0
        /// <summary>
        /// Ends drawing a property tree, and handles management of undo, as well as marking scenes and drawn assets dirty.
        /// </summary>
        /// <param name="tree">The tree.</param>
        public static void EndDrawPropertyTree(PropertyTree tree)
        {
            tree.InvokeDelayedActions();

            if (tree.UnitySerializedObject != null)
            {
                if (mPropertyFieldGetter != null)
                {
                    var    obj = tree.UnitySerializedObject;
                    IntPtr ptr = mPropertyFieldGetter(ref obj);

                    if (ptr == IntPtr.Zero)
                    {
                        // SerializedObject has been disposed, likely due to a scene change invoked from GUI code.
                        // BAIL THE F**K OUT! :D Crashes will happen.
                        return;
                    }
                }

                if (tree.WillUndo)
                {
                    tree.UnitySerializedObject.ApplyModifiedProperties();
                }
                else
                {
                    tree.UnitySerializedObject.ApplyModifiedPropertiesWithoutUndo();
                }
            }

            bool appliedOdinChanges = false;

            if (tree.ApplyChanges())
            {
                appliedOdinChanges = true;
                GUIHelper.RequestRepaint();

                if (tree.TargetType.ImplementsOrInherits(typeof(UnityEngine.Object)))
                {
                    var targets = tree.WeakTargets;

                    for (int i = 0; i < targets.Count; i++)
                    {
                        var target = (UnityEngine.Object)targets[i];

                        if (AssetDatabase.Contains(target))
                        {
                            EditorUtility.SetDirty(target);
                        }
                        else if (Application.isPlaying == false)
                        {
#if UNITY_5_3_OR_NEWER
                            if (tree.TargetType.ImplementsOrInherits(typeof(Component)))
                            {
                                Component component = (Component)target;
                                UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(component.gameObject.scene);
                            }
                            else
                            {
                                // We can't find out where this thing is from
                                // It is probably a "temporary" UnityObject created from a script somewhere
                                // Just to be safe, mark it as dirty, and mark all scenes as dirty

                                EditorUtility.SetDirty(target);
                                UnityEditor.SceneManagement.EditorSceneManager.MarkAllScenesDirty();
                            }
#else
                            EditorApplication.MarkSceneDirty();
#endif
                        }
                    }
                }
            }

            // This is very important, as applying changes may cause more actions to be delayed
            tree.InvokeDelayedActions();

            if (appliedOdinChanges)
            {
                tree.InvokeOnValidate();
            }

            drawnInspectorDepthCount--;

#if ODIN_TRIAL_VERSION
            if (drawnInspectorDepthCount == 0)
            {
                float height = OdinTrialVersionInfo.IsExpired ? 22 : 17;
                var   rect   = GUILayoutUtility.GetRect(16, height, GUILayoutOptions.ExpandWidth().Height(height));

                var bgRect = rect;
                bgRect.xMin -= 20;
                bgRect.xMax += 20;
                bgRect.y    += 2;
                AllEditorGUI.DrawBorders(bgRect, 0, 0, 1, 0, SirenixGUIStyles.LightBorderColor);

                rect.y += 2;
                if (OdinTrialVersionInfo.IsExpired)
                {
                    EditorGUI.DrawRect(bgRect, Color.black);
                    GUIHelper.PushContentColor(Color.red);

                    GUI.Label(rect.AddY(3), "ODIN Inspector Trial expired!", SirenixGUIStyles.Label);
                    GUIHelper.PopContentColor();
                    var btnRect = rect.AlignRight(EditorStyles.miniButton.CalcSize(new GUIContent("Purchase ODIN Inspector")).x);
                    btnRect.yMin += 2;
                    btnRect.yMax -= 2;
                    GUIHelper.PushColor(Color.green);
                    if (GUI.Button(btnRect, "Purchase ODIN Inspector", EditorStyles.miniButton))
                    {
                        UnityEditorInternal.AssetStore.Open("content/89041");
                    }
                    GUIHelper.PopColor();
                }
                else
                {
                    GUI.Label(rect, "ODIN Inspector Trial Version", SirenixGUIStyles.LeftAlignedGreyMiniLabel);
                    GUI.Label(rect, "Expires " + OdinTrialVersionInfo.ExpirationDate.ToShortDateString(), EditorStyles.centeredGreyMiniLabel);
                    GUI.Label(rect, OdinTrialVersionInfo.ExpirationDate.Subtract(System.DateTime.Now).TotalHours.ToString("F2") + " hours remaining.", SirenixGUIStyles.RightAlignedGreyMiniLabel);
                }
            }
#endif
        }
コード例 #6
0
        /// <summary>
        /// Ends drawing a property tree, and handles management of undo, as well as marking scenes and drawn assets dirty.
        /// </summary>
        /// <param name="tree">The tree.</param>
        public static void EndDrawPropertyTree(PropertyTree tree)
        {
            tree.InvokeDelayedActions();

            if (tree.UnitySerializedObject != null)
            {
                if (SerializedObject_nativeObjectPtrGetter != null)
                {
                    var    obj = tree.UnitySerializedObject;
                    IntPtr ptr = SerializedObject_nativeObjectPtrGetter(ref obj);

                    if (ptr == IntPtr.Zero)
                    {
                        // SerializedObject has been disposed, likely due to a scene change invoked from GUI code.
                        // BAIL THE F**K OUT! :D Crashes will happen.
                        return;
                    }
                }

                if (tree.WillUndo)
                {
                    tree.UnitySerializedObject.ApplyModifiedProperties();
                }
                else
                {
                    tree.UnitySerializedObject.ApplyModifiedPropertiesWithoutUndo();
                }
            }

            bool appliedOdinChanges = false;

            if (tree.ApplyChanges())
            {
                appliedOdinChanges = true;
                GUIHelper.RequestRepaint();
            }

            // This is very important, as applying changes may cause more actions to be delayed
            tree.InvokeDelayedActions();

            if (appliedOdinChanges)
            {
                tree.InvokeOnValidate();

                if (tree.PrefabModificationHandler.HasPrefabs)
                {
                    var targets = tree.WeakTargets;

                    for (int i = 0; i < targets.Count; i++)
                    {
                        if (tree.PrefabModificationHandler.TargetPrefabs[i] == null)
                        {
                            continue;
                        }

                        var target = (UnityEngine.Object)targets[i];
                        PrefabUtility.RecordPrefabInstancePropertyModifications(target);
                    }
                }
            }

            if (tree.WillUndo)
            {
                Undo.FlushUndoRecordObjects();
            }

            drawnInspectorDepthCount--;

#if ODIN_TRIAL_VERSION
            if (drawnInspectorDepthCount == 0)
            {
                float height = OdinTrialVersionInfo.IsExpired ? 22 : 17;
                var   rect   = GUILayoutUtility.GetRect(16, height, GUILayoutOptions.ExpandWidth().Height(height));

                var bgRect = rect;
                bgRect.xMin -= 20;
                bgRect.xMax += 20;
                bgRect.y    += 2;
                SirenixEditorGUI.DrawBorders(bgRect, 0, 0, 1, 0, SirenixGUIStyles.LightBorderColor);

                rect.y += 2;
                if (OdinTrialVersionInfo.IsExpired)
                {
                    EditorGUI.DrawRect(bgRect, Color.black);
                    GUIHelper.PushContentColor(Color.red);

                    GUI.Label(rect.AddY(3), "Odin Inspector Trial expired!", SirenixGUIStyles.Label);
                    GUIHelper.PopContentColor();
                    var btnRect = rect.AlignRight(EditorStyles.miniButton.CalcSize(new GUIContent("Purchase Odin Inspector")).x);
                    btnRect.yMin += 2;
                    btnRect.yMax -= 2;
                    GUIHelper.PushColor(Color.green);
                    if (GUI.Button(btnRect, "Purchase Odin Inspector", EditorStyles.miniButton))
                    {
                        UnityEditorInternal.AssetStore.Open("content/89041");
                    }
                    GUIHelper.PopColor();
                }
                else
                {
                    GUI.Label(rect, "Odin Inspector Trial Version", SirenixGUIStyles.LeftAlignedGreyMiniLabel);
                    GUI.Label(rect, "Expires " + OdinTrialVersionInfo.ExpirationDate.ToShortDateString(), EditorStyles.centeredGreyMiniLabel);
                    GUI.Label(rect, OdinTrialVersionInfo.ExpirationDate.Subtract(System.DateTime.Now).TotalHours.ToString("F2") + " hours remaining.", SirenixGUIStyles.RightAlignedGreyMiniLabel);
                }
            }
#endif
        }