Пример #1
0
        private void OnGUI()
        {
            if (whitelist == null)
            {
                whitelist = new List <AllowedAssembly>();
                LoadAndParseWhitelist();
            }

            var tmpStyle = new GUIStyle(EditorStyles.largeLabel)
            {
                alignment = TextAnchor.MiddleCenter,
                fontStyle = FontStyle.Bold
            };

            GUILayout.Label("User-defined Whitelist of Assemblies trusted by Injection Detector", tmpStyle);

            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
            var whitelistUpdated = false;

            var count = whitelist.Count;

            if (count > 0)
            {
                for (var i = 0; i < count; i++)
                {
                    var assembly = whitelist[i];
                    using (GUITools.Horizontal())
                    {
                        GUILayout.Label(assembly.ToString());
                        if (GUILayout.Button(new GUIContent("-", "Remove Assembly from Whitelist"), GUILayout.Width(30)))
                        {
                            whitelist.Remove(assembly);
                            whitelistUpdated = true;
                            break;
                        }
                    }
                }
            }
            else
            {
                tmpStyle = new GUIStyle(EditorStyles.largeLabel)
                {
                    alignment = TextAnchor.MiddleCenter
                };
                GUILayout.Label("- no Assemblies added so far (use buttons below to add) -", tmpStyle);
            }

            if (manualAssemblyWhitelisting)
            {
                manualAssemblyWhitelistingName = EditorGUILayout.TextField(manualAssemblyWhitelistingName);

                using (GUITools.Horizontal())
                {
                    if (GUILayout.Button("Save"))
                    {
                        try
                        {
                            if (manualAssemblyWhitelistingName.StartsWith("Cause:"))
                            {
                                throw new Exception("Please remove Cause: from the assembly name!");
                            }

                            var assName = new AssemblyName(manualAssemblyWhitelistingName.Trim());

                            var res = TryWhitelistAssemblyName(assName, true);
                            if (res != WhitelistingResult.Exists)
                            {
                                whitelistUpdated = true;
                            }
                            manualAssemblyWhitelisting     = false;
                            manualAssemblyWhitelistingName = InitialCustomName;
                        }
                        catch (Exception error)
                        {
                            ShowNotification(new GUIContent(error.Message));
                        }

                        GUI.FocusControl("");
                    }

                    if (GUILayout.Button("Cancel"))
                    {
                        manualAssemblyWhitelisting     = false;
                        manualAssemblyWhitelistingName = InitialCustomName;
                        GUI.FocusControl("");
                    }
                }
            }

            EditorGUILayout.EndScrollView();

            using (GUITools.Horizontal())
            {
                GUILayout.Space(20);
                if (GUILayout.Button("Add Assembly"))
                {
                    var assemblyPath = EditorUtility.OpenFilePanel("Choose an Assembly to add", "", "dll");
                    if (!string.IsNullOrEmpty(assemblyPath))
                    {
                        whitelistUpdated |= TryWhitelistAssemblies(new[] { assemblyPath }, true);
                    }
                }

                if (GUILayout.Button("Add Assemblies from filterFolder"))
                {
                    var selectedFolder = EditorUtility.OpenFolderPanel("Choose a filterFolder with Assemblies", "", "");
                    if (!string.IsNullOrEmpty(selectedFolder))
                    {
                        var libraries = EditorTools.FindLibrariesAt(selectedFolder);
                        whitelistUpdated |= TryWhitelistAssemblies(libraries);
                    }
                }

                if (!manualAssemblyWhitelisting)
                {
                    if (GUILayout.Button("Add Assembly manually"))
                    {
                        manualAssemblyWhitelisting = true;
                    }
                }

                if (count > 0)
                {
                    if (GUILayout.Button("Clear"))
                    {
                        if (EditorUtility.DisplayDialog("Please confirm",
                                                        "Are you sure you wish to completely clear your Injection Detector whitelist?", "Yes", "No"))
                        {
                            whitelist.Clear();
                            whitelistUpdated = true;
                        }
                    }
                }
                GUILayout.Space(20);
            }

            GUILayout.Space(20);

            if (whitelistUpdated)
            {
                WriteWhitelist();
            }
        }
