public void Remove(UnityEngine.Object obj)
        {
            activeObjects.Remove(obj);
            var gid = GlobalObjectId.GetGlobalObjectIdSlow(obj);

            globalObjectIdSet.Remove(gid);
        }
Exemplo n.º 2
0
        private void IndexSubAsset(Object subObj, string containerPath, bool checkIfDocumentExists, bool hasCustomIndexers)
        {
            var gid                 = GlobalObjectId.GetGlobalObjectIdSlow(subObj);
            var id                  = gid.ToString();
            var containerName       = Path.GetFileNameWithoutExtension(containerPath);
            var objPathName         = Utils.RemoveInvalidCharsFromPath($"{containerName}/{subObj.name}", ' ');
            var subObjDocumentIndex = AddDocument(id, objPathName, containerPath, checkIfDocumentExists, SearchDocumentFlags.Nested | SearchDocumentFlags.Asset);

            IndexTypes(subObj.GetType(), subObjDocumentIndex);
            IndexProperty(subObjDocumentIndex, "is", "nested", saveKeyword: true, exact: true);
            IndexProperty(subObjDocumentIndex, "is", "subasset", saveKeyword: true, exact: true);
            if (settings.options.dependencies)
            {
                AddProperty("ref", containerPath.ToLowerInvariant(), subObjDocumentIndex);
            }

            if (hasCustomIndexers)
            {
                IndexCustomProperties(id, subObjDocumentIndex, subObj);
            }

            IndexWordComponents(subObjDocumentIndex, subObj.name);
            if (settings.options.properties)
            {
                IndexObject(subObjDocumentIndex, subObj, settings.options.dependencies);
            }
        }
        internal void ConvertGlobalObjectIdsToSceneObjects()
        {
            activeObjects.Clear();
            var gids          = globalObjectIdSet.ToArray();
            var outputObjects = new UnityEngine.Object[gids.Length];

            GlobalObjectId.GlobalObjectIdentifiersToObjectsSlow(gids, outputObjects);
            for (var i = 0; i < outputObjects.Length; i++)
            {
                var obj = outputObjects[i];
                //Debug.Log($"GID: {gids[i]}, OBJ: {obj} -> GUID: {GlobalObjectId.GetGlobalObjectIdSlow(obj)}");
                //Sometimes invalid objects are returned. https://fogbugz.unity3d.com/f/cases/1291291/
                //This is the workaround.
                if (obj != null)
                {
                    //if(gids[i] == GlobalObjectId.GetGlobalObjectIdSlow(obj))
                    var x = gids[i];
                    var y = GlobalObjectId.GetGlobalObjectIdSlow(obj);
                    if (y.identifierType == x.identifierType && y.targetObjectId == x.targetObjectId && y.targetPrefabId == x.targetPrefabId && y.assetGUID == x.assetGUID)
                    {
                        activeObjects.Add(obj);
                    }
                }
            }
        }
Exemplo n.º 4
0
        internal static IBuildStep Deserialize(string json)
        {
            if (string.IsNullOrEmpty(json))
            {
                return(null);
            }

            if (GlobalObjectId.TryParse(json, out var id))
            {
                if (GlobalObjectId.GlobalObjectIdentifierToObjectSlow(id) is BuildPipeline pipeline)
                {
                    return(pipeline);
                }
            }
            else
            {
                var type = Type.GetType(json);
                if (TypeConstruction.TryConstruct <IBuildStep>(type, out var step))
                {
                    return(step);
                }
            }

            return(null);
        }
        public object Deserialize(SerializedValueView view)
        {
            var json = view.ToString();

            if (string.IsNullOrEmpty(json))
            {
                return(null);
            }

            if (GlobalObjectId.TryParse(json, out var id))
            {
                if (GlobalObjectId.GlobalObjectIdentifierToObjectSlow(id) is BuildPipeline pipeline)
                {
                    return(pipeline);
                }
            }
            else
            {
                if (TypeConstructionHelper.TryConstructFromAssemblyQualifiedTypeName <IBuildStep>(json, out var step))
                {
                    return(step);
                }
            }
            return(null);
        }
