public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { SerializedProperty hiddenValue = prop.FindPropertyRelative("hiddenValue"); SerializedProperty cryptoKey = prop.FindPropertyRelative("currentCryptoKey"); SerializedProperty fakeValue = prop.FindPropertyRelative("fakeValue"); SerializedProperty inited = prop.FindPropertyRelative("inited"); int currentCryptoKey = cryptoKey.intValue; var union = new IntBytesUnion(); float val = 0; if (!inited.boolValue) { if (currentCryptoKey == 0) { currentCryptoKey = cryptoKey.intValue = 230887; } hiddenValue.arraySize = 4; inited.boolValue = true; union.i = ObscuredFloat.Encrypt(0, currentCryptoKey); hiddenValue.GetArrayElementAtIndex(0).intValue = union.b1; hiddenValue.GetArrayElementAtIndex(1).intValue = union.b2; hiddenValue.GetArrayElementAtIndex(2).intValue = union.b3; hiddenValue.GetArrayElementAtIndex(3).intValue = union.b4; } else { int arraySize = hiddenValue.arraySize; byte[] hiddenValueArray = new byte[arraySize]; for (int i = 0; i < arraySize; i++) { hiddenValueArray[i] = (byte)hiddenValue.GetArrayElementAtIndex(i).intValue; } union.b1 = hiddenValueArray[0]; union.b2 = hiddenValueArray[1]; union.b3 = hiddenValueArray[2]; union.b4 = hiddenValueArray[3]; val = ObscuredFloat.Decrypt(union.i, currentCryptoKey); } EditorGUI.BeginChangeCheck(); val = EditorGUI.FloatField(position, label, val); if (EditorGUI.EndChangeCheck()) { union.i = ObscuredFloat.Encrypt(val, currentCryptoKey); hiddenValue.GetArrayElementAtIndex(0).intValue = union.b1; hiddenValue.GetArrayElementAtIndex(1).intValue = union.b2; hiddenValue.GetArrayElementAtIndex(2).intValue = union.b3; hiddenValue.GetArrayElementAtIndex(3).intValue = union.b4; } fakeValue.floatValue = val; }
public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { var hiddenValue = prop.FindPropertyRelative("hiddenValue"); SetBoldIfValueOverridePrefab(prop, hiddenValue); var cryptoKey = prop.FindPropertyRelative("currentCryptoKey"); var inited = prop.FindPropertyRelative("inited"); var fakeValue = prop.FindPropertyRelative("fakeValue"); var fakeValueActive = prop.FindPropertyRelative("fakeValueActive"); var currentCryptoKey = cryptoKey.intValue; var union = new IntBytesUnion(); float val = 0; if (!inited.boolValue) { if (currentCryptoKey == 0) { currentCryptoKey = cryptoKey.intValue = ObscuredFloat.cryptoKeyEditor; } inited.boolValue = true; union.i = ObscuredFloat.Encrypt(0, currentCryptoKey); hiddenValue.intValue = union.i; } else { union.i = hiddenValue.intValue; val = ObscuredFloat.Decrypt(union.i, currentCryptoKey); } EditorGUI.BeginChangeCheck(); val = EditorGUI.FloatField(position, label, val); if (EditorGUI.EndChangeCheck()) { union.i = ObscuredFloat.Encrypt(val, currentCryptoKey); hiddenValue.intValue = union.i; fakeValue.floatValue = val; fakeValueActive.boolValue = true; } ResetBoldFont(); }
public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { SerializedProperty hiddenValue = prop.FindPropertyRelative("hiddenValue"); SerializedProperty hiddenValue1 = hiddenValue.FindPropertyRelative("b1"); SerializedProperty hiddenValue2 = hiddenValue.FindPropertyRelative("b2"); SerializedProperty hiddenValue3 = hiddenValue.FindPropertyRelative("b3"); SerializedProperty hiddenValue4 = hiddenValue.FindPropertyRelative("b4"); SerializedProperty hiddenValueOld = prop.FindPropertyRelative("hiddenValueOld"); SerializedProperty hiddenValueOld1 = null; SerializedProperty hiddenValueOld2 = null; SerializedProperty hiddenValueOld3 = null; SerializedProperty hiddenValueOld4 = null; if (hiddenValueOld != null && hiddenValueOld.isArray && hiddenValueOld.arraySize == 4) { hiddenValueOld1 = hiddenValueOld.GetArrayElementAtIndex(0); hiddenValueOld2 = hiddenValueOld.GetArrayElementAtIndex(1); hiddenValueOld3 = hiddenValueOld.GetArrayElementAtIndex(2); hiddenValueOld4 = hiddenValueOld.GetArrayElementAtIndex(3); } SetBoldIfValueOverridePrefab(prop, hiddenValue); SerializedProperty cryptoKey = prop.FindPropertyRelative("currentCryptoKey"); SerializedProperty fakeValue = prop.FindPropertyRelative("fakeValue"); SerializedProperty inited = prop.FindPropertyRelative("inited"); int currentCryptoKey = cryptoKey.intValue; IntBytesUnion union = new IntBytesUnion(); float val = 0; if (!inited.boolValue) { if (currentCryptoKey == 0) { currentCryptoKey = cryptoKey.intValue = ObscuredFloat.cryptoKeyEditor; } inited.boolValue = true; union.i = ObscuredFloat.Encrypt(0, currentCryptoKey); hiddenValue1.intValue = union.b4.b1; hiddenValue2.intValue = union.b4.b2; hiddenValue3.intValue = union.b4.b3; hiddenValue4.intValue = union.b4.b4; } else { if (hiddenValueOld != null && hiddenValueOld.isArray && hiddenValueOld.arraySize == 4) { union.b4.b1 = (byte)hiddenValueOld1.intValue; union.b4.b2 = (byte)hiddenValueOld2.intValue; union.b4.b3 = (byte)hiddenValueOld3.intValue; union.b4.b4 = (byte)hiddenValueOld4.intValue; } else { union.b4.b1 = (byte)hiddenValue1.intValue; union.b4.b2 = (byte)hiddenValue2.intValue; union.b4.b3 = (byte)hiddenValue3.intValue; union.b4.b4 = (byte)hiddenValue4.intValue; } /*Debug.Log("Int: " + union.i);*/ val = ObscuredFloat.Decrypt(union.i, currentCryptoKey); } EditorGUI.BeginChangeCheck(); val = EditorGUI.FloatField(position, label, val); if (EditorGUI.EndChangeCheck()) { union.i = ObscuredFloat.Encrypt(val, currentCryptoKey); hiddenValue1.intValue = union.b4.b1; hiddenValue2.intValue = union.b4.b2; hiddenValue3.intValue = union.b4.b3; hiddenValue4.intValue = union.b4.b4; if (hiddenValueOld != null && hiddenValueOld.isArray && hiddenValueOld.arraySize == 4) { hiddenValueOld.arraySize = 0; } } fakeValue.floatValue = val; ResetBoldFont(); }
public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { var hiddenValue = prop.FindPropertyRelative("hiddenValue"); var hiddenValueOldProperty = prop.FindPropertyRelative("hiddenValueOldByte4"); var hiddenValueOld = default(ACTkByte4); var oldValueExists = false; if (hiddenValueOldProperty != null) { if (hiddenValueOldProperty.FindPropertyRelative("b1") != null) { hiddenValueOld.b1 = (byte)hiddenValueOldProperty.FindPropertyRelative("b1").intValue; hiddenValueOld.b2 = (byte)hiddenValueOldProperty.FindPropertyRelative("b2").intValue; hiddenValueOld.b3 = (byte)hiddenValueOldProperty.FindPropertyRelative("b3").intValue; hiddenValueOld.b4 = (byte)hiddenValueOldProperty.FindPropertyRelative("b4").intValue; if (hiddenValueOld.b1 != 0 || hiddenValueOld.b2 != 0 || hiddenValueOld.b3 != 0 || hiddenValueOld.b4 != 0) { oldValueExists = true; } } } SetBoldIfValueOverridePrefab(prop, hiddenValue); var cryptoKey = prop.FindPropertyRelative("currentCryptoKey"); var inited = prop.FindPropertyRelative("inited"); var fakeValue = prop.FindPropertyRelative("fakeValue"); var fakeValueActive = prop.FindPropertyRelative("fakeValueActive"); var currentCryptoKey = cryptoKey.intValue; var union = new IntBytesUnion(); float val = 0; if (!inited.boolValue) { if (currentCryptoKey == 0) { currentCryptoKey = cryptoKey.intValue = ObscuredFloat.cryptoKeyEditor; } inited.boolValue = true; union.i = ObscuredFloat.Encrypt(0, currentCryptoKey); hiddenValue.intValue = union.i; } else { if (oldValueExists) { union.b4 = hiddenValueOld; union.b4.Shuffle(); } else { union.i = hiddenValue.intValue; } val = ObscuredFloat.Decrypt(union.i, currentCryptoKey); } EditorGUI.BeginChangeCheck(); val = EditorGUI.FloatField(position, label, val); if (EditorGUI.EndChangeCheck()) { union.i = ObscuredFloat.Encrypt(val, currentCryptoKey); hiddenValue.intValue = union.i; if (oldValueExists) { hiddenValueOldProperty.FindPropertyRelative("b1").intValue = 0; hiddenValueOldProperty.FindPropertyRelative("b2").intValue = 0; hiddenValueOldProperty.FindPropertyRelative("b3").intValue = 0; hiddenValueOldProperty.FindPropertyRelative("b4").intValue = 0; } fakeValue.floatValue = val; fakeValueActive.boolValue = true; } ResetBoldFont(); }