我想知道如何更改“姓名”打印上显示的文本的颜色,但我几乎不知道如何做到这一点。我想让它变绿,感谢你的帮助或提示:D
// Name
ImGui::InputText("Name", selected_entry.name, 32);发布于 2021-07-14 00:28:10
整体上,可以使用样式更改文本颜色
ImGuiStyle* style = &ImGui::GetStyle();
style->Colors[ImGuiCol_Text] = ImVec4(1.0f, 1.0f, 1.0f, 1.00f);单个小部件的颜色可以通过推送/弹出样式进行更改
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));输出:

同样,如果您希望输入文本和标签使用不同的颜色,我建议您轻松地使用两个小部件。
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();

https://stackoverflow.com/questions/61853584
复制相似问题