0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Godot(4.x)で色をRGBの0~255で表現したいのに,なぜか真っ白になっちゃう!!!

Posted at

警告
便宜上表記拡張子は.pyとしています.
脳内で.gdに変換してください.

TL;DR;

Colorではなく,Color8を使う.

.py
var colorBackground = Color8(r, g, b)

はじめに

最近 (UnityとUEに挫折して) Godot(Godot Engine v4.2.1)を触り始めた人です.
さて,背景色をスクリプトから灰色(128, 128, 128)に指定したいと思いColorというものを使って見たのですが,なぜか背景色は真っ白になってしまいました...ちゃんと(128, 128, 128)を渡しているのになぜだろう...

結論

はい.ドキュメントを読みましょう.0~255のRGBで指定するにはColor8というものを使う必要がありますね.Colorは0~1のRGBで指定するものみたいです.おそらく1以上のものは自動的に1に変換されていたから,(128, 128, 128)を渡したら自動的に(1, 1, 1)に変換されて,白色になっていたのでしょう.

.py
# r, g, bは0~1である必要がある.
var colorBackground0to1 = Color(r, g, b)

# r, g, bは0~255である必要がある.
var colorBackground0to255 = Color8(r, g, b)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?