Esempio n. 1
0
        /// <summary>
        /// Deserializes data at index <paramref name="index"/>.
        /// </summary>
        /// <param name="index">Data index.</param>
        /// <exception cref="InvalidOperationException">
        /// Thrown when there's no data at index <paramref name="index"/>.
        /// </exception>
        /// <remarks>
        /// The method automatically deserializes children.
        /// </remarks>
        private void Deserialize(int index)
        {
#if DEBUG
            if (index < 0 || index >= m_SerializedBehaviorData.Length)
            {
                m_treeBuilder = null;
                throw new InvalidOperationException($"Failed to get a serialized behavior at index {index}.");
            }
#endif

            SerializedBehaviorData data = m_SerializedBehaviorData[index];
            data.serializedBehavior.AddBehavior(m_treeBuilder);

            int[] children = data.childrenIndices;
            for (int i = 0, count = children.Length; i < count; ++i)
            {
                int child = children[i];
                if (child >= 0)
                {
                    Deserialize(child);
                }
            }

            m_treeBuilder.Complete();
        }