Exemplo n.º 1
0
        protected override void Initialize()
        {
            listItemStyle = new GUIStyle(GUIStyle.none)
            {
                padding = new RectOffset(7, 20, 3, 3)
            };

            var entry = this.ValueEntry;

            this.toggled         = this.GetPersistentValue("Toggled", GeneralDrawerConfig.Instance.OpenListsByDefault);
            this.keyWidthOffset  = 130;
            this.label           = this.Property.Label ?? new GUIContent(typeof(TDictionary).GetNiceName());
            this.attrSettings    = entry.Property.Info.GetAttribute <DictionaryDrawerSettings>() ?? new DictionaryDrawerSettings();
            this.disableAddKey   = entry.Property.Tree.PrefabModificationHandler.HasPrefabs && !entry.Property.SupportsPrefabModifications;
            this.keyLabel        = new GUIContent(this.attrSettings.KeyLabel);
            this.valueLabel      = new GUIContent(this.attrSettings.ValueLabel);
            this.keyLabelWidth   = EditorStyles.label.CalcSize(this.keyLabel).x + 20;
            this.valueLabelWidth = EditorStyles.label.CalcSize(this.valueLabel).x + 20;

            if (!this.disableAddKey)
            {
                this.tempKeyValue = new TempKeyValuePair <TKey, TValue>();
                var tree = PropertyTree.Create(this.tempKeyValue);
                tree.UpdateTree();
                this.tempKeyEntry   = (IPropertyValueEntry <TKey>)tree.GetPropertyAtPath("Key").ValueEntry;
                this.tempValueEntry = (IPropertyValueEntry <TValue>)tree.GetPropertyAtPath("Value").ValueEntry;
            }
        }
        protected override void OnEnable()
        {
            base.OnEnable();
#if ODIN_INSPECTOR
            _propertyTree = PropertyTree.Create(target);
#endif
        }
Exemplo n.º 3
0
    public void drawComponent(NodeIComponent component)
    {
        SirenixEditorGUI.BeginBoxHeader();

        component.style.unfolded = SirenixEditorGUI.Foldout(component.style.unfolded, component.component.GetType().ToString());
        Rect rect = GUILayoutUtility.GetLastRect();

        SirenixEditorGUI.EndBoxHeader();

        NodeEditorGUILayout.AddPortField(component.port);

        if (component.style.unfolded)
        {
            SirenixEditorGUI.BeginBox();
            if (component.tree == null)
            {
                GUILayout.Label("the tree is null somehow");
            }
            if (component.tree != null)
            {
                component.tree.Draw(false);
            }
            else
            {
                component.tree = PropertyTree.Create(component.component);
                component.tree.Draw(false);
            }
            //Debug.Log(component.tree.WeakTargets);
            SirenixEditorGUI.EndBox();
        }
    }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
0
    public void init(IComponent c, Node node, NodeMEntity entity, PortOrientation orientation)
    {
        //port = CreateInstance("NodePort") as NodePort;
        parent       = node;
        component    = c;
        parentEntity = entity;
        //  tree = PropertyTree.Create(component);

        if (orientation == PortOrientation.Out)
        {
            port = node.AddDynamicOutput(typeof(bool));
        }
        else
        {
            port = node.AddDynamicInput(typeof(bool));
        }

        style             = new NodeIComponentStyle();
        style.unfolded    = false;
        style.portVisible = false;

        tree = PropertyTree.Create(component);

        AssetDatabase.SaveAssets();
    }
Exemplo n.º 6
0
 private void DrawMultipleTree()
 {
     if (this.objectTree2 == null)
     {
         objectTree2 = PropertyTree.Create(this.treeProperty2);
     }
     this.objectTree2.Draw(false);
 }
Exemplo n.º 7
0
        private void DrawSingleTree()
        {
            if (this.objectTree1 == null)
            {
                this.objectTree1 = PropertyTree.Create(this.treeProperty1);
            }

            this.objectTree1.Draw(false);
        }
Exemplo n.º 8
0
 protected override void DrawTree()
 {
     if (customTree == null)
     {
         customTree = PropertyTree.Create(serializedObject);
     }
     InspectorUtilities.BeginDrawPropertyTree(customTree, true);
     InspectorUtilities.DrawPropertiesInTree(customTree);
     InspectorUtilities.EndDrawPropertyTree(customTree);
 }
Exemplo n.º 9
0
        protected override void Initialize()
        {
            base.Initialize();

            var target = Property.ValueEntry.WeakSmartValue as Object;

            tree = PropertyTree.Create(target);

            Property.Context.GetPersistent(this, $"{target.name}-Feedback-Foldout", out foldout);
        }
        protected virtual void OnEnable()
        {
#if ODIN_INSPECTOR
            propertyTree = PropertyTree.Create(target);
            propertyTree.DrawMonoScriptObjectField = true;
#endif
            if (target is ITLBasicTrackAssetEditorEnter enter)
            {
                enter.Enter();
            }
        }
        private void DrawWithDefaultLocator()
        {
            if (this.defaultPropertyTree == null)
            {
                this.defaultPropertyTree = PropertyTree.Create(new SomeClass());
            }

            SirenixEditorGUI.BeginBox("Default Locator");
            this.defaultPropertyTree.Draw(false);
            SirenixEditorGUI.EndBox();
        }
