Пример #1
0
	public override void OnInspectorGUI(){
		serializedObject.Update();
		InitNullChecks();
		
		Line ();
		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("http://microgsd.com/Support/RoadArchitectManual.aspx");
		}
		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?
		}
	}
Пример #2
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?
        }
    }