我想弄清楚如何更改“名称”打印上显示的文本的颜色,但我对如何操作几乎一无所知。我想让它变成绿色,感谢帮助或提示:D
// Name
ImGui::InputText("Name", selected_entry.name, 32);
Run Code Online (Sandbox Code Playgroud)
Nav*_*een 17
全局文本颜色可以使用样式更改
ImGuiStyle* style = &ImGui::GetStyle();
style->Colors[ImGuiCol_Text] = ImVec4(1.0f, 1.0f, 1.0f, 1.00f);
Run Code Online (Sandbox Code Playgroud)
单个小部件的颜色可以通过推送/弹出样式单独更改
char txt_green[] = "text green";
char txt_def[] = "text default";
// Particular widget styling
ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0,255,0,255));
ImGui::InputText("##text1", txt_green, sizeof(txt_green));
ImGui::PopStyleColor();
...
// Use global style colors
ImGui::InputText("##text2", txt_def, sizeof(txt_def));
Run Code Online (Sandbox Code Playgroud)
输出:
同样,如果您想要输入文本和标签使用不同的颜色,我建议轻松使用两个小部件。
char txt_def[] = "text default";
ImGui::InputText("##Name", txt_def, sizeof(txt_def));
ImGui::SameLine();
ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(0, 255, 0, 255));
ImGui::Text("Name");
ImGui::PopStyleColor();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
28474 次 |
| 最近记录: |