예제 #1
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 = cryptoKey.longValue;

            var    union = new LongBytesUnion();
            double val   = 0;

            if (!inited.boolValue)
            {
                if (currentCryptoKey == 0)
                {
                    currentCryptoKey = cryptoKey.longValue = ObscuredDouble.cryptoKeyEditor;
                }

                inited.boolValue = true;

                union.l = ObscuredDouble.Encrypt(0, currentCryptoKey);
                hiddenValue.longValue = union.l;
            }
            else
            {
                union.l = hiddenValue.longValue;
                val     = ObscuredDouble.Decrypt(union.l, currentCryptoKey);
            }

            EditorGUI.BeginChangeCheck();
            val = EditorGUI.DoubleField(position, label, val);
            if (EditorGUI.EndChangeCheck())
            {
                union.l = ObscuredDouble.Encrypt(val, currentCryptoKey);
                hiddenValue.longValue = union.l;

                fakeValue.doubleValue     = val;
                fakeValueActive.boolValue = true;
            }

            ResetBoldFont();
        }
        public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
        {
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
            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");

            long currentCryptoKey = cryptoKey.longValue;

            LongBytesUnion union = new LongBytesUnion();
            double         val   = 0;

            if (!inited.boolValue)
            {
                if (currentCryptoKey == 0)
                {
                    currentCryptoKey = cryptoKey.longValue = ObscuredDouble.cryptoKeyEditor;
                }
                hiddenValue.arraySize = 8;
                inited.boolValue      = true;

                union.l = ObscuredDouble.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;
                hiddenValue.GetArrayElementAtIndex(4).intValue = union.b5;
                hiddenValue.GetArrayElementAtIndex(5).intValue = union.b6;
                hiddenValue.GetArrayElementAtIndex(6).intValue = union.b7;
                hiddenValue.GetArrayElementAtIndex(7).intValue = union.b8;
            }
            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];
                union.b5 = hiddenValueArray[4];
                union.b6 = hiddenValueArray[5];
                union.b7 = hiddenValueArray[6];
                union.b8 = hiddenValueArray[7];

                val = ObscuredDouble.Decrypt(union.l, currentCryptoKey);
            }

            EditorGUI.BeginChangeCheck();
            val = EditorGUI.DoubleField(position, label, val);
            if (EditorGUI.EndChangeCheck())
            {
                union.l = ObscuredDouble.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;
                hiddenValue.GetArrayElementAtIndex(4).intValue = union.b5;
                hiddenValue.GetArrayElementAtIndex(5).intValue = union.b6;
                hiddenValue.GetArrayElementAtIndex(6).intValue = union.b7;
                hiddenValue.GetArrayElementAtIndex(7).intValue = union.b8;
            }

            fakeValue.doubleValue = val;
            ResetBoldFont();
#endif
        }
예제 #3
0
        public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
        {
            var hiddenValue  = prop.FindPropertyRelative("hiddenValue");
            var hiddenValue1 = hiddenValue.FindPropertyRelative("b1");
            var hiddenValue2 = hiddenValue.FindPropertyRelative("b2");
            var hiddenValue3 = hiddenValue.FindPropertyRelative("b3");
            var hiddenValue4 = hiddenValue.FindPropertyRelative("b4");
            var hiddenValue5 = hiddenValue.FindPropertyRelative("b5");
            var hiddenValue6 = hiddenValue.FindPropertyRelative("b6");
            var hiddenValue7 = hiddenValue.FindPropertyRelative("b7");
            var hiddenValue8 = hiddenValue.FindPropertyRelative("b8");

            var hiddenValueOld = prop.FindPropertyRelative("hiddenValueOld");
            SerializedProperty hiddenValueOld1 = null;
            SerializedProperty hiddenValueOld2 = null;
            SerializedProperty hiddenValueOld3 = null;
            SerializedProperty hiddenValueOld4 = null;
            SerializedProperty hiddenValueOld5 = null;
            SerializedProperty hiddenValueOld6 = null;
            SerializedProperty hiddenValueOld7 = null;
            SerializedProperty hiddenValueOld8 = null;

            if (hiddenValueOld != null && hiddenValueOld.isArray && hiddenValueOld.arraySize == 8)
            {
                hiddenValueOld1 = hiddenValueOld.GetArrayElementAtIndex(0);
                hiddenValueOld2 = hiddenValueOld.GetArrayElementAtIndex(1);
                hiddenValueOld3 = hiddenValueOld.GetArrayElementAtIndex(2);
                hiddenValueOld4 = hiddenValueOld.GetArrayElementAtIndex(3);
                hiddenValueOld5 = hiddenValueOld.GetArrayElementAtIndex(4);
                hiddenValueOld6 = hiddenValueOld.GetArrayElementAtIndex(5);
                hiddenValueOld7 = hiddenValueOld.GetArrayElementAtIndex(6);
                hiddenValueOld8 = hiddenValueOld.GetArrayElementAtIndex(7);
            }

            SetBoldIfValueOverridePrefab(prop, hiddenValue);

            var cryptoKey = prop.FindPropertyRelative("currentCryptoKey");
            var inited    = prop.FindPropertyRelative("inited");

            var currentCryptoKey = cryptoKey.longValue;

            var    union = new LongBytesUnion();
            double val   = 0;

            if (!inited.boolValue)
            {
                if (currentCryptoKey == 0)
                {
                    currentCryptoKey = cryptoKey.longValue = ObscuredDouble.cryptoKeyEditor;
                }
                inited.boolValue = true;

                union.l = ObscuredDouble.Encrypt(0, currentCryptoKey);

                hiddenValue1.intValue = union.b8.b1;
                hiddenValue2.intValue = union.b8.b2;
                hiddenValue3.intValue = union.b8.b3;
                hiddenValue4.intValue = union.b8.b4;
                hiddenValue5.intValue = union.b8.b5;
                hiddenValue6.intValue = union.b8.b6;
                hiddenValue7.intValue = union.b8.b7;
                hiddenValue8.intValue = union.b8.b8;
            }
            else
            {
                if (hiddenValueOld != null && hiddenValueOld.isArray && hiddenValueOld.arraySize == 8)
                {
                    union.b8.b1 = (byte)hiddenValueOld1.intValue;
                    union.b8.b2 = (byte)hiddenValueOld2.intValue;
                    union.b8.b3 = (byte)hiddenValueOld3.intValue;
                    union.b8.b4 = (byte)hiddenValueOld4.intValue;
                    union.b8.b5 = (byte)hiddenValueOld5.intValue;
                    union.b8.b6 = (byte)hiddenValueOld6.intValue;
                    union.b8.b7 = (byte)hiddenValueOld7.intValue;
                    union.b8.b8 = (byte)hiddenValueOld8.intValue;
                }
                else
                {
                    union.b8.b1 = (byte)hiddenValue1.intValue;
                    union.b8.b2 = (byte)hiddenValue2.intValue;
                    union.b8.b3 = (byte)hiddenValue3.intValue;
                    union.b8.b4 = (byte)hiddenValue4.intValue;
                    union.b8.b5 = (byte)hiddenValue5.intValue;
                    union.b8.b6 = (byte)hiddenValue6.intValue;
                    union.b8.b7 = (byte)hiddenValue7.intValue;
                    union.b8.b8 = (byte)hiddenValue8.intValue;
                }

                val = ObscuredDouble.Decrypt(union.l, currentCryptoKey);
            }

            EditorGUI.BeginChangeCheck();
            val = EditorGUI.DoubleField(position, label, val);
            if (EditorGUI.EndChangeCheck())
            {
                union.l = ObscuredDouble.Encrypt(val, currentCryptoKey);

                hiddenValue1.intValue = union.b8.b1;
                hiddenValue2.intValue = union.b8.b2;
                hiddenValue3.intValue = union.b8.b3;
                hiddenValue4.intValue = union.b8.b4;
                hiddenValue5.intValue = union.b8.b5;
                hiddenValue6.intValue = union.b8.b6;
                hiddenValue7.intValue = union.b8.b7;
                hiddenValue8.intValue = union.b8.b8;

                if (hiddenValueOld != null && hiddenValueOld.isArray && hiddenValueOld.arraySize == 8)
                {
                    hiddenValueOld.arraySize = 0;
                }
            }

            ResetBoldFont();
        }
