瀏覽代碼

Alias Vector4 to Color if necessary in Variant::GetColor(). Closes #1278.

Lasse Öörni 9 年之前
父節點
當前提交
152e090141
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      Source/Urho3D/Core/Variant.h

+ 2 - 2
Source/Urho3D/Core/Variant.h

@@ -947,8 +947,8 @@ public:
         return type_ == VAR_QUATERNION ? *reinterpret_cast<const Quaternion*>(&value_) : Quaternion::IDENTITY;
     }
 
-    /// Return color or default on type mismatch.
-    const Color& GetColor() const { return type_ == VAR_COLOR ? *reinterpret_cast<const Color*>(&value_) : Color::WHITE; }
+    /// Return color or default on type mismatch. Vector4 is aliased to Color if necessary.
+    const Color& GetColor() const { return (type_ == VAR_COLOR || type_ == VAR_VECTOR4) ? *reinterpret_cast<const Color*>(&value_) : Color::WHITE; }
 
     /// Return string or empty on type mismatch.
     const String& GetString() const { return type_ == VAR_STRING ? *reinterpret_cast<const String*>(&value_) : String::EMPTY; }