Exemplo n.º 12
0
    public override void InitAssets()
    {
        if (gameStateManager != null)
        {
            serializedGameStateManager = new SerializedObject(gameStateManager);
        }

        if (myObjectTree == null)
        {
            myObjectTree = PropertyTree.Create(gameStateManager);
        }
    }
        private void DrawWithCustomLocator()
        {
            if (this.customPropertyTree == null)
            {
                this.customPropertyTree = PropertyTree.Create(new SomeClass());
                this.customPropertyTree.AttributeProcessorLocator = new CustomMinionAttributeProcessorLocator();
            }

            SirenixEditorGUI.BeginBox("Custom Locator");
            this.customPropertyTree.Draw(false);
            SirenixEditorGUI.EndBox();
        }
        private void OnEnable()
        {
            _target = target as AddressableImportSettings;
            if (_target == null)
            {
                return;
            }

#if ODIN_INSPECTOR
            _propertyTree = PropertyTree.Create(_target);
#endif

            _methods = AddressableImporterMethodHandler.CollectValidMembers(_target.GetType());
        }
Exemplo n.º 15
0
        public void Initialize(AddressableImportSettings importSettings)
        {
            _importSettings = importSettings;
            _drawerTree     = PropertyTree.Create(this);

            _filters = new List <Func <AddressableImportRule, string, bool> >()
            {
                ValidateAddressableGroupName,
                ValidateRulePath,
                ValidateLabelsPath,
            };

            _drawerTree.OnPropertyValueChanged += (property, index) => EditorUtility.SetDirty(_importSettings);
        }
            public override void OnInspectorGUI()
            {
#if ODIN_INSPECTOR
                _propertyTree = _propertyTree ?? PropertyTree.Create(_target);
#endif
                DrawBaseEditor();

                if (!_isOdinSupportActive)
                {
                    DrawMethods(_methods);
                }

                serializedObject.ApplyModifiedProperties();
            }
        /// <summary>
        /// 绘制用于Example创建的UI
        /// </summary>
        private void DrawExampleCreatorEditor()
        {
            if (m_ExamplePropertyTree == null)
            {
                if (m_ExampleTemplate == null)
                {
                    m_ExampleTemplate = new ExampleTemplate();
                }

                m_ExamplePropertyTree = PropertyTree.Create(m_ExampleTemplate);
            }

            GUILayout.Label("自动生成OverViewExample代码", SirenixGUIStyles.SectionHeader, new GUILayoutOption[0]);

            SirenixEditorGUI.DrawThickHorizontalSeparator(4f, 10f);
            m_ExamplePropertyTree.Draw(false);
        }
Exemplo n.º 18
0
    // Use this for initialization
    protected override void Init()
    {
        //  newAction = CreateInstance<BlaAction>();
        base.Init();
        //meh = 5;
        meh = new BlaAction();

        NodePort port = GetInputPort("ConnectHere");

        // if (newtree == null)
        newtree = PropertyTree.Create(bq);
        Debug.Log("weak: " + newtree.WeakTargets[0].GetType());

        //  bool change = newtree.ApplyChanges();
        //  Debug.Log(change);

        // newtree.OnPropertyValueChanged
    }
Exemplo n.º 19
0
        public override void OnInspectorGUI()
        {
            // If there are no custom editors for a parent type just draw the inspector as usual
            if (parentEditorType == null)
            {
                base.OnInspectorGUI();
            }
            else                 // If a parent type with a custom editor was found draw it
            {
                if (parentType != null)
                {
                    SirenixEditorGUI.Title(ObjectNames.NicifyVariableName(parentType.GetNiceName()), null, TextAlignment.Left, true);
                }

                // Draw the parent custom editor
                if (parentEditorType != null)
                {
                    CreateCachedEditor(target, parentEditorType, ref cachedParentEditor);
                    cachedParentEditor.OnInspectorGUI();
                }

                SirenixEditorGUI.Title(ObjectNames.NicifyVariableName(targetType.GetNiceName()), null, TextAlignment.Left, true);
                // Then draw the properties that the child class defined separately afterwards
                propertyTree ??= PropertyTree.Create(serializedObject);
                InspectorUtilities.BeginDrawPropertyTree(propertyTree, true);
                foreach (var inspectorProperty in propertyTree.EnumerateTree(false))
                {
                    // Don't draw properties that are covered by the parent editor type or any of its parents
                    if (inspectorProperty.Info.TypeOfOwner == parentType || parentBaseClasses.Contains(inspectorProperty.Info.TypeOfOwner))
                    {
                        continue;
                    }

                    inspectorProperty.Draw(inspectorProperty.Label);
                }

                InspectorUtilities.EndDrawPropertyTree(propertyTree);
            }
        }
