Exemplo n.º 1
0
        private SymbolsData GetSymbolsData()
        {
            var result = new SymbolsData();

            var groups = (BuildTargetGroup[])Enum.GetValues(typeof(BuildTargetGroup));

            foreach (var buildTargetGroup in groups)
            {
                if (buildTargetGroup == BuildTargetGroup.Unknown)
                {
                    continue;
                }

                var symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);

                result.injectionDebug            |= GetSymbol(symbols, SymbolsData.InjectionDebug);
                result.injectionDebugVerbose     |= GetSymbol(symbols, SymbolsData.InjectionDebugVerbose);
                result.injectionDebugParanoid    |= GetSymbol(symbols, SymbolsData.InjectionDebugParanoid);
                result.wallhackDebug             |= GetSymbol(symbols, SymbolsData.WallhackDebug);
                result.excludeObfuscation        |= GetSymbol(symbols, SymbolsData.ExcludeObfuscation);
                result.preventReadPhoneState     |= GetSymbol(symbols, SymbolsData.PreventReadPhoneState);
                result.preventInternetPermission |= GetSymbol(symbols, SymbolsData.PreventInternetPermission);
                result.obscuredAutoMigration     |= GetSymbol(symbols, SymbolsData.ObscuredAutoMigration);
            }

            return(result);
        }
Exemplo n.º 2
0
        public async Task Initialize()
        {
            //load saved state
            if (Config.SaveData)
            {
                this.ConfigureSerialization();
                this.LoadNonVolatileVars();
            }
            if (!BackTesting)
            {
                //on restart there is the possibility that we missed some trades, let's reload the last trades
                var req = await Market.GetLastTradesAsync(Market.Time - TimeSpan.FromHours(12));

                if (req.IsSuccessful)
                {
                    foreach (var trade in req.Result)
                    {
                        if (SymbolsData.ContainsKey(trade.Symbol))
                        {
                            this.WorkingSlice.Add(SymbolsData[trade.Symbol].Symbol, trade);
                        }
                        else
                        {
                            Logger.Error($"{Name} - Symbol data not found for trade {trade} during initialize.");
                        }
                    }
                }
                else
                {
                    Logger.Error("{0} - GetLastTrades failed during initialize", Name);
                }
            }
            //call on initialize
            await this.OnInitialize();
        }
Exemplo n.º 3
0
 void Start()
 {
     symbolsData = SymbolsData.instance;         //getting data about each symbol
     oneSpin     = 6 * symbolsData.distance;     //calculating one full spin
     counter     = 0;                            //setting counter to zero
     loader      = new DataLoader();             //loading data from json->DataStop in Resources
     stopData    = loader.LoadDataStop("DataStop");
 }
Exemplo n.º 4
0
 private SymbolData GetOrAddData(ISymbolInfo symbol)
 {
     if (!SymbolsData.TryGetValue(symbol.Key, out SymbolData data))
     {
         data = new SymbolData(symbol);
         _SymbolsData[symbol.Key] = data;
     }
     return(data);
 }
Exemplo n.º 5
0
        private void DrawSymbol(ref bool field, string symbol, string hint)
        {
            EditorGUI.BeginChangeCheck();
            field = GUILayout.Toggle(field, new GUIContent(symbol, hint));
            if (EditorGUI.EndChangeCheck())
            {
                if (field)
                {
                    SetSymbol(symbol);
                }
                else
                {
                    RemoveSymbol(symbol);
                }

                symbolsData = GetSymbolsData();
            }
        }
Exemplo n.º 6
0
        private SymbolsData GetSymbolsData()
        {
            var result = new SymbolsData();

            BuildTargetGroup[] groups = (BuildTargetGroup[])Enum.GetValues(typeof(BuildTargetGroup));
            foreach (BuildTargetGroup buildTargetGroup in groups)
            {
                string symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup);

                result.injectionDebug            |= GetSymbol(symbols, SymbolsData.ACTK_INJECTION_DEBUG);
                result.injectionDebugVerbose     |= GetSymbol(symbols, SymbolsData.ACTK_INJECTION_DEBUG_VERBOSE);
                result.injectionDebugParanoid    |= GetSymbol(symbols, SymbolsData.ACTK_INJECTION_DEBUG_PARANOID);
                result.wallhackDebug             |= GetSymbol(symbols, SymbolsData.ACTK_WALLHACK_DEBUG);
                result.excludeObfuscation        |= GetSymbol(symbols, SymbolsData.ACTK_EXCLUDE_OBFUSCATION);
                result.preventReadPhoneState     |= GetSymbol(symbols, SymbolsData.ACTK_PREVENT_READ_PHONE_STATE);
                result.preventInternetPermission |= GetSymbol(symbols, SymbolsData.ACTK_PREVENT_INTERNET_PERMISSION);
            }

            return(result);
        }
