Example #1
0
 private static void Write(UnsafeWriter writer, ComponentHierarchyElement value)
 {
     value.Id.WriteTo(writer);
     value.CorrespondingSourceObject.WriteTo(writer);
     value.PrefabInstance.WriteTo(writer);
     value.GameObject.WriteTo(writer);
     writer.Write(value.IsStripped);
 }
        public void AddSceneHierarchyElement(Dictionary <string, string> simpleValues, Dictionary <string, FileID> referenceValues)
        {
            var anchor = simpleValues.GetValueSafe("&anchor");

            if (string.IsNullOrEmpty(anchor))
            {
                return;
            }


            var id = new FileID(null, anchor);

            if (Elements.ContainsKey(id))
            {
                ourLogger.Verbose($"Id = {anchor.Substring(0, Math.Min(anchor.Length, 100))} is defined several times for different documents");
            }

            var  correspondingId  = GetCorrespondingSourceObjectId(referenceValues);
            var  prefabInstanceId = GetPrefabInstanceId(referenceValues);
            bool isStripped       = simpleValues.ContainsKey("stripped");

            if (referenceValues.ContainsKey(UnityYamlConstants.FatherProperty))
            {
                // transform component
                var rootOrder = int.TryParse(simpleValues.GetValueSafe(UnityYamlConstants.RootOrderProperty), out var r)
                    ? r
                    : -1;

                var gameObject = referenceValues.GetValueSafe(UnityYamlConstants.GameObjectProperty);
                var father     = referenceValues.GetValueSafe(UnityYamlConstants.FatherProperty);

                Elements[id] = new TransformHierarchyElement(id, correspondingId, prefabInstanceId, isStripped, rootOrder, gameObject, father);

                if (Elements.TryGetValue(gameObject, out var element))
                {
                    var goElement = (element as GameObjectHierarchyElement).NotNull("goElement != null");
                    goElement.TransformId = id;
                }
                else
                {
                    myGameObjectsTransforms[gameObject] = id;
                }
            }
            else if (referenceValues.ContainsKey(UnityYamlConstants.GameObjectProperty))
            {
                // component
                var gameObject = referenceValues.GetValueSafe(UnityYamlConstants.GameObjectProperty);
                Elements[id] = new ComponentHierarchyElement(id, correspondingId, prefabInstanceId, gameObject, isStripped);
            }
            else
            {
                // gameobject
                var transformId = myGameObjectsTransforms.GetValueSafe(id);
                if (transformId != null)
                {
                    myGameObjectsTransforms.Remove(transformId);
                }

                Elements[id] = new GameObjectHierarchyElement(id, correspondingId, prefabInstanceId, isStripped, transformId,
                                                              simpleValues.GetValueSafe(UnityYamlConstants.NameProperty));
            }
        }
Example #3
0
 protected bool Equals(ComponentHierarchyElement other)
 {
     return(Id.Equals(other.Id));
 }