Exemplo n.º 20
0
        protected static SettingsProvider CreateCustomSettingsProvider(string name)
        {
            _tree = PropertyTree.Create(GetInstance());
            // First parameter is the path in the Settings window.
            // Second parameter is the scope of this setting: it only appears in the Project Settings window.
            SettingsProvider provider = new SettingsProvider($"Project/RedOwl/{name}", SettingsScope.Project)
            {
                // Create the SettingsProvider and initialize its drawing (IMGUI) function in place:
                guiHandler = searchContext =>
                {
                    InspectorUtilities.BeginDrawPropertyTree(_tree, false);
                    foreach (InspectorProperty property in _tree.EnumerateTree(false))
                    {
                        property.Draw(property.Label);
                    }
                    InspectorUtilities.EndDrawPropertyTree(_tree);
                },

                // Populate the search keywords to enable smart search filtering and label highlighting:
                keywords = SettingsProvider.GetSearchKeywordsFromSerializedObject(new SerializedObject(GetInstance()))
            };

            return(provider);
        }
Exemplo n.º 21
0
    public NodeIComponent(IComponent c, Node node, PortOrientation orientation)
    {
        // port = CreateInstance("NodePort") as NodePort;
        parent    = node;
        component = c;
        //  tree = PropertyTree.Create(component);
        if (port == null)
        {
            if (orientation == PortOrientation.Out)
            {
                port = node.AddDynamicOutput(typeof(bool));
            }
            else
            {
                port = node.AddDynamicInput(typeof(bool));
            }
        }

        style             = new NodeIComponentStyle();
        style.unfolded    = false;
        style.portVisible = false;

        tree = PropertyTree.Create(component);
    }
Exemplo n.º 22
0
 public void Initialize(Object target)
 {
     _target = target;
     _drawer = PropertyTree.Create(_target);
 }