Exemplo n.º 7
0
        public override void ViewDidLoad()
        {
            var ds = new SymbolsData(_db);

            table.DataSource = ds;
            table.SetEditing(true, false);

            NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Add, delegate {
                var c       = new AddStockView(_db);
                c.Finished += delegate {
                    ds.Refresh();
                    table.ReloadData();
                };
                var n = new UINavigationController(c);
                NavigationController.PresentModalViewController(n, true);
            });
            NavigationItem.LeftBarButtonItem = new UIBarButtonItem("Admin", UIBarButtonItemStyle.Plain, delegate {
                var c = new SQLiteAdmin(_db);
                NavigationController.PushViewController(c.NewTablesViewController(), true);
            });
        }
Exemplo n.º 8
0
		public override void ViewDidLoad ()
		{
			var ds = new SymbolsData (_db);
			
			table.DataSource = ds;
			table.SetEditing (true, false);
			
			NavigationItem.RightBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Add, delegate { 
				var c = new AddStockView (_db);
				c.Finished += delegate {
					ds.Refresh ();
					table.ReloadData ();
				};
				var n = new UINavigationController (c);
				NavigationController.PresentModalViewController(n, true);
			});
			NavigationItem.LeftBarButtonItem = new UIBarButtonItem ("Admin", UIBarButtonItemStyle.Plain, delegate { 
				var c = new SQLiteAdmin(_db);
				NavigationController.PushViewController(c.NewTablesViewController(), true);
			});
		}