Exemplo n.º 6
0
        private static bool IsMatchForMeetingResponse(GlobalObjectId globalObjectId, ExDateTime ownerCriticalTime, int sequenceNumber, IStorePropertyBag potentialSelection)
        {
            object obj = potentialSelection.TryGetProperty(InternalSchema.AppointmentSequenceNumber);

            byte[] array = potentialSelection.TryGetProperty(CalendarItemBaseSchema.GlobalObjectId) as byte[];
            if (!(obj is int) || array == null)
            {
                return(false);
            }
            int num = (int)obj;

            if (num != sequenceNumber)
            {
                return(false);
            }
            GlobalObjectId globalObjectId2 = new GlobalObjectId(array);

            if (globalObjectId2.Date != ExDateTime.MinValue && globalObjectId2.Date != globalObjectId.Date)
            {
                return(false);
            }
            object obj2 = potentialSelection.TryGetProperty(CalendarItemBaseSchema.OwnerCriticalChangeTime);

            return(!(globalObjectId2.Date != ExDateTime.MinValue) || (obj2 is ExDateTime && ExDateTime.Compare(ownerCriticalTime, (ExDateTime)obj2, AggregationByItemClassReferencesSubjectProcessor.OwnerCriticalTimeTreshold) == 0));
        }
Exemplo n.º 7
0
            internal object TryConvert()
            {
                switch (type)
                {
                case ExportedType.Bool:
                    bool.TryParse(data, out var resultBool);
                    return(resultBool);

                case ExportedType.Number:
                    double.TryParse(data, out var resultDouble);
                    return(resultDouble);

                case ExportedType.String:
                    return(data);

                case ExportedType.ObjectReference:
                    var parts = data.Split(';');
                    if (parts.Length != 2)
                    {
                        return(null);
                    }
                    if (GlobalObjectId.TryParse(parts[0], out var id))
                    {
                        return(new ObjectValue(GlobalObjectId.GlobalObjectIdentifierToObjectSlow(id), parts[1]));
                    }
                    return(data);

                case ExportedType.Color:
                    ColorUtility.TryParseHtmlString(data, out var resultColor);
                    return(resultColor);
                }
                return(null);
            }
        static unsafe NativeList <RuntimeGlobalObjectId> ReferencedUnityObjectsToRuntimeGlobalObjectIds(ReferencedUnityObjects referencedUnityObjects, Allocator allocator = Allocator.Temp)
        {
            var globalObjectIds     = new GlobalObjectId[referencedUnityObjects.Array.Length];
            var runtimeGlobalObjIDs = new NativeList <RuntimeGlobalObjectId>(globalObjectIds.Length, allocator);

            GlobalObjectId.GetGlobalObjectIdsSlow(referencedUnityObjects.Array, globalObjectIds);

            for (int i = 0; i != globalObjectIds.Length; i++)
            {
                var globalObjectId = globalObjectIds[i];

                //@TODO: HACK (Object is a scene object)
                if (globalObjectId.identifierType == 2)
                {
                    Debug.LogWarning($"{referencedUnityObjects.Array[i]} is part of a scene, LiveLink can't transfer scene objects. (Note: LiveConvertSceneView currently triggers this)");
                    continue;
                }

                if (globalObjectId.assetGUID == new GUID())
                {
                    //@TODO: How do we handle this
                    Debug.LogWarning($"{referencedUnityObjects.Array[i]} has no valid GUID. LiveLink currently does not support built-in assets.");
                    continue;
                }

                var runtimeGlobalObjectId =
                    System.Runtime.CompilerServices.Unsafe.AsRef <RuntimeGlobalObjectId>(&globalObjectId);
                runtimeGlobalObjIDs.Add(runtimeGlobalObjectId);
            }

            return(runtimeGlobalObjIDs);
        }
Exemplo n.º 9
0
        public void ClassWithGlobalObjectId_CanBeSerializedAndDeserialized()
        {
            var image = new Texture2D(1, 1);

            AssetDatabase.CreateAsset(image, kTexture2DPath);
            AssetDatabase.ImportAsset(kTexture2DPath, ImportAssetOptions.ForceSynchronousImport | ImportAssetOptions.ForceUpdate);

            try
            {
                var src = new ClassWithGlobalObjectId
                {
                    GlobalObjectId = GlobalObjectId.GetGlobalObjectIdSlow(image),
                    Guid           = GUID.Generate()
                };

                var dst = SerializeAndDeserialize(src);

                Assert.That(dst, Is.Not.SameAs(src));
                Assert.That(dst.GlobalObjectId, Is.EqualTo(src.GlobalObjectId));
                Assert.That(dst.Guid, Is.EqualTo(src.Guid));
            }
            finally
            {
                AssetDatabase.DeleteAsset(kTexture2DPath);
            }
        }
 public void FromPropertyValues(IDictionary <Microsoft.Exchange.Data.PropertyDefinition, int> propertyIndices, IList values, IEvent right)
 {
     SeriesIdTranslationRule.FromLeftToRight(right, delegate(out string value)
     {
         int index;
         object obj;
         if (propertyIndices.TryGetValue(SeriesIdTranslationRule.CalendarItemTypeProperty, out index) && (obj = values[index]) is CalendarItemType)
         {
             if ((CalendarItemType)obj == CalendarItemType.Single)
             {
                 if (propertyIndices.TryGetValue(SeriesIdTranslationRule.NprSeriesId, out index) && values[index] is string)
                 {
                     value = (string)values[index];
                     return(true);
                 }
             }
             else if (propertyIndices.TryGetValue(SeriesIdTranslationRule.CleanGlobalObjectId, out index) && values[index] is byte[])
             {
                 value = new GlobalObjectId((byte[])values[index]).ToString();
                 return(true);
             }
         }
         value = null;
         return(false);
     });
 }
        internal GlobalObjectId[] GetGlobalObjectIds(IList <Object> objects)
        {
            var gids = new GlobalObjectId[objects.Count];

            GlobalObjectId.GetGlobalObjectIdsSlow(objects.ToArray(), gids);
            return(gids);
        }