Exemplo n.º 23
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(IPropertyValueEntry <TDictionary> entry, GUIContent label)
        {
            var context = entry.Property.Context.Get(this, "context", (Context)null);

            if (context.Value == null)
            {
                context.Value                = new Context();
                context.Value.Toggled        = entry.Context.GetPersistent(this, "Toggled", GeneralDrawerConfig.Instance.OpenListsByDefault);
                context.Value.KeyWidthOffset = 130;
                context.Value.Label          = label ?? new GUIContent(typeof(TDictionary).GetNiceName());
                context.Value.AttrSettings   = entry.Property.Info.GetAttribute <DictionaryDrawerSettings>() ?? new DictionaryDrawerSettings();
                context.Value.DisableAddKey  = entry.Property.Tree.HasPrefabs && !entry.GetDictionaryHandler().SupportsPrefabModifications;

                if (!context.Value.DisableAddKey)
                {
                    context.Value.TempKeyValue = new TempKeyValue();

                    var tree = PropertyTree.Create(context.Value.TempKeyValue);
                    tree.UpdateTree();

                    context.Value.TempKeyEntry   = (IPropertyValueEntry <TKey>)tree.GetPropertyAtPath("Key").ValueEntry;
                    context.Value.TempValueEntry = (IPropertyValueEntry <TValue>)tree.GetPropertyAtPath("Value").ValueEntry;
                }
            }

            context.Value.DictionaryHandler           = (DictionaryHandler <TDictionary, TKey, TValue>)entry.GetDictionaryHandler();
            context.Value.Config                      = GeneralDrawerConfig.Instance;
            context.Value.Paging.NumberOfItemsPerPage = context.Value.Config.NumberOfItemsPrPage;
            context.Value.ListItemStyle.padding.right = !entry.IsEditable || context.Value.AttrSettings.IsReadOnly ? 4 : 20;

            //if (!IsSupportedKeyType)
            //{
            //    var message = entry.Property.Context.Get(this, "error_message", (string)null);
            //    var detailedMessage = entry.Property.Context.Get(this, "error_message_detailed", (string)null);
            //    var folded = entry.Property.Context.Get(this, "error_message_folded", true);

            //    if (message.Value == null)
            //    {
            //        string str = "";

            //        if (label != null)
            //        {
            //            str += label.text + "\n\n";
            //        }

            //        str += "The dictionary key type '" + typeof(TKey).GetNiceFullName() + "' is not supported in prefab instances. Expand this box to see which key types are supported.";

            //        message.Value = str;
            //    }

            //    if (detailedMessage.Value == null)
            //    {
            //        var sb = new StringBuilder("The following key types are supported:");

            //        sb.AppendLine()
            //          .AppendLine();

            //        foreach (var type in DictionaryKeyUtility.GetPersistentPathKeyTypes())
            //        {
            //            sb.AppendLine(type.GetNiceName());
            //        }

            //        sb.AppendLine("Enums of any type");

            //        detailedMessage.Value = sb.ToString();
            //    }

            //    folded.Value = SirenixEditorGUI.DetailedMessageBox(message.Value, detailedMessage.Value, MessageType.Error, folded.Value);

            //    return;
            //}

            SirenixEditorGUI.BeginIndentedVertical(SirenixGUIStyles.PropertyPadding);
            {
                context.Value.Paging.Update(elementCount: entry.Property.Children.Count);
                this.DrawToolbar(entry, context.Value);
                context.Value.Paging.Update(elementCount: entry.Property.Children.Count);

                if (!context.Value.DisableAddKey && context.Value.AttrSettings.IsReadOnly == false)
                {
                    this.DrawAddKey(entry, context.Value);
                }

                float t;
                GUIHelper.BeginLayoutMeasuring();
                if (SirenixEditorGUI.BeginFadeGroup(UniqueDrawerKey.Create(entry.Property, this), context.Value.Toggled.Value, out t))
                {
                    var rect = SirenixEditorGUI.BeginVerticalList(false);
                    if (context.Value.AttrSettings.DisplayMode == DictionaryDisplayOptions.OneLine)
                    {
                        var maxWidth = rect.width - 90;
                        rect.xMin = context.Value.KeyWidthOffset + 22;
                        rect.xMax = rect.xMin + 10;
                        context.Value.KeyWidthOffset = context.Value.KeyWidthOffset + SirenixEditorGUI.SlideRect(rect).x;

                        if (Event.current.type == EventType.Repaint)
                        {
                            context.Value.KeyWidthOffset = Mathf.Clamp(context.Value.KeyWidthOffset, 90, maxWidth);
                        }

                        if (context.Value.Paging.ElementCount != 0)
                        {
                            var headerRect = SirenixEditorGUI.BeginListItem(false);
                            {
                                GUILayout.Space(14);
                                if (Event.current.type == EventType.Repaint)
                                {
                                    GUI.Label(headerRect.SetWidth(context.Value.KeyWidthOffset), context.Value.AttrSettings.KeyLabel, SirenixGUIStyles.LabelCentered);
                                    GUI.Label(headerRect.AddXMin(context.Value.KeyWidthOffset), context.Value.AttrSettings.ValueLabel, SirenixGUIStyles.LabelCentered);
                                    SirenixEditorGUI.DrawSolidRect(headerRect.AlignBottom(1), SirenixGUIStyles.BorderColor);
                                }
                            }
                            SirenixEditorGUI.EndListItem();
                        }
                    }

                    this.DrawElements(entry, label, context.Value);
                    SirenixEditorGUI.EndVerticalList();
                }
                SirenixEditorGUI.EndFadeGroup();

                // Draw borders
                var outerRect = GUIHelper.EndLayoutMeasuring();
                if (t > 0.01f && Event.current.type == EventType.Repaint)
                {
                    Color col = SirenixGUIStyles.BorderColor;
                    outerRect.yMin -= 1;
                    SirenixEditorGUI.DrawBorders(outerRect, 1, col);
                    col.a *= t;
                    if (context.Value.AttrSettings.DisplayMode == DictionaryDisplayOptions.OneLine)
                    {
                        // Draw Slide Rect Border
                        outerRect.width = 1;
                        outerRect.x    += context.Value.KeyWidthOffset + 13;
                        SirenixEditorGUI.DrawSolidRect(outerRect, col);
                    }
                }
            }
            SirenixEditorGUI.EndIndentedVertical();
        }
        public static void UpdatePrefabInstancePropertyModifications(UnityEngine.Object prefabInstance, bool withUndo)
        {
            if (prefabInstance == null)
            {
                throw new ArgumentNullException("prefabInstance");
            }
            if (!(prefabInstance is ISupportsPrefabSerialization))
            {
                throw new ArgumentException("Type must implement ISupportsPrefabSerialization");
            }
            if (!(prefabInstance is ISerializationCallbackReceiver))
            {
                throw new ArgumentException("Type must implement ISerializationCallbackReceiver");
            }
            if (!OdinPrefabSerializationEditorUtility.ObjectIsPrefabInstance(prefabInstance))
            {
                throw new ArgumentException("Value must be a prefab instance");
            }

            Action action = null;

            EditorApplication.HierarchyWindowItemCallback hierarchyCallback = (arg1, arg2) => action();
            EditorApplication.ProjectWindowItemCallback   projectCallback   = (arg1, arg2) => action();
            SceneView.OnSceneFunc sceneCallback = (arg) => action();

            EditorApplication.hierarchyWindowItemOnGUI += hierarchyCallback;
            EditorApplication.projectWindowItemOnGUI   += projectCallback;
            SceneView.onSceneGUIDelegate += sceneCallback;

            action = () =>
            {
                EditorApplication.hierarchyWindowItemOnGUI -= hierarchyCallback;
                EditorApplication.projectWindowItemOnGUI   -= projectCallback;
                SceneView.onSceneGUIDelegate -= sceneCallback;

                // Clear out pre-existing modifications, as they can actually mess this up
                {
                    ISupportsPrefabSerialization supporter = (ISupportsPrefabSerialization)prefabInstance;

                    if (supporter.SerializationData.PrefabModifications != null)
                    {
                        supporter.SerializationData.PrefabModifications.Clear();
                    }

                    if (supporter.SerializationData.PrefabModificationsReferencedUnityObjects != null)
                    {
                        supporter.SerializationData.PrefabModificationsReferencedUnityObjects.Clear();
                    }

                    UnitySerializationUtility.PrefabModificationCache.CachePrefabModifications(prefabInstance, new List <PrefabModification>());
                }

                try
                {
                    if (prefabInstance == null)
                    {
                        // Ignore - the object has been destroyed since the method was invoked.
                        return;
                    }

                    if (Event.current == null)
                    {
                        throw new InvalidOperationException("Delayed property modification delegate can only be called during the GUI event loop; Event.current must be accessible.");
                    }

                    try
                    {
                        PrefabUtility.RecordPrefabInstancePropertyModifications(prefabInstance);
                    }
                    catch (Exception ex)
                    {
                        Debug.LogError("Exception occurred while calling Unity's PrefabUtility.RecordPrefabInstancePropertyModifications:");
                        Debug.LogException(ex);
                    }

                    var tree = PropertyTree.Create(prefabInstance);

                    tree.DrawMonoScriptObjectField = false;

                    bool isRepaint = Event.current.type == EventType.Repaint;

                    if (!isRepaint)
                    {
                        GUIHelper.PushEventType(EventType.Repaint);
                    }

                    InspectorUtilities.BeginDrawPropertyTree(tree, withUndo);

                    foreach (var property in tree.EnumerateTree(true))
                    {
                        if (property.ValueEntry == null)
                        {
                            continue;
                        }
                        if (!property.SupportsPrefabModifications)
                        {
                            continue;
                        }

                        property.Update(true);

                        if (!(property.ChildResolver is IKeyValueMapResolver))
                        {
                            continue;
                        }

                        if (property.ValueEntry.DictionaryChangedFromPrefab)
                        {
                            tree.PrefabModificationHandler.RegisterPrefabDictionaryDeltaModification(property, 0);
                        }
                        else
                        {
                            var prefabProperty = tree.PrefabModificationHandler.PrefabPropertyTree.GetPropertyAtPath(property.Path);

                            if (prefabProperty == null)
                            {
                                continue;
                            }
                            if (prefabProperty.ValueEntry == null)
                            {
                                continue;
                            }
                            if (!property.SupportsPrefabModifications)
                            {
                                continue;
                            }
                            if (!(property.ChildResolver is IKeyValueMapResolver))
                            {
                                continue;
                            }

                            tree.PrefabModificationHandler.RegisterPrefabDictionaryDeltaModification(property, 0);
                        }
                    }

                    InspectorUtilities.EndDrawPropertyTree(tree);

                    if (!isRepaint)
                    {
                        GUIHelper.PopEventType();
                    }

                    ISerializationCallbackReceiver receiver = (ISerializationCallbackReceiver)prefabInstance;
                    receiver.OnBeforeSerialize();
                    receiver.OnAfterDeserialize();
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }
            };

            foreach (SceneView scene in SceneView.sceneViews)
            {
                scene.Repaint();
            }
        }