예제 #4
0
        public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
        {
            var hiddenValue = prop.FindPropertyRelative("hiddenValue");

            var hiddenValueOldProperty = prop.FindPropertyRelative("hiddenValueOldByte8");
            var hiddenValueOld         = default(ACTkByte8);
            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;
                    hiddenValueOld.b5 = (byte)hiddenValueOldProperty.FindPropertyRelative("b5").intValue;
                    hiddenValueOld.b6 = (byte)hiddenValueOldProperty.FindPropertyRelative("b6").intValue;
                    hiddenValueOld.b7 = (byte)hiddenValueOldProperty.FindPropertyRelative("b7").intValue;
                    hiddenValueOld.b8 = (byte)hiddenValueOldProperty.FindPropertyRelative("b8").intValue;

                    if (hiddenValueOld.b1 != 0 ||
                        hiddenValueOld.b2 != 0 ||
                        hiddenValueOld.b3 != 0 ||
                        hiddenValueOld.b4 != 0 ||
                        hiddenValueOld.b5 != 0 ||
                        hiddenValueOld.b6 != 0 ||
                        hiddenValueOld.b7 != 0 ||
                        hiddenValueOld.b8 != 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.longValue;

            var    union = new LongBytesUnion();
            double val   = 0;

            if (!inited.boolValue)
            {
                if (currentCryptoKey == 0)
                {
                    currentCryptoKey = cryptoKey.longValue = ObscuredDouble.cryptoKeyEditor;
                }

                inited.boolValue = true;

                union.l = ObscuredDouble.Encrypt(0, currentCryptoKey);
                hiddenValue.longValue = union.l;
            }
            else
            {
                if (oldValueExists)
                {
                    union.b8 = hiddenValueOld;
                    union.b8.Shuffle();
                }
                else
                {
                    union.l = hiddenValue.longValue;
                }

                val = ObscuredDouble.Decrypt(union.l, currentCryptoKey);
            }

            EditorGUI.BeginChangeCheck();
            val = EditorGUI.DoubleField(position, label, val);
            if (EditorGUI.EndChangeCheck())
            {
                union.l = ObscuredDouble.Encrypt(val, currentCryptoKey);
                hiddenValue.longValue = union.l;

                if (oldValueExists)
                {
                    hiddenValueOldProperty.FindPropertyRelative("b1").intValue = 0;
                    hiddenValueOldProperty.FindPropertyRelative("b2").intValue = 0;
                    hiddenValueOldProperty.FindPropertyRelative("b3").intValue = 0;
                    hiddenValueOldProperty.FindPropertyRelative("b4").intValue = 0;
                    hiddenValueOldProperty.FindPropertyRelative("b5").intValue = 0;
                    hiddenValueOldProperty.FindPropertyRelative("b6").intValue = 0;
                    hiddenValueOldProperty.FindPropertyRelative("b7").intValue = 0;
                    hiddenValueOldProperty.FindPropertyRelative("b8").intValue = 0;
                }

                fakeValue.doubleValue     = val;
                fakeValueActive.boolValue = true;
            }

            ResetBoldFont();
        }