Example #1
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        InitNullChecks();

        RAEditorUtilitys.DrawLine();
        EditorGUILayout.BeginHorizontal();
        //Main label:
        EditorGUILayout.LabelField("Splat map generation:", EditorStyles.boldLabel);
        //Online manual button:
        if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
        {
            Application.OpenURL("https://github.com/MicroGSD/RoadArchitect/wiki");
        }
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(6f);

        //Splat Resolution input:
        tSplatImageWidth.intValue  = GSDT.SplatResoWidth;
        tSplatImageHeight.intValue = GSDT.SplatResoHeight;
        EditorGUILayout.BeginHorizontal();
        tSplatReso = (SplatImageResoMatchingEnum)EditorGUILayout.Popup("Match resolutions:", (int)tSplatReso, TheSplatResoOptions);
        if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
        {
            tSplatImageWidth.intValue  = 1024;
            tSplatImageHeight.intValue = 1024;
        }
        EditorGUILayout.EndHorizontal();

        if (tSplatReso != SplatImageResoMatchingEnum.None)
        {
            if (tSplatReso == SplatImageResoMatchingEnum.MatchHeightmapResolution)
            {
                tSplatImageWidth.intValue  = GSDT.tTerrain.terrainData.heightmapResolution;
                tSplatImageHeight.intValue = GSDT.tTerrain.terrainData.heightmapResolution;
            }
            else if (tSplatReso == SplatImageResoMatchingEnum.MatchDetailResolution)
            {
                tSplatImageWidth.intValue  = GSDT.tTerrain.terrainData.detailResolution;
                tSplatImageHeight.intValue = GSDT.tTerrain.terrainData.detailResolution;
            }
            else if (tSplatReso == SplatImageResoMatchingEnum.MatchTerrainSize)
            {
                tSplatImageWidth.intValue  = (int)GSDT.tTerrain.terrainData.size.x;
                tSplatImageHeight.intValue = (int)GSDT.tTerrain.terrainData.size.z;
            }
            else if (tSplatReso == SplatImageResoMatchingEnum.Match512x512)
            {
                tSplatImageWidth.intValue  = 512;
                tSplatImageHeight.intValue = 512;
            }
            else if (tSplatReso == SplatImageResoMatchingEnum.Match1024x1024)
            {
                tSplatImageWidth.intValue  = 1024;
                tSplatImageHeight.intValue = 1024;
            }
            else if (tSplatReso == SplatImageResoMatchingEnum.Match2048x2048)
            {
                tSplatImageWidth.intValue  = 2048;
                tSplatImageHeight.intValue = 2048;
            }
            else if (tSplatReso == SplatImageResoMatchingEnum.Match4096x4096)
            {
                tSplatImageWidth.intValue  = 4096;
                tSplatImageHeight.intValue = 4096;
            }
            tSplatReso = SplatImageResoMatchingEnum.None;
        }

        //Splat image width input:
        tSplatImageWidth.intValue = EditorGUILayout.IntField("Splat image width:", tSplatImageWidth.intValue);
        //Splat image height input:
        tSplatImageHeight.intValue = EditorGUILayout.IntField("Splat image height:", tSplatImageHeight.intValue);


        //Splat background color input:
        EditorGUILayout.BeginHorizontal();
        tSplatBackgroundColor.colorValue = EditorGUILayout.ColorField("Splat background:", GSDT.SplatBackground);
        //Default button:
        if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
        {
            tSplatBackgroundColor.colorValue = new Color(0f, 0f, 0f, 1f);
        }
        EditorGUILayout.EndHorizontal();

        //Splat foreground color input:
        EditorGUILayout.BeginHorizontal();
        tSplatForegroundColor.colorValue = EditorGUILayout.ColorField("Splat foreground:", GSDT.SplatForeground);
        //Default button:
        if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
        {
            tSplatForegroundColor.colorValue = new Color(1f, 1f, 1f, 1f);
        }
        EditorGUILayout.EndHorizontal();

        //Splat width (meters) input:
        EditorGUILayout.BeginHorizontal();
        tSplatWidth.floatValue = EditorGUILayout.Slider("Splat width (meters):", GSDT.SplatWidth, 0.02f, 256f);
        //Default button:
        if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
        {
            tSplatWidth.floatValue = 30f;
        }
        EditorGUILayout.EndHorizontal();

        //Skip bridges:
        tSkipBridges.boolValue = EditorGUILayout.Toggle("Skip bridges: ", GSDT.SplatSkipBridges);

        //Skip tunnels:
        tSkipTunnels.boolValue = EditorGUILayout.Toggle("Skip tunnels: ", GSDT.SplatSkipTunnels);

        //Splat single road bool input:
        EditorGUILayout.BeginHorizontal();
        tSplatSingleRoad.boolValue = EditorGUILayout.Toggle("Splat a single road: ", GSDT.SplatSingleRoad);

        //Splat single road , road input:
        if (GSDT.SplatSingleRoad)
        {
            LoadSplatSingleChoice();
            tSplatSingleChoiceIndex.intValue = EditorGUILayout.Popup(GSDT.SplatSingleChoiceIndex, tRoadsString, GUILayout.Width(150f));
            tRoadSingleChoiceUID.stringValue = tRoads[tSplatSingleChoiceIndex.intValue];
        }

        EditorGUILayout.EndHorizontal();

        //Generate splatmap button:
        GUILayout.Space(8f);
        if (GUILayout.Button("Generate splatmap for this terrain"))
        {
            GenerateSplatMap();
        }
        GUILayout.Space(10f);

        if (GUI.changed)
        {
            serializedObject.ApplyModifiedProperties();
            //			EditorUtility.SetDirty(target); //Necessary?
        }
    }