Exemplo n.º 25
0
        private void UpdateEditors()
        {
            this.currentTargets = this.currentTargets ?? new object[] { };
            this.editors        = this.editors ?? new Editor[] { };
            this.propertyTrees  = this.propertyTrees ?? new PropertyTree[] { };

            IList <object> newTargets = this.GetTargets().ToArray() ?? new object[0];

            if (this.currentTargets.Length != newTargets.Count)
            {
                Array.Resize(ref this.currentTargets, newTargets.Count);
                Array.Resize(ref this.editors, newTargets.Count);
                Array.Resize(ref this.propertyTrees, newTargets.Count);
                this.Repaint();
            }

            for (int i = 0; i < newTargets.Count; i++)
            {
                var newTarget = newTargets[i];
                var curTarget = this.currentTargets[i];
                if (!object.ReferenceEquals(newTarget, curTarget))
                {
                    GUIHelper.RequestRepaint();
                    this.currentTargets[i] = newTarget;

                    if (newTarget == null)
                    {
                        this.propertyTrees[i] = null;
                        this.editors[i]       = null;
                    }
                    else
                    {
                        var editorWindow = newTarget as EditorWindow;
                        if (newTarget.GetType().InheritsFrom <UnityEngine.Object>() && !editorWindow)
                        {
                            var unityObject = newTarget as UnityEngine.Object;
                            if (unityObject)
                            {
                                this.propertyTrees[i] = null;
                                this.editors[i]       = Editor.CreateEditor(unityObject);
                                var materialEditor = this.editors[i] as MaterialEditor;
                                if (materialEditor != null)
                                {
                                    typeof(MaterialEditor).GetProperty("forceVisible", Flags.AllMembers).SetValue(materialEditor, true, null);
                                }
                            }
                            else
                            {
                                this.propertyTrees[i] = null;
                                this.editors[i]       = null;
                            }
                        }
                        else
                        {
                            this.editors[i]       = null;
                            this.propertyTrees[i] = PropertyTree.Create(newTarget);
                        }
                    }
                }
            }

            this.currentTargetsImm = new ImmutableList <object>(this.currentTargets);
        }