Exemplo n.º 12
0
        private static Object ToObject(SearchItem item, Type type)
        {
            if (!GlobalObjectId.TryParse(item.id, out var gid))
            {
                return(null);
            }

            var obj = GlobalObjectId.GlobalObjectIdentifierToObjectSlow(gid);

            if (obj)
            {
                if (type == null)
                {
                    return(obj);
                }
                var objType = obj.GetType();
                if (objType == type || objType.IsSubclassOf(type))
                {
                    return(obj);
                }

                if (obj is GameObject go)
                {
                    return(go.GetComponent(type));
                }
            }

            var assetPath = AssetDatabase.GUIDToAssetPath(gid.assetGUID.ToString());

            return(AssetDatabase.LoadMainAssetAtPath(assetPath));
        }
Exemplo n.º 13
0
        private static ulong GetId(Object obj)
        {
            if (obj != null)
            {
#if UNITY_2019_2_OR_NEWER
                var guid = GlobalObjectId.GetGlobalObjectIdSlow(obj);
                var id   = guid.targetObjectId;

                return(id);
#else
                var inspectorModeInfo =
                    typeof(SerializedObject).GetProperty(INSPECTOR_MODE,
                                                         BindingFlags.NonPublic | BindingFlags.Instance);

                var serializedObject = new SerializedObject(obj);
                inspectorModeInfo?.SetValue(serializedObject, InspectorMode.Debug, null);

                var
                    localIdProp = serializedObject.FindProperty(LOCAL_IDENTIFIER);

                var localId = localIdProp.longValue;
                if (localId <= 0)
                {
#if UNITY_2018_3_OR_NEWER
                    var prefabType = PrefabUtility.GetPrefabAssetType(obj);
                    if (prefabType != PrefabAssetType.NotAPrefab)
                    {
                        var prefab = PrefabUtility.GetPrefabInstanceHandle(obj);
#else
                    var prefabType = PrefabUtility.GetPrefabType(obj);
                    if (prefabType != PrefabType.None)
                    {
                        var prefab = PrefabUtility.GetPrefabParent(obj);
#endif
                        return(GetId(prefab));
                    }

                    var sceneDirty = false;
                    if (obj as GameObject != null)
                    {
                        sceneDirty = ((GameObject)obj).scene.isDirty;
                    }
                    else if ((obj as MonoBehaviour)?.gameObject != null)
                    {
                        sceneDirty = ((MonoBehaviour)obj).gameObject.scene.isDirty;
                    }

                    if (sceneDirty && localId == 0)
                    {
                        localId = obj.GetInstanceID();
                    }
                }

                return((ulong)localId);
#endif
            }

            return(0);
        }
 public override void OnClicked(int index)
 {
     if (GlobalObjectId.TryParse(guids[index], out var gid))
     {
         var containerPath = AssetDatabase.GUIDToAssetPath(gid.assetGUID);
         EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath <Object>(containerPath));
     }
 }
Exemplo n.º 15
0
 // Token: 0x060015FE RID: 5630 RVA: 0x0007B63C File Offset: 0x0007983C
 public ReminderLogEvent(ReminderLogEventType eventType, string objectClass, GlobalObjectId reminderItemId, Guid reminderId, ICollection <KeyValuePair <string, object> > additional = null)
 {
     this.eventType      = eventType;
     this.objectClass    = objectClass;
     this.reminderItemId = reminderItemId;
     this.reminderId     = reminderId;
     this.additional     = additional;
 }
