Beispiel #1
0
        private static void FillProperties(Dictionary <string, string> simpleValues, Dictionary <string, FileID> referenceValues,
                                           OneToListMap <MonoBehaviourProperty, MonoBehaviourPropertyValue> result)
        {
            var anchor = simpleValues.GetValueSafe("&anchor");

            if (anchor == null)
            {
                return;
            }

            var guid = referenceValues.GetValueSafe(UnityYamlConstants.ScriptProperty)?.guid;

            if (guid == null)
            {
                return;
            }

            var gameObject = referenceValues.GetValueSafe(UnityYamlConstants.GameObjectProperty)?.fileID;

            if (gameObject == null)
            {
                return;
            }

            foreach (var(fieldName, value) in simpleValues)
            {
                if (ourIgnoredMonoBehaviourEntries.Contains(fieldName))
                {
                    continue;
                }

                var property      = new MonoBehaviourProperty(guid, fieldName);
                var propertyValue = new MonoBehaviourPrimitiveValue(value, anchor, gameObject);
                result.Add(property, propertyValue);
            }

            foreach (var(fieldName, value) in referenceValues)
            {
                if (ourIgnoredMonoBehaviourEntries.Contains(fieldName))
                {
                    continue;
                }

                var property      = new MonoBehaviourProperty(guid, fieldName);
                var propertyValue = new MonoBehaviourReferenceValue(value, anchor, gameObject);
                result.Add(property, propertyValue);
            }
        }
Beispiel #2
0
        public static MonoBehaviourPropertyValue Read(UnsafeReader reader)
        {
            var type = reader.ReadInt32();

            switch (type)
            {
            case 0:
                return(MonoBehaviourReferenceValue.ReadFrom(reader));

            case 1:
                return(MonoBehaviourPrimitiveValue.ReadFrom(reader));

            default:
                throw new InvalidOperationException();
            }
        }
Beispiel #3
0
 protected bool Equals(MonoBehaviourPrimitiveValue other)
 {
     return(base.Equals(other) && string.Equals(PrimitiveValue, other.PrimitiveValue));
 }