Exemplo n.º 26
0
        void FullScan(ScanType scanType)
        {
            Object prevSelected = this.selectedValidationInfo == null ? (Behaviour)null : this.selectedValidationInfo.Behaviour ?? (Object)this.selectedValidationInfo.Obj;

            var drawingConfig  = InspectorConfig.Instance.DrawingConfig;
            var odinEditorType = typeof(OdinEditor);

            switch (scanType)
            {
            case ScanType.Scene:
                this.validationInfos = Resources.FindObjectsOfTypeAll <Transform>()
                                       .Where(x => (x.gameObject.scene.IsValid() && (x.gameObject.hideFlags & HideFlags.HideInHierarchy) == 0))
                                       .Select(x => new { go = x.gameObject, components = x.GetComponents(typeof(Behaviour)) })
                                       .SelectMany(x => x.components.Select(c => new { go = x.go, component = c }))
                                       .Where(x => x.component == null || drawingConfig.GetEditorType(x.component.GetType()) == odinEditorType)
                                       .OrderBy(x => x.go.name)
                                       .ThenBy(x => x.component == null ? "" : x.component.name)
                                       .Select(x => new { tree = x.component == null ? (PropertyTree)null : PropertyTree.Create(new SerializedObject(x.component)), go = x.go })
                                       .Examine(x => { if (x.tree != null)
                                                       {
                                                           x.tree.UpdateTree();
                                                       }
                                                })
                                       .Where(x => x.tree == null || x.tree.RootPropertyCount != 0)
                                       .Select((x, i) => new BehaviourValidationInfo(x.tree, this, x.go))
                                       .Select(x => (IValidationInfo)x)
                                       .ToList();
                break;

            case ScanType.ScriptableObject:
                this.validationInfos = AssetDatabase.FindAssets("t:ScriptableObject")
                                       .Select(x => AssetDatabase.GUIDToAssetPath(x))
                                       .Select(x => AssetDatabase.LoadAssetAtPath <ScriptableObject>(x))
                                       .Where(x => x == null || drawingConfig.GetEditorType(x.GetType()) == odinEditorType)
                                       .OrderBy(x => x.name)
                                       .Select(x => x == null ? (PropertyTree)null : PropertyTree.Create(new SerializedObject(x)))
                                       .Examine(x => { if (x != null)
                                                       {
                                                           x.UpdateTree();
                                                       }
                                                })
                                       .Where(x => x == null || x.RootPropertyCount != 0)
                                       .Select((x, i) => new ScriptObjValidationInfo(x, this))
                                       .Select(x => (IValidationInfo)x)
                                       .ToList();
                break;

            case ScanType.Prefab:
                this.validationInfos = AssetDatabase.FindAssets("t:GameObject")
                                       .Select(x => AssetDatabase.GUIDToAssetPath(x))
                                       .Select(x => AssetDatabase.LoadAssetAtPath <GameObject>(x))
                                       // .Where(x => (x.gameObject.scene.IsValid() && (x.gameObject.hideFlags & HideFlags.HideInHierarchy) == 0))
                                       .Select(x => new { go = x.gameObject, components = x.GetComponents(typeof(Behaviour)) })
                                       .SelectMany(x => x.components.Select(c => new { go = x.go, component = c }))
                                       .Where(x => x.component == null || drawingConfig.GetEditorType(x.component.GetType()) == odinEditorType)
                                       .OrderBy(x => x.go.name)
                                       .ThenBy(x => x.component == null ? "" : x.component.name)
                                       .Select(x => new { tree = x.component == null ? (PropertyTree)null : PropertyTree.Create(new SerializedObject(x.component)), go = x.go })
                                       .Examine(x => { if (x.tree != null)
                                                       {
                                                           x.tree.UpdateTree();
                                                       }
                                                })
                                       .Where(x => x.tree == null || x.tree.RootPropertyCount != 0)
                                       .Select((x, i) => new BehaviourValidationInfo(x.tree, this, x.go))
                                       .Select(x => (IValidationInfo)x)
                                       .ToList();
                break;
            }

            if (prevSelected != null)
            {
                var prev = this.validationInfos.FirstOrDefault(x => x.Behaviour == prevSelected || x.Obj == prevSelected);
                if (prev != null)
                {
                    prev.Select();
                }
            }

            this.triggerScan = true;
        }
        // Token: 0x06000A26 RID: 2598 RVA: 0x00031018 File Offset: 0x0002F218
        public void Draw(bool drawCodeExample)
        {
            if (TrickOverViewPreview.exampleGroupStyle == null)
            {
                TrickOverViewPreview.exampleGroupStyle = new GUIStyle(GUIStyle.none)
                {
                    padding = new RectOffset(1, 1, 10, 0)
                };
            }
            if (TrickOverViewPreview.previewStyle == null)
            {
                TrickOverViewPreview.previewStyle = new GUIStyle(GUIStyle.none)
                {
                    padding = new RectOffset(0, 0, 0, 0)
                };
            }
            GUILayout.BeginVertical(TrickOverViewPreview.exampleGroupStyle, new GUILayoutOption[0]);
            GUILayout.Label("Preview:", SirenixGUIStyles.BoldTitle, new GUILayoutOption[0]);
            GUILayout.BeginVertical(TrickOverViewPreview.previewStyle, GUILayoutOptions.ExpandWidth(true));
            Rect rect = GUIHelper.GetCurrentLayoutRect().Expand(4f, 0f);

            SirenixEditorGUI.DrawSolidRect(rect, EditorGUIUtility.isProSkin ? TrickOverViewPreview.previewBackgroundColorDark : TrickOverViewPreview.previewBackgroundColorLight, true);
            SirenixEditorGUI.DrawBorders(rect, 1, true);
            GUILayout.Space(8f);

            m_DrawCallbaclAction.Invoke(rect);
            this.tree = (this.tree ?? PropertyTree.Create(this.ExampleInfo.PreviewObject));
            this.tree.Draw(false);

            GUILayout.Space(8f);
            GUILayout.EndVertical();
            if (drawCodeExample && this.ExampleInfo.Code != null)
            {
                GUILayout.Space(12f);
                GUILayout.Label("Code", SirenixGUIStyles.BoldTitle, new GUILayoutOption[0]);
                Rect rect2 = SirenixEditorGUI.BeginToolbarBox(new GUILayoutOption[0]);
                SirenixEditorGUI.DrawSolidRect(rect2.HorizontalPadding(1f), SyntaxHighlighter.BackgroundColor, true);
                SirenixEditorGUI.BeginToolbarBoxHeader(22f);
                if (SirenixEditorGUI.ToolbarButton(this.showRaw ? "Highlighted" : "Raw", false))
                {
                    this.showRaw = !this.showRaw;
                }
                GUILayout.FlexibleSpace();
                if (SirenixEditorGUI.ToolbarButton("Copy", false))
                {
                    Clipboard.Copy <string>(this.ExampleInfo.Code);
                }
                SirenixEditorGUI.EndToolbarBoxHeader();
                if (TrickOverViewPreview.codeTextStyle == null)
                {
                    TrickOverViewPreview.codeTextStyle = new GUIStyle(SirenixGUIStyles.MultiLineLabel);
                    TrickOverViewPreview.codeTextStyle.normal.textColor  = SyntaxHighlighter.TextColor;
                    TrickOverViewPreview.codeTextStyle.active.textColor  = SyntaxHighlighter.TextColor;
                    TrickOverViewPreview.codeTextStyle.focused.textColor = SyntaxHighlighter.TextColor;
                    TrickOverViewPreview.codeTextStyle.wordWrap          = false;
                }
                GUIContent content = GUIHelper.TempContent(this.showRaw ? this.ExampleInfo.Code.TrimEnd(new char[]
                {
                    '\n',
                    '\r'
                }) : this.highlightedCode);
                Vector2 vector = TrickOverViewPreview.codeTextStyle.CalcSize(content);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(-3f);
                GUILayout.BeginVertical(new GUILayoutOption[0]);
                GUIHelper.PushEventType((Event.current.type == EventType.ScrollWheel) ? EventType.Used : Event.current.type);
                this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition, true, false, GUI.skin.horizontalScrollbar, GUIStyle.none, new GUILayoutOption[]
                {
                    GUILayout.MinHeight(vector.y + 20f)
                });
                Rect rect3 = GUILayoutUtility.GetRect(vector.x + 50f, vector.y).AddXMin(4f).AddY(2f);
                if (this.showRaw)
                {
                    EditorGUI.SelectableLabel(rect3, this.ExampleInfo.Code, TrickOverViewPreview.codeTextStyle);
                    GUILayout.Space(-14f);
                }
                else
                {
                    GUI.Label(rect3, content, TrickOverViewPreview.codeTextStyle);
                }
                GUILayout.EndScrollView();
                GUIHelper.PopEventType();
                GUILayout.EndVertical();
                GUILayout.Space(-3f);
                GUILayout.EndHorizontal();
                GUILayout.Space(-3f);
                SirenixEditorGUI.EndToolbarBox();
            }
            GUILayout.EndVertical();
        }