Example #2
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        isUpdateGlobalMultithread   = false;
        isUpdateGlobalSaveMesh      = false;
        EditorStyles.label.wordWrap = true;
        InitChecks();

        //Add road button:
        RAEditorUtilitys.Line();
        if (GUILayout.Button("Add road", GSDLoadButton, GUILayout.Width(128f)))
        {// || GUILayout.Button(btnLoadText,GSDImageButton,GUILayout.Width(16f))){
            Selection.activeObject = GSDRS.AddRoad();
        }
        RAEditorUtilitys.Line();

        //Update all roads button:
        if (GUILayout.Button("Update all roads", EditorStyles.miniButton, GUILayout.Width(120f)))
        {
            GSDRS.UpdateAllRoads();
        }

        //Multi-threading input:
        isTempMultithreading.boolValue = EditorGUILayout.Toggle("Multi-threading enabled", GSDRS.opt_bMultithreading);
        if (isTempMultithreading.boolValue != GSDRS.opt_bMultithreading)
        {
            isUpdateGlobalMultithread = true;
        }

        //Save mesh assets input:
        isTempSaveMeshAssets.boolValue = EditorGUILayout.Toggle("Save mesh assets: ", GSDRS.opt_bSaveMeshes);
        if (isTempSaveMeshAssets.boolValue != GSDRS.opt_bSaveMeshes)
        {
            isUpdateGlobalSaveMesh = true;
        }
        if (GSDRS.opt_bSaveMeshes || isTempSaveMeshAssets.boolValue)
        {
            GUILayout.Label("WARNING: Saving meshes as assets is very slow and can increase road generation time by several minutes.", WarningLabelStyle);
        }

        //Online manual button:
        GUILayout.Space(4f);
        if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
        {
            // formerly http://microgsd.com/Support/RoadArchitectManual.aspx
            Application.OpenURL("https://github.com/MicroGSD/RoadArchitect/wiki");
        }

        //Offline manual button:
        GUILayout.Space(4f);
        if (GUILayout.Button("Offline manual", EditorStyles.miniButton, GUILayout.Width(120f)))
        {
            Application.OpenURL(GSD.Roads.GSDRoadUtilityEditor.GetRoadArchitectApplicationPath() + "/RoadArchitectManual.htm");
        }

        if (GSDRS.EditorPlayCamera == null)
        {
            GSDRS.EditorCameraSetSingle();
        }
        RAEditorUtilitys.Line();

        //		bHasDoneEither = false;

        //		//View intersection
        //		DoInter();

        //View bridges
        //		DoBridges();
        //		if(bHasDoneEither){
        //			EditorGUILayout.LabelField("* Hotkeys only function when this RoadArchitectSystem object is selected", EditorStyles.miniLabel);
        //		}

        //Hotkey check:
        DoHotKeyCheck();

        if (GUI.changed)
        {
            serializedObject.ApplyModifiedProperties();

            //Multithreading global change:
            if (isUpdateGlobalMultithread)
            {
                GSDRS.UpdateAllRoads_MultiThreadOptions();
            }

            //Save mesh assets global change:
            if (isUpdateGlobalSaveMesh)
            {
                GSDRS.UpdateAllRoads_SaveMeshesAsAssetsOptions();
            }
        }
    }