Esempio n. 1
0
        private void FindTargetProperties(RuntimeSerializedProperty property)
        {
            listDataDict.Clear();
            editableDict.Clear();

            var depth = property.Depth;

            do
            {
                if (property.IsArray && property.PropertyType != RuntimeSerializedPropertyType.String)
                {
                    var canTurnToList = property.HasAttribute <ReorderableAttribute>();
                    if (canTurnToList)
                    {
                        CreateListData(property.RuntimeSerializedObject.FindProperty(property.PropertyPath));
                    }
                }

                if (property.PropertyType.IsSubclassOf(RuntimeSerializedPropertyType.Object))
                {
                    var propType = property.GetTypeReflection();
                    if (propType == null)
                    {
                        continue;
                    }
                    var isScriptable = propType.IsSubclassOf(scriptableObjectType);
                    if (isScriptable)
                    {
                        var makeEditable = property.HasAttribute <ReorderableAttribute>();
                        if (makeEditable)
                        {
                            UnityEditor.Editor scriptableEditor = null;
                            if (property.ObjectReference != null)
                            {
                                UnityEditor.Editor.CreateCachedEditorWithContext(property.ObjectReference,
                                                                                 property.RuntimeSerializedObject.TargetObject, null,
                                                                                 ref scriptableEditor);
                            }
                            editableDict.Add(property.PropertyPath, scriptableEditor);
                        }
                    }
                }
            } while (property.Depth < depth && property.NextVisible(true));

            isInitialized = true;
        }