Exemplo n.º 28
0
 public void OnAfterDeserialize()
 {
     tree = PropertyTree.Create(component);
     Debug.Log("after deserialize component");
 }
Exemplo n.º 29
0
        private void FullScan()
        {
            Object prevSelected = this.selectedValidationInfo == null ? (Behaviour)null : this.selectedValidationInfo.Behaviour ?? (Object)this.selectedValidationInfo.GameObject;

            var drawingConfig  = InspectorConfig.Instance.DrawingConfig;
            var odinEditorType = typeof(OdinEditor);

            this.behaviourValidationInfos = Resources.FindObjectsOfTypeAll <Transform>()
                                            .Where(x => (x.gameObject.scene.IsValid() && (x.gameObject.hideFlags & HideFlags.HideInHierarchy) == 0))
                                            .Select(x => new { go = x.gameObject, components = x.GetComponents(typeof(Behaviour)) })
                                            .SelectMany(x => x.components.Select(c => new { go = x.go, component = c }))
                                            .Where(x => x.component == null || drawingConfig.GetEditorType(x.component.GetType()) == odinEditorType)
                                            .OrderBy(x => x.go.name)
                                            .ThenBy(x => x.component == null ? "" : x.component.name)
                                            .Select(x => new { tree = x.component == null ? (PropertyTree)null : PropertyTree.Create(new SerializedObject(x.component)), go = x.go })
                                            .Examine(x => { if (x.tree != null)
                                                            {
                                                                x.tree.UpdateTree();
                                                            }
                                                     })
                                            .Where(x => x.tree == null || x.tree.RootPropertyCount != 0)
                                            .Select((x, i) => new BehaviourValidationInfo(x.tree, this, x.go))
                                            .ToList();

            if (prevSelected != null)
            {
                var prev = this.behaviourValidationInfos.FirstOrDefault(x => x.Behaviour == prevSelected || x.GameObject == prevSelected);
                if (prev != null)
                {
                    prev.Select();
                }
            }

            this.triggerScan = true;
        }
