protected internal override void CopyScriptableObjects( System.Func <ScriptableObject, ScriptableObject> replaceSerializableObject) { // Get the fields of the specified class. FieldInfo[] myField = this.GetType().GetFields(); foreach (var x in myField) { // if(x.FieldType is FloatRemap) if (x.GetValue(this) is FloatRemap) { FloatRemap fr = (FloatRemap)x.GetValue(this); //its a struct this makes a copy // Debug.Log(x + " " + x.FieldType + " " + x.GetType() + " " + x.ReflectedType+" fr val:"+fr.m_Value); if (fr.m_Replacement != null) { NodeKnob knob = fr.m_Replacement; NodeInput replace = replaceSerializableObject.Invoke(knob) as NodeInput; if (replace != null) { fr.m_Replacement = replace; } else { fr.m_Replacement = null; } } x.SetValue(this, fr); //its a god damn struct it needs to be saved back out } } }
public static void ConnectRemapFloats(Node _n, Func <ScriptableObject, ScriptableObject> replaceSerializableObject) { // Get the fields of the specified class. FieldInfo[] myField = _n.GetType().GetFields(); foreach (var x in myField) { // if(x.FieldType is FloatRemap) if (x.GetValue(_n) is FloatRemap) { FloatRemap fr = (FloatRemap)x.GetValue(_n); //its a struct this makes a copy // Debug.Log(x + " " + x.FieldType + " " + x.GetType() + " " + x.ReflectedType+" fr val:"+fr.m_Value); if (fr.m_ReplaceWithInput && fr.m_Replacement == null) { Debug.LogError(" wants to be replaced but isnt linked "); } else if (fr.m_Replacement != null) { NodeKnob knob = fr.m_Replacement; NodeInput replace = replaceSerializableObject.Invoke(knob) as NodeInput; if (replace != null) { fr.m_Replacement = replace; } else { fr.m_Replacement = null; } } x.SetValue(_n, fr); //its a god damn struct it needs to be saved back out } } }
public void CloneFieldsFrom(Node _old) { // Dictionary<string, SharedVariable> m_SVLookUp=new Dictionary<string,SharedVariable>(); Type oldType = _old.GetType(); // typeof(PlayerBTTweaks); Type thisType = this.GetType(); // typeof(PlayerBTTweaks); FieldInfo[] my_Fields = thisType.GetFields(BindingFlags.Public | BindingFlags.Instance); FieldInfo[] oldFields = oldType.GetFields(BindingFlags.Public | BindingFlags.Instance); foreach (var m in oldFields) { //TODO can probably automate this somewhat finding reference types if (m.MemberType == MemberTypes.Field && m.FieldType.FullName.Contains("AnimationCurve")) { foreach (var n in my_Fields) { if (n.Name == m.Name) { AnimationCurve oldCurve = (AnimationCurve)m.GetValue(_old); n.SetValue(this, new AnimationCurve((Keyframe[])oldCurve.keys.Clone())); } } } else if (m.MemberType == MemberTypes.Field && m.FieldType.FullName.Contains("Gradient")) { foreach (var n in my_Fields) { if (n.Name == m.Name) { Gradient oldGradient = (Gradient)m.GetValue(_old); Gradient newGradient = new Gradient(); newGradient.SetKeys((GradientColorKey[])oldGradient.colorKeys.Clone(), (GradientAlphaKey[])oldGradient.alphaKeys); n.SetValue(this, newGradient); } } } else if (m.MemberType == MemberTypes.Field && (m.FieldType.FullName.Contains("Boolean") || m.FieldType.FullName.Contains("Int32") || m.FieldType.FullName.Contains("Color") || m.FieldType.FullName.Contains("TexMode"))) { foreach (var n in my_Fields) { if (n.Name == m.Name) { n.SetValue(this, m.GetValue(_old)); } } } else if (m.MemberType == MemberTypes.Field && m.FieldType.FullName.Contains("FloatRemap")) { foreach (var n in my_Fields) { if (n.Name == m.Name) // && !n.Name.StartsWith("Input") && !n.Name.StartsWith("Output") && !n.Name.StartsWith("nodeKnobs") && !n.Name.StartsWith("calculated") && !n.Name.StartsWith("rect"))) { FloatRemap fr = (FloatRemap)m.GetValue(_old); //its a struct this makes a copy //remove all replace input links if (fr.m_ReplaceWithInput && fr.m_Replacement != null) { //wont find itfr.m_Replacement = n.FindExistingInputByName(_label); var oldReplacement = fr.m_Replacement; fr.m_Replacement = CreateInput(oldReplacement.name, "Float"); } else { fr.m_ReplaceWithInput = false; fr.m_Replacement = null; } n.SetValue(this, fr); } } } } }
protected internal override void InspectorNodeGUI() { m_Value1 = RTEditorGUI.Slider(m_Value1, -100.0f, 100.0f);//,new GUIContent("Red", "Float"), m_R); }
protected Texture2MathOp() { m_Value = new FloatRemap(0.5f, 0, 1); }