Esempio n. 1
0
        public bool TryLoadProperty(ulong documentKey, string propertyName, out PropertyDatabaseRecordKey recordKey, out object value, out string alias)
        {
            var propertyHash = PropertyDatabase.CreatePropertyHash(propertyName);

            recordKey = PropertyDatabase.CreateRecordKey(documentKey, propertyHash);
            if (!propertyAliasesView.TryLoad(recordKey, out object aliasObj))
            {
                value = null;
                alias = propertyName;
                SearchMonitor.Log($"<color=red>Failed</color> to load {propertyName} without alias", recordKey, propertyName);
                return(false);
            }

            alias = (aliasObj as string) ?? propertyName;
            if (propertyDatabaseView.TryLoad(recordKey, out value))
            {
                SearchMonitor.Log($"Load property {propertyName}", recordKey, value);
                return(true);
            }

            SearchMonitor.Log($"<color=red>Failed</color> to load property {propertyName}", recordKey, propertyName);
            return(false);
        }
Esempio n. 2
0
        public static SerializedProperty FindProperty(UnityEngine.Object obj, string propertyPath, out SerializedObject so)
        {
            if (!obj)
            {
                so = null;
                return(null);
            }

            so = new SerializedObject(obj);
            var property = so.FindProperty(propertyPath);

            if (property != null)
            {
                return(property);
            }

            #if USE_PROPERTY_DATABASE
            using (var view = SearchMonitor.GetView())
            #endif
            {
                #if USE_PROPERTY_DATABASE
                var unresolvedPropertyPath = $"{obj.GetType().Name}.{propertyPath}";
                var propertyPathRecordKey  = PropertyDatabase.CreateRecordKey(obj.GetType().Name, unresolvedPropertyPath);
                if (view.TryLoadAlias(propertyPathRecordKey, out var resolvedPropertyPath))
                {
                    if (string.IsNullOrEmpty(resolvedPropertyPath))
                    {
                        so?.Dispose();
                        return(null);
                    }

                    var resolvedProperty = so.FindProperty(resolvedPropertyPath);
                    if (resolvedProperty != null)
                    {
                        return(resolvedProperty);
                    }
                }
                #endif

                property = so.FindProperty($"m_{propertyPath}");
                if (property != null)
                {
                    #if USE_PROPERTY_DATABASE
                    view.StoreAlias(propertyPathRecordKey, property.propertyPath);
                    #endif
                    return(property);
                }

                property = so.GetIterator();
                var next = property.NextVisible(true);
                while (next)
                {
                    if (property.name.EndsWith(propertyPath, StringComparison.OrdinalIgnoreCase))
                    {
                        #if USE_PROPERTY_DATABASE
                        view.StoreAlias(propertyPathRecordKey, property.propertyPath);
                        #endif
                        return(property);
                    }
                    next = property.NextVisible(property.hasChildren);
                }

                #if USE_PROPERTY_DATABASE
                view.StoreAlias(propertyPathRecordKey, string.Empty);
                #endif
                so?.Dispose();
                so = null;
                return(null);
            }
        }
 public PropertyDatabaseRecordKey CreateRecordKey(Hash128 propertyHash)
 {
     return(PropertyDatabase.CreateRecordKey(propertyHash));
 }
 public PropertyDatabaseRecordKey CreateRecordKey(string documentId, Hash128 propertyHash)
 {
     return(PropertyDatabase.CreateRecordKey(documentId, propertyHash));
 }
 public PropertyDatabaseRecordKey CreateRecordKey(string propertyPath)
 {
     return(PropertyDatabase.CreateRecordKey(propertyPath));
 }
 public PropertyDatabaseRecordKey CreateRecordKey(ulong documentKey, Hash128 propertyPathHash)
 {
     return(PropertyDatabase.CreateRecordKey(documentKey, propertyPathHash));
 }
 public PropertyDatabaseRecordKey CreateRecordKey(string documentId, string propertyPath)
 {
     return(PropertyDatabase.CreateRecordKey(documentId, propertyPath));
 }