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 currentCryptoKey = cryptoKey.longValue; long val = 0; if (!inited.boolValue) { if (currentCryptoKey == 0) { currentCryptoKey = cryptoKey.longValue = ObscuredLong.cryptoKeyEditor; } hiddenValue.longValue = ObscuredLong.Encrypt(0, currentCryptoKey); inited.boolValue = true; } else { val = ObscuredLong.Decrypt(hiddenValue.longValue, currentCryptoKey); } EditorGUI.BeginChangeCheck(); val = EditorGUI.LongField(position, label, val); if (EditorGUI.EndChangeCheck()) { hiddenValue.longValue = ObscuredLong.Encrypt(val, currentCryptoKey); } ResetBoldFont(); }
public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { #if !UNITY_5_0_PLUS EditorGUI.LabelField(position, label.text + " [works in Unity 5+]"); #else SerializedProperty hiddenValue = prop.FindPropertyRelative("hiddenValue"); SetBoldIfValueOverridePrefab(prop, hiddenValue); SerializedProperty cryptoKey = prop.FindPropertyRelative("currentCryptoKey"); SerializedProperty inited = prop.FindPropertyRelative("inited"); SerializedProperty fakeValue = prop.FindPropertyRelative("fakeValue"); SerializedProperty fakeValueActive = prop.FindPropertyRelative("fakeValueActive"); long currentCryptoKey = cryptoKey.longValue; long val = 0; if (!inited.boolValue) { if (currentCryptoKey == 0) { currentCryptoKey = cryptoKey.longValue = ObscuredLong.cryptoKeyEditor; } hiddenValue.longValue = ObscuredLong.Encrypt(0, currentCryptoKey); inited.boolValue = true; fakeValue.longValue = 0; } else { val = ObscuredLong.Decrypt(hiddenValue.longValue, currentCryptoKey); } EditorGUI.BeginChangeCheck(); val = EditorGUI.LongField(position, label, val); if (EditorGUI.EndChangeCheck()) { hiddenValue.longValue = ObscuredLong.Encrypt(val, currentCryptoKey); fakeValue.longValue = val; fakeValueActive.boolValue = true; } ResetBoldFont(); #endif }
public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) { var hiddenValue = prop.FindPropertyRelative("hiddenValue"); var cryptoKey = prop.FindPropertyRelative("currentCryptoKey"); var inited = prop.FindPropertyRelative("inited"); var fakeValue = prop.FindPropertyRelative("fakeValue"); var fakeValueActive = prop.FindPropertyRelative("fakeValueActive"); var currentCryptoKey = cryptoKey.longValue; long val = 0; if (!inited.boolValue) { if (currentCryptoKey == 0) { currentCryptoKey = cryptoKey.longValue = ObscuredLong.GenerateKey(); } hiddenValue.longValue = ObscuredLong.Encrypt(0, currentCryptoKey); inited.boolValue = true; fakeValue.longValue = 0; } else { val = ObscuredLong.Decrypt(hiddenValue.longValue, currentCryptoKey); } label = EditorGUI.BeginProperty(position, label, prop); EditorGUI.BeginChangeCheck(); val = EditorGUI.LongField(position, label, val); if (EditorGUI.EndChangeCheck()) { hiddenValue.longValue = ObscuredLong.Encrypt(val, currentCryptoKey); fakeValue.longValue = val; fakeValueActive.boolValue = true; } EditorGUI.EndProperty(); }