コード例 #1
0
        public void ConsumeGameObject(GameObjectHierarchyElement gameObject, TransformHierarchyElement transformHierarchyElement, ModificationHierarchyElement modifications)
        {
            string name = null;

            if (modifications != null)
            {
                name = modifications.GetName(new FileID(null, gameObject.Id.fileID));
            }
            if (name == null)
            {
                name = gameObject.Name;
            }

            if (name?.Equals(string.Empty) == true)
            {
                name = null;
            }

            myParts.Push(name ?? "...");

            int?rootOrder = null;

            if (modifications != null)
            {
                rootOrder = modifications.GetRootIndex(transformHierarchyElement.Id.WithGuid(null));
            }

            if (rootOrder == null)
            {
                rootOrder = transformHierarchyElement.RootOrder;
            }

            myIndex.Push(rootOrder ?? 0);
        }
コード例 #2
0
 private static void Write(UnsafeWriter writer, TransformHierarchyElement value)
 {
     value.Id.WriteTo(writer);
     value.CorrespondingSourceObject.WriteTo(writer);
     value.PrefabInstance.WriteTo(writer);
     writer.Write(value.IsStripped);
     writer.Write(value.RootOrder);
     value.GameObject.WriteTo(writer);
     value.Father.WriteTo(writer);
 }
コード例 #3
0
        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));
            }
        }
コード例 #4
0
 protected bool Equals(TransformHierarchyElement other)
 {
     return(Id.Equals(other.Id));
 }