Пример #2
0
        private static void DrawWallHackSection()
        {
            using (var changed = new EditorGUI.ChangeCheckScope())
            {
                var fold = GUITools.DrawFoldHeader("WallHack Detector", ACTkEditorPrefsSettings.WallHackFoldout);
                if (changed.changed)
                {
                    ACTkEditorPrefsSettings.WallHackFoldout = fold;
                }
            }

            if (!ACTkEditorPrefsSettings.WallHackFoldout)
            {
                return;
            }

            GUILayout.Space(-3f);

            using (GUITools.Vertical(GUITools.PanelWithBackground))
            {
                GUILayout.Label(
                    "Wireframe module uses own shader under the hood and it should be included into the build.",
                    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();

                    var status = shaderIndex != -1 ? ColorTools.GetGreenString() + ">included" : ColorTools.GetRedString() + ">not included";
                    GUILayout.Label("Shader status: <color=#" + status + "</color>", GUITools.RichLabel);

                    GUILayout.Space(5f);
                    EditorGUILayout.HelpBox("You don't need to include it if you're not going to use Wireframe module",
                                            MessageType.Info, true);
                    GUILayout.Space(5f);

                    if (shaderIndex != -1)
                    {
                        if (GUILayout.Button("Remove shader"))
                        {
                            includedShaders.DeleteArrayElementAtIndex(shaderIndex);
                            includedShaders.DeleteArrayElementAtIndex(shaderIndex);
                        }

                        GUILayout.Space(3);
                    }
                    else
                    {
                        using (GUITools.Horizontal())
                        {
                            if (GUILayout.Button("Auto Include"))
                            {
                                var shader = Shader.Find(WallHackDetector.WireframeShaderName);
                                if (shader != null)
                                {
                                    includedShaders.InsertArrayElementAtIndex(includedShaders.arraySize);
                                    var newItem = includedShaders.GetArrayElementAtIndex(includedShaders.arraySize - 1);
                                    newItem.objectReferenceValue = shader;
                                }
                                else
                                {
                                    Debug.LogError(EditorTools.ConstructError("Can't find " + WallHackDetector.WireframeShaderName +
                                                                              " shader!"));
                                }
                            }

                            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 " + WallHackDetector.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");
                    }
                }
            }
        }
Пример #3
0
        private static void DrawSettingsHeader()
        {
            using (new GUILayout.HorizontalScope())
            {
                GUILayout.Space(5f);
                using (new GUILayout.VerticalScope())
                {
                    GUILayout.Label("Version: " + ACTkConstants.Version);

                    using (new GUILayout.HorizontalScope())
                    {
                        if (GUITools.ImageButton("", "Visit Homepage", Icons.Home))
                        {
                            Application.OpenURL(Homepage);
                        }

                        if (GUITools.ImageButton("", "Ask at Forums", Icons.Forum))
                        {
                            Application.OpenURL(ForumLink);
                        }

                        if (GUITools.ImageButton("", "Get priority support", Icons.Support))
                        {
                            Application.OpenURL(SupportLink);
                        }

                        if (GUITools.ImageButton("", "Write a Review at the Asset Store, it will help a lot!", Icons.Star))
                        {
                            if (!Event.current.control)
                            {
                                Application.OpenURL(ReviewURL);
                            }
                            else
                            {
                                UnityEditorInternal.AssetStore.Open(ReviewURL);
                            }
                        }

                        GUILayout.Space(10f);

                        if (GUITools.ImageButton("", "Read Anti-Cheat Toolkit Manual (Readme.pdf)", Icons.Manual))
                        {
                            EditorTools.OpenReadme();
                        }

                        if (GUITools.ImageButton("", "Read API reference", Icons.API))
                        {
                            Application.OpenURL(APILink);
                        }

                        GUILayout.Space(10f);

                        if (GUITools.ImageButton("", "About", Icons.Help))
                        {
                            EditorUtility.DisplayDialog("About Anti-Cheat Toolkit v" + ACTkConstants.Version,
                                                        "Developer: Dmitriy Yukhanov\n" +
                                                        "Logo: Daniele Giardini \\m/\n" +
                                                        "Material Icons: Google\n" +
                                                        "Support: my lovely wife, daughters and you! <3\n\n" +
                                                        @"¯\_(ツ)_/¯", "Fine!");
                        }
                    }
                    GUILayout.Space(1f);
                }

                GUILayout.FlexibleSpace();

                var logo = Images.Logo;
                if (logo != null)
                {
                    logo.wrapMode = TextureWrapMode.Clamp;
                    var logoRect = EditorGUILayout.GetControlRect(GUILayout.Width(logo.width), GUILayout.Height(logo.height));
                    logoRect.y += 13;
                    GUI.DrawTexture(logoRect, logo);
                }
            }
        }
Пример #4
0
 public static void Delete()
 {
     instance = null;
     EditorTools.DeleteFile(Path);
 }