PushChange() public method

Creates a new change list entry.
public PushChange ( object target, PropertyInfo prop ) : void
target object The target object in which the change has been made. Must be a GameObject or Component.
prop System.Reflection.PropertyInfo The target objects Property that has been changed.
return void
Beispiel #1
0
        /// <summary>
        /// Relocates the internal change list from this PrefabLink to a different, hierarchially lower PrefabLink.
        /// </summary>
        /// <param name="other">
        /// The PrefabLink to which to relocate changes. It needs to be hierarchially lower than
        /// this one for the relocation to succeed.
        /// </param>
        /// <remarks>
        /// <para>
        /// In general, each PrefabLink is responsible for all hierarchially lower GameObjects. If one of them has
        /// a PrefabLink on its own, then the higher PrefabLinks responsibility ends there.
        /// </para>
        /// <para>
        /// Change relocation is done when linking an existing GameObject to a Prefab although it is already affected by a
        /// hierarchially higher PrefabLink. In order to prevent both PrefabLinks to interfere with each other,
        /// all higher PrefabLink change list entries referring to that GameObject are relocated to the new, lower
        /// PrefabLink that is specifically targetting it.
        /// </para>
        /// <para>
        /// This way, the above responsibility guideline remains applicable.
        /// </para>
        /// </remarks>
        public void RelocateChanges(PrefabLink other)
        {
            if (this.changes == null || this.changes.Count == 0)
            {
                return;
            }
            if (!other.obj.IsChildOf(this.obj))
            {
                return;
            }
            List <int> childPath = this.obj.IndexPathOfChild(other.obj);

            for (int i = this.changes.Count - 1; i >= 0; i--)
            {
                if (this.changes[i].childIndex.Take(childPath.Count).SequenceEqual(childPath))
                {
                    object target;

                    GameObject targetObj = this.obj.ChildAtIndexPath(this.changes[i].childIndex);
                    if (this.changes[i].componentType != null)
                    {
                        target = targetObj.GetComponent(this.changes[i].componentType);
                    }
                    else
                    {
                        target = targetObj;
                    }

                    other.PushChange(target, this.changes[i].prop, this.changes[i].val);
                    this.changes.RemoveAt(i);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Relocates the internal change list from this PrefabLink to a different, hierarchially lower PrefabLink.
        /// </summary>
        /// <param name="other">
        /// The PrefabLink to which to relocate changes. It needs to be hierarchially lower than
        /// this one for the relocation to succeed.
        /// </param>
        /// <remarks>
        /// <para>
        /// In general, each PrefabLink is responsible for all hierarchially lower GameObjects. If one of them has
        /// a PrefabLink on its own, then the higher PrefabLinks responsibility ends there.
        /// </para>
        /// <para>
        /// Change relocation is done when linking an existing GameObject to a Prefab although it is already affected by a
        /// hierarchially higher PrefabLink. In order to prevent both PrefabLinks to interfere with each other, 
        /// all higher PrefabLink change list entries referring to that GameObject are relocated to the new, lower 
        /// PrefabLink that is specifically targetting it.
        /// </para>
        /// <para>
        /// This way, the above responsibility guideline remains applicable.
        /// </para>
        /// </remarks>
        public void RelocateChanges(PrefabLink other)
        {
            if (this.changes == null || this.changes.Count == 0) return;
            if (!other.obj.IsChildOf(this.obj)) return;
            List<int> childPath = this.obj.IndexPathOfChild(other.obj);

            for (int i = this.changes.Count - 1; i >= 0; i--)
            {
                if (this.changes[i].childIndex.Take(childPath.Count).SequenceEqual(childPath))
                {
                    object target;

                    GameObject targetObj = this.obj.ChildAtIndexPath(this.changes[i].childIndex);
                    if (this.changes[i].componentType != null)
                        target = targetObj.GetComponent(this.changes[i].componentType);
                    else
                        target = targetObj;

                    other.PushChange(target, this.changes[i].prop, this.changes[i].val);
                    this.changes.RemoveAt(i);
                }
            }
        }