Exemplo n.º 9
0
        private void OnGUI()
        {
            GUILayout.Label("You're using Anti-Cheat Toolkit v." + ACTkConstants.Version, ActEditorGUI.LargeBoldLabel);
            EditorGUILayout.Space();
            GUILayout.Label("Injection Detector settings (global)", ActEditorGUI.LargeBoldLabel);

            var enableInjectionDetector = EditorPrefs.GetBool(ActEditorGlobalStuff.PrefsInjectionEnabled);

            EditorGUI.BeginChangeCheck();
            enableInjectionDetector = GUILayout.Toggle(enableInjectionDetector, "Enable Injection Detector");
            if (EditorGUI.EndChangeCheck())
            {
                EditorPrefs.SetBool(ActEditorGlobalStuff.PrefsInjectionEnabled, enableInjectionDetector);
                if (enableInjectionDetector && !ActPostprocessor.IsInjectionDetectorTargetCompatible())
                {
                    Debug.LogWarning(ActEditorGlobalStuff.LogPrefix + "Injection Detector is not available on selected platform (" +
                                     EditorUserBuildSettings.activeBuildTarget + ")");
                }

                if (!enableInjectionDetector)
                {
                    ActEditorGlobalStuff.CleanInjectionDetectorData();
                }
                else if (!File.Exists(ActEditorGlobalStuff.injectionDataPath))
                {
                    ActPostprocessor.InjectionAssembliesScan();
                }
            }

            if (GUILayout.Button("Edit Whitelist"))
            {
                ActAssembliesWhitelist.ShowWindow();
            }

            EditorGUILayout.Space();
            GUILayout.Label("WallHack Detector settings (per-project)", ActEditorGUI.LargeBoldLabel);
            GUILayout.Label(
                "Wireframe module uses specific shader under the hood. Thus such shader should be included into the build to exist at runtime. To make sure it's get included, you may add it to the Always Included Shaders list using buttons below. You don't need to include it if you're not going to use Wireframe module.",
                EditorStyles.wordWrappedLabel);

            ReadGraphicsAsset();

            if (graphicsSettingsAsset != null && includedShaders != null)
            {
                // outputs whole included shaders list, use for debug
                //EditorGUILayout.PropertyField(includedShaders, true);

                var shaderIndex = GetWallhackDetectorShaderIndex();

                EditorGUI.BeginChangeCheck();

                if (shaderIndex != -1)
                {
                    GUILayout.Label("Shader already exists in the Always Included Shaders list, you're good to go!",
                                    EditorStyles.wordWrappedLabel);
                    if (GUILayout.Button("Remove shader"))
                    {
                        includedShaders.DeleteArrayElementAtIndex(shaderIndex);
                        includedShaders.DeleteArrayElementAtIndex(shaderIndex);
                    }
                }
                else
                {
                    GUILayout.Label("Shader doesn't exists in the Always Included Shaders list.", EditorStyles.wordWrappedLabel);
                    if (GUILayout.Button("Include shader"))
                    {
                        var shader = Shader.Find(WireframeShaderName);
                        if (shader != null)
                        {
                            includedShaders.InsertArrayElementAtIndex(includedShaders.arraySize);
                            var newItem = includedShaders.GetArrayElementAtIndex(includedShaders.arraySize - 1);
                            newItem.objectReferenceValue = shader;
                        }
                        else
                        {
                            Debug.LogError("Can't find " + WireframeShaderName + " shader! Please report this to the  " +
                                           ActEditorGlobalStuff.ReportEmail + " including your Unity version number.");
                        }
                    }
                    if (GUILayout.Button("Open Graphics Settings to manage it manually (see readme.pdf for details)"))
                    {
                        EditorApplication.ExecuteMenuItem("Edit/Project Settings/Graphics");
                    }
                }

                if (EditorGUI.EndChangeCheck())
                {
                    graphicsSettingsAsset.ApplyModifiedProperties();
                }
            }
            else
            {
                GUILayout.Label("Can't automatically control " + WireframeShaderName +
                                " shader existence at the Always Included Shaders list. Please, manage this manually in Graphics Settings.");
                if (GUILayout.Button("Open Graphics Settings"))
                {
                    EditorApplication.ExecuteMenuItem("Edit/Project Settings/Graphics");
                }
            }

            EditorGUILayout.Space();
            GUILayout.Label("Compilation symbols (per-project)", ActEditorGUI.LargeBoldLabel);
            GUILayout.Label("Here you may switch conditional compilation symbols used in ACTk.\n" +
                            "Check Readme for more details on each symbol.", EditorStyles.wordWrappedLabel);
            EditorGUILayout.Space();
            if (symbolsData == null)
            {
                symbolsData = GetSymbolsData();
            }

            /*if (GUILayout.Button("Reset"))
             * {
             *      var groups = (BuildTargetGroup[])Enum.GetValues(typeof(BuildTargetGroup));
             *      foreach (BuildTargetGroup buildTargetGroup in groups)
             *      {
             *              PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, string.Empty);
             *      }
             * }*/

            EditorGUI.BeginChangeCheck();
            symbolsData.injectionDebug = GUILayout.Toggle(symbolsData.injectionDebug, new GUIContent(SymbolsData.InjectionDebug, "Switches the Injection Detector debug."));
            if (EditorGUI.EndChangeCheck())
            {
                if (symbolsData.injectionDebug)
                {
                    SetSymbol(SymbolsData.InjectionDebug);
                }
                else
                {
                    RemoveSymbol(SymbolsData.InjectionDebug);
                }

                symbolsData = GetSymbolsData();
            }

            EditorGUI.BeginChangeCheck();
            symbolsData.injectionDebugVerbose = GUILayout.Toggle(symbolsData.injectionDebugVerbose, new GUIContent(SymbolsData.InjectionDebugVerbose, "Switches the Injection Detector verbose debug level."));
            if (EditorGUI.EndChangeCheck())
            {
                if (symbolsData.injectionDebugVerbose)
                {
                    SetSymbol(SymbolsData.InjectionDebugVerbose);
                }
                else
                {
                    RemoveSymbol(SymbolsData.InjectionDebugVerbose);
                }

                symbolsData = GetSymbolsData();
            }

            EditorGUI.BeginChangeCheck();
            symbolsData.injectionDebugParanoid = GUILayout.Toggle(symbolsData.injectionDebugParanoid, new GUIContent(SymbolsData.InjectionDebugParanoid, "Switches the Injection Detector paraniod debug level."));
            if (EditorGUI.EndChangeCheck())
            {
                if (symbolsData.injectionDebugParanoid)
                {
                    SetSymbol(SymbolsData.InjectionDebugParanoid);
                }
                else
                {
                    RemoveSymbol(SymbolsData.InjectionDebugParanoid);
                }

                symbolsData = GetSymbolsData();
            }

            EditorGUI.BeginChangeCheck();
            symbolsData.wallhackDebug = GUILayout.Toggle(symbolsData.wallhackDebug, new GUIContent(SymbolsData.WallhackDebug, "Switches the WallHack Detector debug - you'll see the WallHack objects in scene and get extra information in console."));
            if (EditorGUI.EndChangeCheck())
            {
                if (symbolsData.wallhackDebug)
                {
                    SetSymbol(SymbolsData.WallhackDebug);
                }
                else
                {
                    RemoveSymbol(SymbolsData.WallhackDebug);
                }

                symbolsData = GetSymbolsData();
            }

            EditorGUI.BeginChangeCheck();
            symbolsData.excludeObfuscation = GUILayout.Toggle(symbolsData.excludeObfuscation, new GUIContent(SymbolsData.ExcludeObfuscation, "Enable if you use Unity-unaware obfuscators which support ObfuscationAttribute to help avoid names corruption."));
            if (EditorGUI.EndChangeCheck())
            {
                if (symbolsData.excludeObfuscation)
                {
                    SetSymbol(SymbolsData.ExcludeObfuscation);
                }
                else
                {
                    RemoveSymbol(SymbolsData.ExcludeObfuscation);
                }

                symbolsData = GetSymbolsData();
            }

            EditorGUI.BeginChangeCheck();
            symbolsData.preventReadPhoneState = GUILayout.Toggle(symbolsData.preventReadPhoneState, new GUIContent(SymbolsData.PreventReadPhoneState, "Disables ObscuredPrefs Lock To Device functionality."));
            if (EditorGUI.EndChangeCheck())
            {
                if (symbolsData.preventReadPhoneState)
                {
                    SetSymbol(SymbolsData.PreventReadPhoneState);
                }
                else
                {
                    RemoveSymbol(SymbolsData.PreventReadPhoneState);
                }

                symbolsData = GetSymbolsData();
            }

            EditorGUI.BeginChangeCheck();
            symbolsData.preventInternetPermission = GUILayout.Toggle(symbolsData.preventInternetPermission, new GUIContent(SymbolsData.PreventInternetPermission, "Disables TimeCheatingDetector functionality."));
            if (EditorGUI.EndChangeCheck())
            {
                if (symbolsData.preventInternetPermission)
                {
                    SetSymbol(SymbolsData.PreventInternetPermission);
                }
                else
                {
                    RemoveSymbol(SymbolsData.PreventInternetPermission);
                }

                symbolsData = GetSymbolsData();
            }

            EditorGUI.BeginChangeCheck();
            symbolsData.obscuredAutoMigration = GUILayout.Toggle(symbolsData.obscuredAutoMigration, new GUIContent(SymbolsData.ObscuredAutoMigration, "Enables automatic migration of ObscuredFloat and ObscuredDouble instances from the ACTk 1.5.2.0-1.5.8.0 to the 1.5.9.0+ format. Reduces these types performance a bit."));
            if (EditorGUI.EndChangeCheck())
            {
                if (symbolsData.obscuredAutoMigration)
                {
                    SetSymbol(SymbolsData.ObscuredAutoMigration);
                }
                else
                {
                    RemoveSymbol(SymbolsData.ObscuredAutoMigration);
                }

                symbolsData = GetSymbolsData();
            }
        }