Exemplo n.º 16
0
 private GlobalObjectId MakeCleanId(GlobalObjectId globalObjectId)
 {
     if (!globalObjectId.IsCleanGlobalObjectId)
     {
         return(new GlobalObjectId(globalObjectId.CleanGlobalObjectIdBytes));
     }
     return(globalObjectId);
 }
 public static SceneObjectIdentifier FromGlobalObjectId(GlobalObjectId id)
 {
     return(new SceneObjectIdentifier
     {
         targetObject = id.targetObjectId,
         targetPrefab = id.targetPrefabId
     });
 }
Exemplo n.º 18
0
        public static ObjectID GetFor(Object o)
        {
            var goid     = GlobalObjectId.GetGlobalObjectIdSlow(o);
            var id       = goid.targetObjectId;
            var prefabId = goid.targetPrefabId;

            return(new ObjectID(id, prefabId));
        }
Exemplo n.º 19
0
 private string ToPath(SearchItem item)
 {
     if (GlobalObjectId.TryParse(item.id, out var gid))
     {
         return(AssetDatabase.GUIDToAssetPath(gid.assetGUID));
     }
     return(item.id);
 }
Exemplo n.º 20
0
 private string GetCleanGoidKey(byte[] cleanGoid)
 {
     if (cleanGoid != null)
     {
         return(GlobalObjectId.ByteArrayToHexString(cleanGoid));
     }
     return(string.Empty);
 }
Exemplo n.º 21
0
 internal static string ExtractDataValue(object data, out ExportedType type, bool convertForCSV = false)
 {
     if (data == null)
     {
         type = ExportedType.None;
         return(string.Empty);
     }
     else if (data is UnityEngine.Object o)
     {
         type = ExportedType.ObjectReference;
         string objectToString = o.name;
         if (string.IsNullOrEmpty(o.name))
         {
             objectToString = AssetDatabase.GetAssetPath(o);
             if (string.IsNullOrEmpty(objectToString))
             {
                 objectToString = o.GetType().ToString();
             }
         }
         if (convertForCSV)
         {
             return(o.ToString());
         }
         else
         {
             return($"{GlobalObjectId.GetGlobalObjectIdSlow(o).ToString()};{objectToString}");
         }
     }
     else if (data is SerializedProperty sp)
     {
         return(ExtractDataValue(PropertySelectors.GetSerializedPropertyValue(sp), out type));
     }
     else if (data is MaterialProperty mp)
     {
         return(ExtractDataValue(MaterialSelectors.GetMaterialPropertyValue(mp), out type));
     }
     else if (data is Color color)
     {
         type = ExportedType.Color;
         return('#' + ColorUtility.ToHtmlStringRGBA(color));
     }
     else
     {
         if (data is bool)
         {
             type = ExportedType.Bool;
         }
         else if (Utils.TryGetNumber(data, out var number))
         {
             type = ExportedType.Number;
         }
         else
         {
             type = ExportedType.String;
         }
         return(data.ToString());
     }
 }
Exemplo n.º 22
0
        // Token: 0x060010F3 RID: 4339 RVA: 0x00046BD0 File Offset: 0x00044DD0
        private SyncCalendarItemType GetTypedItem(PropertyDefinition[] xsoRequiredProperties, object[] itemRow, out ExDateTime itemStart)
        {
            itemStart = ExDateTime.MinValue;
            StoreId          itemId           = null;
            string           uid              = null;
            CalendarItemType calendarItemType = CalendarItemType.Single;
            ExDateTime?      startWallClock   = null;
            ExDateTime?      end              = null;
            ExDateTime?      endWallClock     = null;
            Dictionary <PropertyDefinition, object> dictionary = new Dictionary <PropertyDefinition, object>(itemRow.Length);

            for (int i = 0; i < xsoRequiredProperties.Length; i++)
            {
                if (!(itemRow[i] is PropertyError) && !dictionary.ContainsKey(xsoRequiredProperties[i]))
                {
                    if (xsoRequiredProperties[i] == CalendarItemInstanceSchema.StartTime)
                    {
                        itemStart = (ExDateTime)itemRow[i];
                    }
                    else if (xsoRequiredProperties[i] == CalendarItemInstanceSchema.StartWallClock)
                    {
                        startWallClock = new ExDateTime?((ExDateTime)itemRow[i]);
                    }
                    else if (xsoRequiredProperties[i] == CalendarItemInstanceSchema.EndTime)
                    {
                        end = new ExDateTime?((ExDateTime)itemRow[i]);
                    }
                    else if (xsoRequiredProperties[i] == CalendarItemInstanceSchema.EndWallClock)
                    {
                        endWallClock = new ExDateTime?((ExDateTime)itemRow[i]);
                    }
                    else if (xsoRequiredProperties[i] == ItemSchema.Id)
                    {
                        itemId = (VersionedId)itemRow[i];
                    }
                    else if (xsoRequiredProperties[i] == CalendarItemBaseSchema.CalendarItemType)
                    {
                        calendarItemType = (CalendarItemType)itemRow[i];
                    }
                    else if (xsoRequiredProperties[i] == CalendarItemBaseSchema.GlobalObjectId)
                    {
                        uid = new GlobalObjectId((byte[])itemRow[i]).Uid;
                    }
                    dictionary.Add(xsoRequiredProperties[i], itemRow[i]);
                }
            }
            return(new SyncCalendarItemType
            {
                ItemId = itemId,
                UID = uid,
                CalendarItemType = calendarItemType,
                Start = new ExDateTime?(itemStart),
                StartWallClock = startWallClock,
                End = end,
                EndWallClock = endWallClock,
                RowData = dictionary
            });
        }