Exemplo n.º 30
0
        /// <summary>
        /// Draws the property.
        /// </summary>
        protected override void DrawPropertyLayout(GUIContent label)
        {
            var property  = this.Property;
            var entry     = this.ValueEntry;
            var attribute = this.Attribute;

            var assetList    = property.Context.Get(this, "assetList", (AssetList)null);
            var propertyTree = property.Context.Get(this, "togglableAssetListPropertyTree", (PropertyTree)null);

            if (property.ValueEntry.WeakSmartValue == null)
            {
                return;
            }

            if (assetList.Value == null)
            {
                assetList.Value = new AssetList();
                assetList.Value.AutoPopulate    = attribute.AutoPopulate;
                assetList.Value.AssetNamePrefix = attribute.AssetNamePrefix;
                assetList.Value.Tags            = attribute.Tags != null?attribute.Tags.Trim().Split(',').Select(i => i.Trim()).ToArray() : null;

                assetList.Value.LayerNames = attribute.LayerNames != null?attribute.LayerNames.Trim().Split(',').Select(i => i.Trim()).ToArray() : null;

                assetList.Value.List = entry;
                assetList.Value.CollectionResolver = property.ChildResolver as IOrderedCollectionResolver;
                assetList.Value.Property           = entry.Property;

                if (attribute.Path != null)
                {
                    var path = attribute.Path.TrimStart('/', ' ').TrimEnd('/', ' ');
                    path = attribute.Path.Trim('/', ' ');

                    path = "Assets/" + path + "/";
                    path = Application.dataPath + "/" + path;

                    assetList.Value.AssetsFolderLocation = new DirectoryInfo(path);

                    path = attribute.Path.Trim('/', ' ');
                    assetList.Value.PrettyPath = "/" + path.TrimStart('/');
                }

                if (attribute.CustomFilterMethod != null)
                {
                    MethodInfo methodInfo;
                    string     error;
                    if (MemberFinder.Start(entry.ParentType)
                        .IsMethod()
                        .IsNamed(attribute.CustomFilterMethod)
                        .HasReturnType <bool>()
                        .HasParameters <TElement>()
                        .TryGetMember <MethodInfo>(out methodInfo, out error))
                    {
                        if (methodInfo.IsStatic)
                        {
                            assetList.Value.StaticCustomIncludeMethod = (Func <TElement, bool>)Delegate.CreateDelegate(typeof(Func <TElement, bool>), methodInfo, true);
                        }
                        else
                        {
                            assetList.Value.InstanceCustomIncludeMethod = EmitUtilities.CreateWeakInstanceMethodCaller <bool, TElement>(methodInfo);
                        }
                    }

                    assetList.Value.ErrorMessage = error;
                }

                // We can get away with lag on load.
                assetList.Value.MaxSearchDurationPrFrameInMS = 20;
                assetList.Value.EnsureListPopulation();
                assetList.Value.MaxSearchDurationPrFrameInMS = 1;

                //assetList.Value.List = list;

                //if (propertyTree.Value == null)
                //{
                propertyTree.Value = PropertyTree.Create(assetList.Value);
                propertyTree.Value.UpdateTree();
                propertyTree.Value.GetRootProperty(0).Label = label;
                //}
            }
            else if (Event.current.type == EventType.Layout)
            {
                assetList.Value.Property = entry.Property;
                assetList.Value.EnsureListPopulation();
                assetList.Value.SetToggleValues();
            }

            if (assetList.Value.ErrorMessage != null)
            {
                SirenixEditorGUI.ErrorMessageBox(assetList.Value.ErrorMessage);
            }
            assetList.Value.Property = entry.Property;
            propertyTree.Value.Draw(false);

            if (Event.current.type == EventType.Used)
            {
                assetList.Value.UpdateList();
            }
        }