Exemplo n.º 10
0
        private void OnGUI()
        {
            using (ACTkEditorGUI.Vertical(ACTkEditorGUI.PanelWithBackground))
            {
                ACTkEditorGUI.DrawHeader("Injection Detector settings (global)");
                //GUILayout.Label("Injection Detector settings (global)", ACTkEditorGUI.LargeBoldLabel);

                var enableInjectionDetector = EditorPrefs.GetBool(ACTkEditorGlobalStuff.PrefsInjectionEnabled);

                EditorGUI.BeginChangeCheck();
                enableInjectionDetector = GUILayout.Toggle(enableInjectionDetector, "Enable Injection Detector");
                if (EditorGUI.EndChangeCheck())
                {
                    EditorPrefs.SetBool(ACTkEditorGlobalStuff.PrefsInjectionEnabled, enableInjectionDetector);
                    if (enableInjectionDetector && !ACTkPostprocessor.IsInjectionDetectorTargetCompatible())
                    {
                        Debug.LogWarning(ACTkEditorGlobalStuff.LogPrefix + "Injection Detector is not available on selected platform (" +
                                         EditorUserBuildSettings.activeBuildTarget + ")");
                    }

                    if (!enableInjectionDetector)
                    {
                        ACTkEditorGlobalStuff.CleanInjectionDetectorData();
                    }
                    else if (!File.Exists(ACTkEditorGlobalStuff.injectionDataPath))
                    {
                        ACTkPostprocessor.InjectionAssembliesScan();
                    }
                }

                EditorGUILayout.Space();

                if (GUILayout.Button("Edit Whitelist"))
                {
                    ACTkAssembliesWhitelist.ShowWindow();
                }

                GUILayout.Space(3);
            }

            EditorGUILayout.Space();

            using (ACTkEditorGUI.Vertical(ACTkEditorGUI.PanelWithBackground))
            {
                ACTkEditorGUI.DrawHeader("WallHack Detector settings (per-project)");
                GUILayout.Label("Wireframe module uses specific shader under the hood. Thus such shader should be included into the build to exist at runtime. To make sure it's get included, you may add it to the Always Included Shaders list using buttons below. You don't need to include it if you're not going to use Wireframe module.",
                                EditorStyles.wordWrappedLabel);

                ReadGraphicsAsset();

                if (graphicsSettingsAsset != null && includedShaders != null)
                {
                    // outputs whole included shaders list, use for debug
                    //EditorGUILayout.PropertyField(includedShaders, true);

                    var shaderIndex = GetWallhackDetectorShaderIndex();

                    EditorGUI.BeginChangeCheck();

                    if (shaderIndex != -1)
                    {
                        GUILayout.Label("Shader <b>is at</b> the Always Included Shaders list, you're good to go!", ACTkEditorGUI.RichLabel);
                        if (GUILayout.Button("Remove shader"))
                        {
                            includedShaders.DeleteArrayElementAtIndex(shaderIndex);
                            includedShaders.DeleteArrayElementAtIndex(shaderIndex);
                        }
                        EditorGUILayout.Space();
                    }
                    else
                    {
                        GUILayout.Label("Shader <b>is not</b> at the Always Included Shaders list.", ACTkEditorGUI.RichLabel);
                        using (ACTkEditorGUI.Horizontal())
                        {
                            if (GUILayout.Button("Include automatically", GUILayout.Width(minSize.x / 2f)))
                            {
                                var shader = Shader.Find(WireframeShaderName);
                                if (shader != null)
                                {
                                    includedShaders.InsertArrayElementAtIndex(includedShaders.arraySize);
                                    var newItem = includedShaders.GetArrayElementAtIndex(includedShaders.arraySize - 1);
                                    newItem.objectReferenceValue = shader;
                                }
                                else
                                {
                                    Debug.LogError("Can't find " + WireframeShaderName + " shader! Please report this to the  " +
                                                   ACTkEditorGlobalStuff.ReportEmail + " including your Unity version number.");
                                }
                            }

                            if (GUILayout.Button("Include manually (see readme.pdf)"))
                            {
#if UNITY_2018_3_OR_NEWER
                                SettingsService.OpenProjectSettings("Project/Graphics");
#else
                                EditorApplication.ExecuteMenuItem("Edit/Project Settings/Graphics");
#endif
                            }
                        }
                        GUILayout.Space(3);
                    }

                    if (EditorGUI.EndChangeCheck())
                    {
                        graphicsSettingsAsset.ApplyModifiedProperties();
                    }
                }
                else
                {
                    GUILayout.Label("Can't automatically control " + WireframeShaderName +
                                    " shader existence at the Always Included Shaders list. Please, manage this manually in Graphics Settings.");
                    if (GUILayout.Button("Open Graphics Settings"))
                    {
                        EditorApplication.ExecuteMenuItem("Edit/Project Settings/Graphics");
                    }
                }
            }

            EditorGUILayout.Space();

            using (ACTkEditorGUI.Vertical(ACTkEditorGUI.PanelWithBackground))
            {
                ACTkEditorGUI.DrawHeader("Conditional Compilation Symbols (per-project)");
                GUILayout.Label("Here you may switch conditional compilation symbols used in ACTk.\n" +
                                "Check Readme for more details on each symbol.", EditorStyles.wordWrappedLabel);
                EditorGUILayout.Space();
                if (symbolsData == null)
                {
                    symbolsData = GetSymbolsData();
                }

                /*if (GUILayout.Button("Reset"))
                 * {
                 *      var groups = (BuildTargetGroup[])Enum.GetValues(typeof(BuildTargetGroup));
                 *      foreach (BuildTargetGroup buildTargetGroup in groups)
                 *      {
                 *              PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, string.Empty);
                 *      }
                 * }*/

                using (ACTkEditorGUI.Horizontal())
                {
                    using (ACTkEditorGUI.Vertical())
                    {
                        GUILayout.Label("Debug Symbols", ACTkEditorGUI.LargeBoldLabel);
                        ACTkEditorGUI.Separator();

                        DrawSymbol(ref symbolsData.injectionDebug, ACTkEditorGlobalStuff.ConditionalSymbols.InjectionDebug, "Switches the Injection Detector debug.");
                        DrawSymbol(ref symbolsData.injectionDebugVerbose, ACTkEditorGlobalStuff.ConditionalSymbols.InjectionDebugVerbose, "Switches the Injection Detector verbose debug level.");
                        DrawSymbol(ref symbolsData.injectionDebugParanoid, ACTkEditorGlobalStuff.ConditionalSymbols.InjectionDebugParanoid, "Switches the Injection Detector paranoid debug level.");
                        DrawSymbol(ref symbolsData.wallhackDebug, ACTkEditorGlobalStuff.ConditionalSymbols.WallhackDebug, "Switches the WallHack Detector debug - you'll see the WallHack objects in scene and get extra information in console.");
                        DrawSymbol(ref symbolsData.detectionBacklogs, ACTkEditorGlobalStuff.ConditionalSymbols.DetectionBacklogs, "Enables additional logs in some detectors to make it easier to debug false positives.");
                    }

                    using (ACTkEditorGUI.Vertical())
                    {
                        GUILayout.Label("Compatibility Symbols", ACTkEditorGUI.LargeBoldLabel);
                        ACTkEditorGUI.Separator();

                        DrawSymbol(ref symbolsData.exposeThirdPartyIntegrationSymbol, ACTkEditorGlobalStuff.ConditionalSymbols.ThirdPartyIntegration, "Enable to let other third-party code in project know you have ACTk added.");
                        DrawSymbol(ref symbolsData.excludeObfuscation, ACTkEditorGlobalStuff.ConditionalSymbols.ExcludeObfuscation, "Enable if you use Unity-unaware obfuscators which support ObfuscationAttribute to help avoid names corruption.");
                        DrawSymbol(ref symbolsData.preventReadPhoneState, ACTkEditorGlobalStuff.ConditionalSymbols.PreventReadPhoneState, "Disables ObscuredPrefs Lock To Device functionality.");
                        DrawSymbol(ref symbolsData.preventInternetPermission, ACTkEditorGlobalStuff.ConditionalSymbols.PreventInternetPermission, "Disables TimeCheatingDetector functionality.");
                        DrawSymbol(ref symbolsData.obscuredAutoMigration, ACTkEditorGlobalStuff.ConditionalSymbols.ObscuredAutoMigration, "Enables automatic migration of ObscuredFloat and ObscuredDouble instances from the ACTk 1.5.2.0-1.5.8.0 to the 1.5.9.0+ format. Reduces these types performance a bit.");
                    }
                }

                GUILayout.Space(3);
            }
        }
