public void CopyFrom(DS_HazeContextItem other) { if (other == null) { return; } Type type1 = this.GetType(); Type type2 = other.GetType(); foreach (FieldInfo field1 in type1.GetFields()) { FieldInfo field2 = type2.GetField(field1.Name); field1.SetValue((object)this, field2.GetValue((object)other)); } this.m_Weight = new AnimationCurve(this.m_Weight.get_keys()); }
/// <summary> /// Copy all the values from 'other'. /// </summary> /// <param name="other"> The DS_HazeContextVariant to get values from. </param> public void CopyFrom(DS_HazeContextItem other) { if (other == null) { #if DEVELOPMENT_BUILD || UNITY_EDITOR Debug.LogError("DeepSky::DS_HazeContextItem:CopyFrom - null context passed!"); #endif return; } Type thisType = GetType(); Type otherType = other.GetType(); foreach (FieldInfo field in thisType.GetFields()) { FieldInfo otherField = otherType.GetField(field.Name); field.SetValue(this, otherField.GetValue(other)); } // We need an actual copy of the weight curve, not just the reference. m_Weight = new AnimationCurve(m_Weight.keys); }