void OnGUI()
    {
        //All the buttons and the functions they correspond to...
        string tooltip = ("Vertex Influence Spheres allow for environment blending.");

        GUILayout.Label(new GUIContent("Vertex Influence Spheres", tooltip), EditorStyles.boldLabel);
        GUILayout.BeginHorizontal();
        tooltip =
            "This creates a vertex influence sphere. If you parent this to another object, it will only work on that object's children. This can be used to help performance. Otherwise it will apply to every paintable object in the scene";
        if (GUILayout.Button(new GUIContent("Create Sphere", tooltip)))
        {
            VertexInfluenceSphere.CreateVTXSphere();
            VertexInfluenceManager.SetAutoRefresh(autoRefresh);
        }
        tooltip = "This will paint the vertex colors on all the spheres in the scene. This will force a refresh no matter what, including if there are no spheres";
        if (GUILayout.Button(new GUIContent("Paint Spheres", tooltip)))
        {
            VertexInfluenceManager.RefreshAll();
            VertexInfluenceManager.SetAutoRefresh(autoRefresh);
        }
        GUILayout.EndHorizontal();
        tooltip =
            "Automatically paints whenever one of the spheres is modified. Note that this doesn't update in all cases, unlike the 'Paint Spheres' button. Also note this can get slow. To optimize, consider parenting influence spheres under groups so they don't have to check every mesh in the scene.";
        autoRefresh = EditorGUILayout.Toggle(new GUIContent("Auto-Paint", tooltip), autoRefresh);
        if (autoRefresh != autoRefreshStored)
        {
            VertexInfluenceManager.SetAutoRefresh(autoRefresh);
        }
        autoRefreshStored = autoRefresh;
        GUILayout.Label("Material Swap", EditorStyles.boldLabel);
        string[] matTintTypeStrings = new string[] { "Standard", "Sandstone" };
        materialTintType = GUILayout.SelectionGrid(materialTintType, matTintTypeStrings, 2);
        string[] matBlendTypeStrings = new string[] { "Snow", "Overgrowth", "Sand" };
        materialBlendType = GUILayout.SelectionGrid(materialBlendType, matBlendTypeStrings, 3);
        tooltip           = "Changes all relevant materials in the scene to use the materials specified above.";
        if (GUILayout.Button(new GUIContent("Swap Materials", tooltip)))
        {
            MaterialSwapManager.UpdateMaterials(materialTintType, materialBlendType);
        }
        tooltip = "Reverts all the materials to the default (standard + snow)";
        if (GUILayout.Button(new GUIContent("Revert Materials", tooltip)))
        {
            MaterialSwapManager.RevertMaterials();
        }
        tooltip  = "Checking this will automatically update new objects to be the material type you specified. Note this could get slow on larger scenes, and if so it is reccoemended you leave this off and manually swap materials from time to time";
        autoSwap = EditorGUILayout.Toggle(new GUIContent("Auto-Swap", tooltip), autoSwap);
        if (autoSwap != autoSwapStored)
        {
            MaterialSwapManager.SetAutoRefresh(autoSwap);
        }
        autoSwapStored = autoSwap;
        EditorGUILayout.HelpBox("Note: Every button and attribute has a rollover tooltip", MessageType.Info);
    }
示例#2
0
    public static void UpdateMaterials(int tintIndex, int materialIndex)
    {
        //First, we need to get a manager.
        GameObject manager = GameObject.Find("CDT_MaterialSwapManager");

        if (manager == null)
        {
            manager      = new GameObject();
            manager.name = "CDT_MaterialSwapManager";
            manager.AddComponent <MaterialSwapManager>();
        }
        MaterialSwapManager materialSwapManager = manager.GetComponent <MaterialSwapManager>();

        materialSwapManager.isSecondColor      = tintIndex;
        materialSwapManager.materialBlendIndex = materialIndex;
        //Then paint.
        materialSwapManager.StartPaintingRaw();
    }
示例#3
0
 public void StartPaintingRaw()
 {
     if (!Application.isPlaying)
     {
         //Runs all the functions to paint everything from scratch
         fullExecute = true;
         DetectVertexInfluenceSpheres();
         RevertOldMeshes();
         GetStaticMeshes();
         GetPaintableMeshes();
         PaintMeshes();
         if (vertexInfluenceSpheres.Count == 0)
         {
             DeleteMeClean();
         }
         FixScalarMeshes();
         MaterialSwapManager.UpdateMaterials();
         fullExecute = false;
     }
 }
示例#4
0
    public static void SetAutoRefresh(bool val)
    {
        MaterialSwapManager materialSwapManager = MaterialSwapManager.GetManager();

        materialSwapManager.autoRefresh = val;
    }
示例#5
0
    public static void UpdateMaterials()
    {
        MaterialSwapManager materialSwapManager = MaterialSwapManager.GetManager();

        materialSwapManager.StartPaintingRaw();
    }
示例#6
0
    public static void RevertMaterials()
    {
        MaterialSwapManager materialSwapManager = MaterialSwapManager.GetManager();

        materialSwapManager.RevertMeshesRaw();
    }