Exemplo n.º 11
0
 private void Awake()
 {
     instance = this;
 }
Exemplo n.º 12
0
        private void OnGUI()
        {
            GUILayout.Label("Injection Detector settings (global)", ActEditorGUI.LargeBoldLabel);

            bool enableInjectionDetector = EditorPrefs.GetBool(ActEditorGlobalStuff.PREFS_INJECTION_ENABLED);

            EditorGUI.BeginChangeCheck();
            enableInjectionDetector = GUILayout.Toggle(enableInjectionDetector, "Enable Injection Detector");
            if (EditorGUI.EndChangeCheck())
            {
                EditorPrefs.SetBool(ActEditorGlobalStuff.PREFS_INJECTION_ENABLED, enableInjectionDetector);
                if (enableInjectionDetector && !ActPostprocessor.IsInjectionDetectorTargetCompatible())
                {
                    Debug.LogWarning(ActEditorGlobalStuff.LOG_PREFIX + "Injection Detector is not available on selected platform (" +
                                     EditorUserBuildSettings.activeBuildTarget + ")");
                }

                if (!enableInjectionDetector)
                {
                    ActEditorGlobalStuff.CleanInjectionDetectorData();
                }
                else if (!File.Exists(ActEditorGlobalStuff.injectionDataPath))
                {
                    ActPostprocessor.InjectionAssembliesScan();
                }
            }

            if (GUILayout.Button("Edit Whitelist"))
            {
                ActAssembliesWhitelist.ShowWindow();
            }

            EditorGUILayout.Space();
            GUILayout.Label("WallHack Detector settings (per-project)", ActEditorGUI.LargeBoldLabel);
            GUILayout.Label(
                "Wireframe module uses specific shader under the hood. Thus such shader should be included into the build to exist at runtime. To make sure it's get included, you may add it to the Always Included Shaders list using buttons below. You don't need to include it if you're not going to use Wireframe module.",
                EditorStyles.wordWrappedLabel);

            ReadGraphicsAsset();

            if (graphicsSettingsAsset != null && includedShaders != null)
            {
                // outputs whole included shaders list, use for debug
                //EditorGUILayout.PropertyField(includedShaders, true);

                int shaderIndex = GetWallhackDetectorShaderIndex();

                EditorGUI.BeginChangeCheck();

                if (shaderIndex != -1)
                {
                    GUILayout.Label("Shader already exists in the Always Included Shaders list, you're good to go!",
                                    EditorStyles.wordWrappedLabel);
                    if (GUILayout.Button("Remove shader"))
                    {
                        includedShaders.DeleteArrayElementAtIndex(shaderIndex);
                        includedShaders.DeleteArrayElementAtIndex(shaderIndex);
                    }
                }
                else
                {
                    GUILayout.Label("Shader doesn't exists in the Always Included Shaders list.", EditorStyles.wordWrappedLabel);
                    if (GUILayout.Button("Include shader"))
                    {
                        Shader shader = Shader.Find(WIREFRAME_SHADER_NAME);
                        if (shader != null)
                        {
                            includedShaders.InsertArrayElementAtIndex(includedShaders.arraySize);
                            SerializedProperty newItem = includedShaders.GetArrayElementAtIndex(includedShaders.arraySize - 1);
                            newItem.objectReferenceValue = shader;
                        }
                        else
                        {
                            Debug.LogError("Can't find " + WIREFRAME_SHADER_NAME + " shader! Please report this to the  " +
                                           ActEditorGlobalStuff.REPORT_EMAIL + " including your Unity version number.");
                        }
                    }
                    if (GUILayout.Button("Open Graphics Settings to manage it manually (see readme.pdf for details)"))
                    {
                        EditorApplication.ExecuteMenuItem("Edit/Project Settings/Graphics");
                    }
                }

                if (EditorGUI.EndChangeCheck())
                {
                    graphicsSettingsAsset.ApplyModifiedProperties();
                }
            }
            else
            {
                GUILayout.Label("Can't automatically control " + WIREFRAME_SHADER_NAME +
                                " shader existence at the Always Included Shaders list. Please, manage this manually in Graphics Settings.");
                if (GUILayout.Button("Open Graphics Settings"))
                {
                    EditorApplication.ExecuteMenuItem("Edit/Project Settings/Graphics");
                }
            }

            EditorGUILayout.Space();
            GUILayout.Label("Compilation symbols (per-project)", ActEditorGUI.LargeBoldLabel);
            GUILayout.Label("Here you may switch conditional compilation symbols used in ACTk.\n" +
                            "Check Readme for more details on each symbol.", EditorStyles.wordWrappedLabel);
            EditorGUILayout.Space();
            if (symbolsData == null)
            {
                symbolsData = GetSymbolsData();
            }

            /*if (GUILayout.Button("Reset"))
             * {
             *      var groups = (BuildTargetGroup[])Enum.GetValues(typeof(BuildTargetGroup));
             *      foreach (BuildTargetGroup buildTargetGroup in groups)
             *      {
             *              PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, string.Empty);
             *      }
             * }*/

            EditorGUI.BeginChangeCheck();
            symbolsData.injectionDebug = GUILayout.Toggle(symbolsData.injectionDebug, SymbolsData.ACTK_INJECTION_DEBUG);
            if (EditorGUI.EndChangeCheck())
            {
                if (symbolsData.injectionDebug)
                {
                    SetSymbol(SymbolsData.ACTK_INJECTION_DEBUG);
                }
                else
                {
                    RemoveSymbol(SymbolsData.ACTK_INJECTION_DEBUG);
                }

                symbolsData = GetSymbolsData();
            }

            EditorGUI.BeginChangeCheck();
            symbolsData.injectionDebugVerbose = GUILayout.Toggle(symbolsData.injectionDebugVerbose, SymbolsData.ACTK_INJECTION_DEBUG_VERBOSE);
            if (EditorGUI.EndChangeCheck())
            {
                if (symbolsData.injectionDebugVerbose)
                {
                    SetSymbol(SymbolsData.ACTK_INJECTION_DEBUG_VERBOSE);
                }
                else
                {
                    RemoveSymbol(SymbolsData.ACTK_INJECTION_DEBUG_VERBOSE);
                }

                symbolsData = GetSymbolsData();
            }

            EditorGUI.BeginChangeCheck();
            symbolsData.injectionDebugParanoid = GUILayout.Toggle(symbolsData.injectionDebugParanoid, SymbolsData.ACTK_INJECTION_DEBUG_PARANOID);
            if (EditorGUI.EndChangeCheck())
            {
                if (symbolsData.injectionDebugParanoid)
                {
                    SetSymbol(SymbolsData.ACTK_INJECTION_DEBUG_PARANOID);
                }
                else
                {
                    RemoveSymbol(SymbolsData.ACTK_INJECTION_DEBUG_PARANOID);
                }

                symbolsData = GetSymbolsData();
            }

            EditorGUI.BeginChangeCheck();
            symbolsData.wallhackDebug = GUILayout.Toggle(symbolsData.wallhackDebug, SymbolsData.ACTK_WALLHACK_DEBUG);
            if (EditorGUI.EndChangeCheck())
            {
                if (symbolsData.wallhackDebug)
                {
                    SetSymbol(SymbolsData.ACTK_WALLHACK_DEBUG);
                }
                else
                {
                    RemoveSymbol(SymbolsData.ACTK_WALLHACK_DEBUG);
                }

                symbolsData = GetSymbolsData();
            }

            EditorGUI.BeginChangeCheck();
            symbolsData.excludeObfuscation = GUILayout.Toggle(symbolsData.excludeObfuscation, SymbolsData.ACTK_EXCLUDE_OBFUSCATION);
            if (EditorGUI.EndChangeCheck())
            {
                if (symbolsData.excludeObfuscation)
                {
                    SetSymbol(SymbolsData.ACTK_EXCLUDE_OBFUSCATION);
                }
                else
                {
                    RemoveSymbol(SymbolsData.ACTK_EXCLUDE_OBFUSCATION);
                }

                symbolsData = GetSymbolsData();
            }

            EditorGUI.BeginChangeCheck();
            symbolsData.preventReadPhoneState = GUILayout.Toggle(symbolsData.preventReadPhoneState, SymbolsData.ACTK_PREVENT_READ_PHONE_STATE);
            if (EditorGUI.EndChangeCheck())
            {
                if (symbolsData.preventReadPhoneState)
                {
                    SetSymbol(SymbolsData.ACTK_PREVENT_READ_PHONE_STATE);
                }
                else
                {
                    RemoveSymbol(SymbolsData.ACTK_PREVENT_READ_PHONE_STATE);
                }

                symbolsData = GetSymbolsData();
            }

            EditorGUI.BeginChangeCheck();
            symbolsData.preventInternetPermission = GUILayout.Toggle(symbolsData.preventInternetPermission, SymbolsData.ACTK_PREVENT_INTERNET_PERMISSION);
            if (EditorGUI.EndChangeCheck())
            {
                if (symbolsData.preventInternetPermission)
                {
                    SetSymbol(SymbolsData.ACTK_PREVENT_INTERNET_PERMISSION);
                }
                else
                {
                    RemoveSymbol(SymbolsData.ACTK_PREVENT_INTERNET_PERMISSION);
                }

                symbolsData = GetSymbolsData();
            }
        }