コード例 #1
0
        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 fakeValue = prop.FindPropertyRelative("fakeValue");
            SerializedProperty inited    = prop.FindPropertyRelative("inited");

            ulong currentCryptoKey = (ulong)cryptoKey.longValue;
            ulong val = 0;

            if (!inited.boolValue)
            {
                if (currentCryptoKey == 0)
                {
                    currentCryptoKey    = ObscuredULong.cryptoKeyEditor;
                    cryptoKey.longValue = (long)ObscuredULong.cryptoKeyEditor;
                }
                hiddenValue.longValue = (long)ObscuredULong.Encrypt(0, currentCryptoKey);
                inited.boolValue      = true;
            }
            else
            {
                val = ObscuredULong.Decrypt((ulong)hiddenValue.longValue, currentCryptoKey);
            }

            EditorGUI.BeginChangeCheck();
            val = (ulong)EditorGUI.LongField(position, label, (long)val);
            if (EditorGUI.EndChangeCheck())
            {
                hiddenValue.longValue = (long)ObscuredULong.Encrypt(val, currentCryptoKey);
            }

            fakeValue.longValue = (long)val;
            ResetBoldFont();
#endif
        }
コード例 #2
0
        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 = (ulong)cryptoKey.longValue;
            ulong val = 0;

            if (!inited.boolValue)
            {
                if (currentCryptoKey == 0)
                {
                    currentCryptoKey    = ObscuredULong.cryptoKeyEditor;
                    cryptoKey.longValue = (long)ObscuredULong.cryptoKeyEditor;
                }
                hiddenValue.longValue = (long)ObscuredULong.Encrypt(0, currentCryptoKey);
                inited.boolValue      = true;
            }
            else
            {
                val = ObscuredULong.Decrypt((ulong)hiddenValue.longValue, currentCryptoKey);
            }

            EditorGUI.BeginChangeCheck();
            val = (ulong)EditorGUI.LongField(position, label, (long)val);
            if (EditorGUI.EndChangeCheck())
            {
                hiddenValue.longValue     = (long)ObscuredULong.Encrypt(val, currentCryptoKey);
                fakeValue.longValue       = (long)val;
                fakeValueActive.boolValue = true;
            }

            ResetBoldFont();
        }