Exemplo n.º 23
0
    static string GetKey(GameObject gameObject, string label)
    {
        if (!st_current._keyDictionary.ContainsKey(gameObject))
        {
            st_current._keyDictionary.Add(gameObject, GlobalObjectId.GetGlobalObjectIdSlow(gameObject).ToString());
        }

        return($"{gameObject.name}_{label}_{st_current._keyDictionary[gameObject]}");
    }
 public TransitionalClientIntentQuery(GlobalObjectId globalObjectId, ICalendarItemStateDefinition initialState, ICalendarItemStateDefinition targetState) : base(globalObjectId, targetState)
 {
     Util.ThrowOnNullArgument(initialState, "initialState");
     if (!initialState.SchemaKey.Equals(targetState.SchemaKey))
     {
         throw new ArgumentException(string.Format("Cannot query client intent for a transition between heterogeneous states (Initial: {0}; Target: {1}).", initialState.SchemaKey, targetState.SchemaKey));
     }
     this.InitialState = initialState;
 }
Exemplo n.º 25
0
        public void Deserialize_PipelineAsBuildStep_IsValid()
        {
            var assetPath  = $"Assets/TestBuildPipeline{BuildPipeline.AssetExtension}";
            var pipeline   = BuildPipeline.CreateAsset(assetPath);
            var pipelineId = GlobalObjectId.GetGlobalObjectIdSlow(pipeline);

            Assert.That(BuildStep.Deserialize(pipelineId.ToString()), Is.EqualTo(pipeline));
            AssetDatabase.DeleteAsset(assetPath);
        }
        private static SceneList.SceneInfo GetSceneInfo(string path)
        {
            var sceneAsset = AssetDatabase.LoadAssetAtPath <SceneAsset>(path);

            return(new SceneList.SceneInfo()
            {
                AutoLoad = true, Scene = GlobalObjectId.GetGlobalObjectIdSlow(sceneAsset)
            });
        }
Exemplo n.º 27
0
        private bool HasSentUpdateForItem(GlobalObjectId goid, UserObject attendee, Dictionary <GlobalObjectId, List <Attendee> > organizerRumsSent)
        {
            bool result = false;

            if (organizerRumsSent.ContainsKey(goid) && RumAgent.Instance.AttendeeListContainsParticipant(organizerRumsSent[goid], attendee.Participant))
            {
                result = true;
            }
            return(result);
        }
Exemplo n.º 28
0
        private static Texture2D FetchThumbnail(SearchItem item)
        {
            if (!GlobalObjectId.TryParse(item.id, out var gid))
            {
                return(null);
            }
            var sourceAssetPath = AssetDatabase.GUIDToAssetPath(gid.assetGUID.ToString());

            return(AssetDatabase.GetCachedIcon(sourceAssetPath) as Texture2D);
        }
Exemplo n.º 29
0
        static string GetBuildConfigurationName(BuildConfiguration config)
        {
            var name = config.name;

            if (string.IsNullOrEmpty(name))
            {
                name = GlobalObjectId.GetGlobalObjectIdSlow(config).ToString();
            }
            return(name);
        }
Exemplo n.º 30
0
        private static Texture2D FetchThumbnail(SearchItem item)
        {
            if (!GlobalObjectId.TryParse(item.id, out var gid))
            {
                return(null);
            }
            var sourceAssetPath = AssetDatabase.GUIDToAssetPath(gid.assetGUID.ToString());

            return(Utils.GetAssetPreviewFromPath(sourceAssetPath, k_PreviewSize, FetchPreviewOptions.Preview2D));
        }