Ejemplo n.º 1
0
        private SerializableMemberInfo(LinkedMemberInfo memberInfo)
        {
            int parentCount = 0;

            for (var parent = memberInfo.Parent; parent != null; parent = parent.Parent)
            {
                parentCount++;
            }
            memberStack = new Stack <Data>(parentCount + 1);
            var next = memberInfo;

            for (int n = parentCount; n >= 0; n--)
            {
                memberStack.Push(new Data(next));
                next = next.Parent;
            }

            var targets     = memberInfo.UnityObjects;
            int targetCount = targets.Length;

            targetReferences = new int[targetCount];
            for (int n = targetCount - 1; n >= 0; n--)
            {
                var target = targets[n];
                targetReferences[n] = ObjectIds.Get(target);
            }
        }
Ejemplo n.º 2
0
        public byte[] Serialize(BinaryFormatter formatter)
        {
            if (cachedEditors == null)
            {
                using (var stream = new MemoryStream(54))
                {
                    // Editor count
                    formatter.Serialize(stream, 0);

                                        #if DEV_MODE && DEBUG_SERIALIZE
                    Debug.Log(StringUtils.ToStringSansNamespace(GetType()) + " - Serialized null cachedEditors.");
                                        #endif
                    return(stream.ToArray());
                }
            }

            int count = cachedEditors.Count;
            using (var stream = new MemoryStream(count * 57))
            {
                // 1: Editor count
                formatter.Serialize(stream, count);

                // 2: instance IDs for Editors
                foreach (var editorData in cachedEditors)
                {
                    formatter.Serialize(stream, ObjectIds.Get(editorData.Value));
                }

                                #if DEV_MODE && DEBUG_SERIALIZE
                Debug.Log(StringUtils.ToStringSansNamespace(GetType()) + " - Serialized " + cachedEditors.Count + " cachedEditors:\n" + StringUtils.ToString(cachedEditors, "\n"));
                                #endif
                return(stream.ToArray());
            }
        }
        public InspectorSerializedState(InspectorState inspectorState)
        {
            var targets = inspectorState.inspected;

            int count = targets.Length;

                        #if DEV_MODE && DEBUG_ENABLED
            Debug.Log("Creating InspectorSerializedState from " + targets.Length + " targets: " + StringUtils.ToString(targets));
                        #endif

            var references = new int[count];
            for (int n = count - 1; n >= 0; n--)
            {
                var target = targets[n];
                if (target == null)
                {
                                        #if DEV_MODE
                    Debug.LogWarning("InspectorSerializedState inspected[" + n + "] reference was null! Will skip serializing.");
                                        #endif

                    references = references.RemoveAt(n);
                }
                else
                {
                    references[n] = ObjectIds.Get(target);

                                        #if DEV_MODE
                    Debug.Assert(ObjectIds.GetTarget(references[n]) == target);
                                        #endif
                }
            }
            inspected = references;

            viewLocked = inspectorState.ViewIsLocked;

            scrollPos = inspectorState.ScrollPos;

            filter = inspectorState.filter.RawInput;
        }