浏览代码

Removed the mechanism of binary-serializing resource name hashes instead of resource names. This is to allow correct resource loading from binary scene files on platforms that cannot iterate the resources in the application installation (eg. Android). This also affects networking, downside is increased network payload size when resource attributes are transferred. All binary scenes saved with old Urho versions are also invalidated.

Lasse Öörni 12 年之前
父节点
当前提交
ee0e3aa663
共有 33 个文件被更改,包括 199 次插入5029 次删除
  1. 12 12
      Bin/Data/Scripts/Editor/AttributeEditor.as
  2. 2 4
      Docs/AngelScriptAPI.h
  3. 73 4803
      Docs/LuaScriptAPI.dox
  4. 2 4
      Docs/ScriptAPI.dox
  5. 1 1
      Source/Engine/Audio/SoundSource.cpp
  6. 8 8
      Source/Engine/Core/Variant.cpp
  7. 14 14
      Source/Engine/Core/Variant.h
  8. 3 3
      Source/Engine/Graphics/AnimatedModel.cpp
  9. 11 7
      Source/Engine/Graphics/AnimationController.cpp
  10. 2 0
      Source/Engine/Graphics/AnimationController.h
  11. 1 1
      Source/Engine/Graphics/BillboardSet.cpp
  12. 4 4
      Source/Engine/Graphics/CustomGeometry.cpp
  13. 1 1
      Source/Engine/Graphics/DecalSet.cpp
  14. 2 2
      Source/Engine/Graphics/Light.cpp
  15. 5 5
      Source/Engine/Graphics/StaticModel.cpp
  16. 2 2
      Source/Engine/Graphics/Terrain.cpp
  17. 4 4
      Source/Engine/IO/Deserializer.cpp
  18. 6 5
      Source/Engine/IO/Serializer.cpp
  19. 2 2
      Source/Engine/LuaScript/pkgs/Core/Variant.pkg
  20. 0 2
      Source/Engine/LuaScript/pkgs/Resource/ResourceCache.pkg
  21. 1 1
      Source/Engine/Physics/CollisionShape.cpp
  22. 6 11
      Source/Engine/Resource/Resource.h
  23. 7 66
      Source/Engine/Resource/ResourceCache.cpp
  24. 0 18
      Source/Engine/Resource/ResourceCache.h
  25. 8 24
      Source/Engine/Resource/XMLElement.cpp
  26. 13 13
      Source/Engine/Script/CoreAPI.cpp
  27. 0 2
      Source/Engine/Script/ResourceAPI.cpp
  28. 3 4
      Source/Engine/Script/ScriptInstance.cpp
  29. 1 1
      Source/Engine/UI/BorderImage.cpp
  30. 1 1
      Source/Engine/UI/Cursor.cpp
  31. 1 1
      Source/Engine/UI/Sprite.cpp
  32. 1 1
      Source/Engine/UI/Text.cpp
  33. 2 2
      Source/Engine/UI/Text3D.cpp

+ 12 - 12
Bin/Data/Scripts/Editor/AttributeEditor.as

@@ -465,7 +465,7 @@ void LoadAttributeEditor(UIElement@ parent, const Variant&in value, const Attrib
     }
     }
     else if (type == VAR_RESOURCEREF)
     else if (type == VAR_RESOURCEREF)
     {
     {
-        SetEditable(SetValue(parent.children[1].children[0], cache.GetResourceName(value.GetResourceRef().id), sameValue), editable && sameValue);
+        SetEditable(SetValue(parent.children[1].children[0], value.GetResourceRef().name, sameValue), editable && sameValue);
         SetEditable(parent.children[1].children[1], editable && sameValue);  // If editable then can pick
         SetEditable(parent.children[1].children[1], editable && sameValue);  // If editable then can pick
         for (uint i = 2; i < parent.children[1].numChildren; ++i)
         for (uint i = 2; i < parent.children[1].numChildren; ++i)
             SetEditable(parent.children[1].children[i], sameValue); // If same value then can open/edit/test
             SetEditable(parent.children[1].children[i], sameValue); // If same value then can open/edit/test
@@ -480,22 +480,22 @@ void LoadAttributeEditor(UIElement@ parent, const Variant&in value, const Attrib
             if (parent is null)
             if (parent is null)
                 break;
                 break;
 
 
-            StringHash firstID = refList.ids[subIndex];
-            bool idSameValue = true;
+            String firstName = refList.names[subIndex];
+            bool nameSameValue = true;
             if (!sameValue)
             if (!sameValue)
             {
             {
-                // Reevaluate each ID in the list
+                // Reevaluate each name in the list
                 for (uint i = 0; i < values.length; ++i)
                 for (uint i = 0; i < values.length; ++i)
                 {
                 {
                     ResourceRefList refList = values[i].GetResourceRefList();
                     ResourceRefList refList = values[i].GetResourceRefList();
-                    if (subIndex >= refList.length || refList.ids[subIndex] != firstID)
+                    if (subIndex >= refList.length || refList.names[subIndex] != firstName)
                     {
                     {
-                        idSameValue = false;
+                        nameSameValue = false;
                         break;
                         break;
                     }
                     }
                 }
                 }
             }
             }
-            SetEditable(SetValue(parent.children[1].children[0], cache.GetResourceName(firstID), idSameValue), editable && idSameValue);
+            SetEditable(SetValue(parent.children[1].children[0], firstName, nameSameValue), editable && nameSameValue);
         }
         }
     }
     }
     else if (type == VAR_VARIANTVECTOR)
     else if (type == VAR_VARIANTVECTOR)
@@ -619,7 +619,7 @@ void StoreAttributeEditor(UIElement@ parent, Array<Serializable@>@ serializables
             Variant[] values(1);
             Variant[] values(1);
             GetEditorValue(parent, VAR_RESOURCEREF, null, coordinate, values);
             GetEditorValue(parent, VAR_RESOURCEREF, null, coordinate, values);
             ResourceRef ref = values[0].GetResourceRef();
             ResourceRef ref = values[0].GetResourceRef();
-            refList.ids[subIndex] = ref.id;
+            refList.names[subIndex] = ref.name;
             serializables[i].attributes[index] = Variant(refList);
             serializables[i].attributes[index] = Variant(refList);
         }
         }
     }
     }
@@ -710,7 +710,7 @@ void GetEditorValue(UIElement@ parent, VariantType type, Array<String>@ enumName
     {
     {
         LineEdit@ attrEdit = parent.children[0];
         LineEdit@ attrEdit = parent.children[0];
         ResourceRef ref;
         ResourceRef ref;
-        ref.id = StringHash(attrEdit.text.Trimmed());
+        ref.name = attrEdit.text.Trimmed();
         ref.type = ShortStringHash(attrEdit.vars[TYPE_VAR].GetUInt());
         ref.type = ShortStringHash(attrEdit.vars[TYPE_VAR].GetUInt());
         FillValue(values, Variant(ref));
         FillValue(values, Variant(ref));
     }
     }
@@ -965,7 +965,7 @@ void PickResourceDone(StringHash eventType, VariantMap& eventData)
         {
         {
             ResourceRef ref = target.attributes[resourcePickIndex].GetResourceRef();
             ResourceRef ref = target.attributes[resourcePickIndex].GetResourceRef();
             ref.type = res.type;
             ref.type = res.type;
-            ref.id = StringHash(res.name);
+            ref.name = res.name;
             target.attributes[resourcePickIndex] = Variant(ref);
             target.attributes[resourcePickIndex] = Variant(ref);
             target.ApplyAttributes();
             target.ApplyAttributes();
         }
         }
@@ -974,7 +974,7 @@ void PickResourceDone(StringHash eventType, VariantMap& eventData)
             ResourceRefList refList = target.attributes[resourcePickIndex].GetResourceRefList();
             ResourceRefList refList = target.attributes[resourcePickIndex].GetResourceRefList();
             if (resourcePickSubIndex < refList.length)
             if (resourcePickSubIndex < refList.length)
             {
             {
-                refList.ids[resourcePickSubIndex] = StringHash(res.name);
+                refList.names[resourcePickSubIndex] = res.name;
                 target.attributes[resourcePickIndex] = Variant(refList);
                 target.attributes[resourcePickIndex] = Variant(refList);
                 target.ApplyAttributes();
                 target.ApplyAttributes();
             }
             }
@@ -984,7 +984,7 @@ void PickResourceDone(StringHash eventType, VariantMap& eventData)
             Array<Variant>@ attrs = target.attributes[resourcePickIndex].GetVariantVector();
             Array<Variant>@ attrs = target.attributes[resourcePickIndex].GetVariantVector();
             ResourceRef ref = attrs[resourcePickSubIndex].GetResourceRef();
             ResourceRef ref = attrs[resourcePickSubIndex].GetResourceRef();
             ref.type = res.type;
             ref.type = res.type;
-            ref.id = StringHash(res.name);
+            ref.name = res.name;
             attrs[resourcePickSubIndex] = ref;
             attrs[resourcePickSubIndex] = ref;
             target.attributes[resourcePickIndex] = Variant(attrs);
             target.attributes[resourcePickIndex] = Variant(attrs);
             target.ApplyAttributes();
             target.ApplyAttributes();

+ 2 - 4
Docs/AngelScriptAPI.h

@@ -885,7 +885,7 @@ class ResourceRef
 
 
 // Properties:
 // Properties:
 ShortStringHash type;
 ShortStringHash type;
-StringHash id;
+String name;
 };
 };
 
 
 class ResourceRefList
 class ResourceRefList
@@ -898,7 +898,7 @@ void Resize(uint);
 uint length;
 uint length;
 /* (readonly) */
 /* (readonly) */
 bool empty;
 bool empty;
-Array<StringHash> ids;
+Array<String> names;
 ShortStringHash type;
 ShortStringHash type;
 };
 };
 
 
@@ -1457,10 +1457,8 @@ bool Exists(const String&) const;
 File GetFile(const String&);
 File GetFile(const String&);
 String GetPreferredResourceDir(const String&) const;
 String GetPreferredResourceDir(const String&) const;
 String SanitateResourceName(const String&) const;
 String SanitateResourceName(const String&) const;
-const String& GetResourceName(StringHash) const;
 String GetResourceFileName(const String&) const;
 String GetResourceFileName(const String&) const;
 Resource GetResource(const String&, const String&);
 Resource GetResource(const String&, const String&);
-Resource GetResource(ShortStringHash, StringHash);
 Resource GetResource(ShortStringHash, const String&);
 Resource GetResource(ShortStringHash, const String&);
 
 
 // Properties:
 // Properties:

文件差异内容过多而无法显示
+ 73 - 4803
Docs/LuaScriptAPI.dox


+ 2 - 4
Docs/ScriptAPI.dox

@@ -885,7 +885,7 @@ Properties:
 Properties:
 Properties:
 
 
 - ShortStringHash type
 - ShortStringHash type
-- StringHash id
+- String name
 
 
 
 
 ### ResourceRefList
 ### ResourceRefList
@@ -898,7 +898,7 @@ Properties:
 
 
 - uint length (readonly)
 - uint length (readonly)
 - bool empty (readonly)
 - bool empty (readonly)
-- StringHash[] ids
+- String[] names
 - ShortStringHash type
 - ShortStringHash type
 
 
 
 
@@ -1398,10 +1398,8 @@ Methods:
 - File@ GetFile(const String&)
 - File@ GetFile(const String&)
 - String GetPreferredResourceDir(const String&) const
 - String GetPreferredResourceDir(const String&) const
 - String SanitateResourceName(const String&) const
 - String SanitateResourceName(const String&) const
-- const String& GetResourceName(StringHash) const
 - String GetResourceFileName(const String&) const
 - String GetResourceFileName(const String&) const
 - Resource@ GetResource(const String&, const String&)
 - Resource@ GetResource(const String&, const String&)
-- Resource@ GetResource(ShortStringHash, StringHash)
 - Resource@ GetResource(ShortStringHash, const String&)
 - Resource@ GetResource(ShortStringHash, const String&)
 
 
 Properties:
 Properties:

+ 1 - 1
Source/Engine/Audio/SoundSource.cpp

@@ -498,7 +498,7 @@ void SoundSource::Mix(int* dest, unsigned samples, int mixRate, bool stereo, boo
 void SoundSource::SetSoundAttr(ResourceRef value)
 void SoundSource::SetSoundAttr(ResourceRef value)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    Play(cache->GetResource<Sound>(value.id_));
+    Play(cache->GetResource<Sound>(value.name_));
 }
 }
 
 
 void SoundSource::SetPositionAttr(int value)
 void SoundSource::SetPositionAttr(int value)

+ 8 - 8
Source/Engine/Core/Variant.cpp

@@ -231,7 +231,7 @@ void Variant::FromString(VariantType type, const char* value)
                 SetType(VAR_RESOURCEREF);
                 SetType(VAR_RESOURCEREF);
                 ResourceRef& ref = *(reinterpret_cast<ResourceRef*>(&value_));
                 ResourceRef& ref = *(reinterpret_cast<ResourceRef*>(&value_));
                 ref.type_ = values[0];
                 ref.type_ = values[0];
-                ref.id_ = values[1];
+                ref.name_ = values[1];
             }
             }
         }
         }
         break;
         break;
@@ -244,9 +244,9 @@ void Variant::FromString(VariantType type, const char* value)
                 SetType(VAR_RESOURCEREFLIST);
                 SetType(VAR_RESOURCEREFLIST);
                 ResourceRefList& refList = *(reinterpret_cast<ResourceRefList*>(&value_));
                 ResourceRefList& refList = *(reinterpret_cast<ResourceRefList*>(&value_));
                 refList.type_ = values[0];
                 refList.type_ = values[0];
-                refList.ids_.Resize(values.Size() - 1);
+                refList.names_.Resize(values.Size() - 1);
                 for (unsigned i = 1; i < values.Size(); ++i)
                 for (unsigned i = 1; i < values.Size(); ++i)
-                    refList.ids_[i - 1] = values[i];
+                    refList.names_[i - 1] = values[i];
             }
             }
         }
         }
         break;
         break;
@@ -332,7 +332,7 @@ String Variant::ToString() const
 
 
     default:
     default:
         // VAR_RESOURCEREF, VAR_RESOURCEREFLIST, VAR_VARIANTVECTOR, VAR_VARIANTMAP
         // VAR_RESOURCEREF, VAR_RESOURCEREFLIST, VAR_VARIANTVECTOR, VAR_VARIANTMAP
-        // Reference string serialization requires hash-to-name mapping from the context & subsystems. Can not support here
+        // Reference string serialization requires typehash-to-name mapping from the context. Can not support here
         // Also variant map or vector string serialization is not supported. XML or binary save should be used instead
         // Also variant map or vector string serialization is not supported. XML or binary save should be used instead
         return String::EMPTY;
         return String::EMPTY;
     }
     }
@@ -377,14 +377,14 @@ bool Variant::IsZero() const
         return value_.ptr_ == 0;
         return value_.ptr_ == 0;
 
 
     case VAR_RESOURCEREF:
     case VAR_RESOURCEREF:
-        return reinterpret_cast<const ResourceRef*>(&value_)->id_ == StringHash::ZERO;
+        return reinterpret_cast<const ResourceRef*>(&value_)->name_.Empty();
 
 
     case VAR_RESOURCEREFLIST:
     case VAR_RESOURCEREFLIST:
     {
     {
-        Vector<StringHash> ids = reinterpret_cast<const ResourceRefList*>(&value_)->ids_;
-        for (Vector<StringHash>::ConstIterator i = ids.Begin(); i != ids.End(); ++i)
+        const Vector<String>& names = reinterpret_cast<const ResourceRefList*>(&value_)->names_;
+        for (Vector<String>::ConstIterator i = names.Begin(); i != names.End(); ++i)
         {
         {
-            if (*i != StringHash::ZERO)
+            if (!i->Empty())
                 return false;
                 return false;
         }
         }
         return true;
         return true;

+ 14 - 14
Source/Engine/Core/Variant.h

@@ -103,29 +103,29 @@ struct URHO3D_API ResourceRef
     {
     {
     }
     }
 
 
-    /// Construct with type and id.
-    ResourceRef(ShortStringHash type, StringHash id) :
+    /// Construct with type and resource name.
+    ResourceRef(ShortStringHash type, const String& name) :
         type_(type),
         type_(type),
-        id_(id)
+        name_(name)
     {
     {
     }
     }
 
 
     // Construct from another ResourceRef.
     // Construct from another ResourceRef.
     ResourceRef(const ResourceRef& rhs) :
     ResourceRef(const ResourceRef& rhs) :
         type_(rhs.type_),
         type_(rhs.type_),
-        id_(rhs.id_)
+        name_(rhs.name_)
     {
     {
     }
     }
 
 
     /// Object type.
     /// Object type.
     ShortStringHash type_;
     ShortStringHash type_;
-    /// Object identifier (name hash.)
-    StringHash id_;
+    /// Object name.
+    String name_;
 
 
     /// Test for equality with another reference.
     /// Test for equality with another reference.
-    bool operator == (const ResourceRef& rhs) const { return type_ == rhs.type_ && id_ == rhs.id_; }
+    bool operator == (const ResourceRef& rhs) const { return type_ == rhs.type_ && name_ == rhs.name_; }
     /// Test for inequality with another reference.
     /// Test for inequality with another reference.
-    bool operator != (const ResourceRef& rhs) const { return type_ != rhs.type_ || id_ != rhs.id_; }
+    bool operator != (const ResourceRef& rhs) const { return type_ != rhs.type_ || name_ != rhs.name_; }
 };
 };
 
 
 /// %List of typed resource references.
 /// %List of typed resource references.
@@ -142,21 +142,21 @@ struct URHO3D_API ResourceRefList
     {
     {
     }
     }
     /// Construct with type and id list.
     /// Construct with type and id list.
-    ResourceRefList(ShortStringHash type, const Vector<StringHash>& ids) :
+    ResourceRefList(ShortStringHash type, const Vector<String>& names) :
         type_(type),
         type_(type),
-        ids_(ids)
+        names_(names)
     {
     {
     }
     }
 
 
     /// Object type.
     /// Object type.
     ShortStringHash type_;
     ShortStringHash type_;
-    /// List of object identifiers (name hashes).
-    Vector<StringHash> ids_;
+    /// List of object names.
+    Vector<String> names_;
 
 
     /// Test for equality with another reference list.
     /// Test for equality with another reference list.
-    bool operator == (const ResourceRefList& rhs) const { return type_ == rhs.type_ && ids_ == rhs.ids_; }
+    bool operator == (const ResourceRefList& rhs) const { return type_ == rhs.type_ && names_ == rhs.names_; }
     /// Test for inequality with another reference list.
     /// Test for inequality with another reference list.
-    bool operator != (const ResourceRefList& rhs) const { return type_ != rhs.type_ || ids_ != rhs.ids_; }
+    bool operator != (const ResourceRefList& rhs) const { return type_ != rhs.type_ || names_ != rhs.names_; }
 };
 };
 
 
 class Variant;
 class Variant;

+ 3 - 3
Source/Engine/Graphics/AnimatedModel.cpp

@@ -739,7 +739,7 @@ void AnimatedModel::SetModelAttr(ResourceRef value)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     // When loading a scene, set model without creating the bone nodes (will be assigned later during post-load)
     // When loading a scene, set model without creating the bone nodes (will be assigned later during post-load)
-    SetModel(cache->GetResource<Model>(value.id_), !loading_);
+    SetModel(cache->GetResource<Model>(value.name_), !loading_);
 }
 }
 
 
 void AnimatedModel::SetBonesEnabledAttr(VariantVector value)
 void AnimatedModel::SetBonesEnabledAttr(VariantVector value)
@@ -768,7 +768,7 @@ void AnimatedModel::SetAnimationStatesAttr(VariantVector value)
         {
         {
             // Note: null animation is allowed here for editing
             // Note: null animation is allowed here for editing
             const ResourceRef& animRef = value[index++].GetResourceRef();
             const ResourceRef& animRef = value[index++].GetResourceRef();
-            SharedPtr<AnimationState> newState(new AnimationState(this, cache->GetResource<Animation>(animRef.id_)));
+            SharedPtr<AnimationState> newState(new AnimationState(this, cache->GetResource<Animation>(animRef.name_)));
             animationStates_.Push(newState);
             animationStates_.Push(newState);
 
 
             newState->SetStartBone(skeleton_.GetBone(value[index++].GetString()));
             newState->SetStartBone(skeleton_.GetBone(value[index++].GetString()));
@@ -819,7 +819,7 @@ VariantVector AnimatedModel::GetAnimationStatesAttr() const
         AnimationState* state = *i;
         AnimationState* state = *i;
         Animation* animation = state->GetAnimation();
         Animation* animation = state->GetAnimation();
         Bone* startBone = state->GetStartBone();
         Bone* startBone = state->GetStartBone();
-        ret.Push(ResourceRef(Animation::GetTypeStatic(), animation ? animation->GetNameHash() : StringHash()));
+        ret.Push(GetResourceRef(animation, Animation::GetTypeStatic()));
         ret.Push(startBone ? startBone->name_ : String::EMPTY);
         ret.Push(startBone ? startBone->name_ : String::EMPTY);
         ret.Push(state->IsLooped());
         ret.Push(state->IsLooped());
         ret.Push(state->GetWeight());
         ret.Push(state->GetWeight());

+ 11 - 7
Source/Engine/Graphics/AnimationController.cpp

@@ -168,6 +168,7 @@ bool AnimationController::Play(const String& name, unsigned char layer, bool loo
     {
     {
         AnimationControl newControl;
         AnimationControl newControl;
         Animation* animation = state->GetAnimation();
         Animation* animation = state->GetAnimation();
+        newControl.name_ = animation->GetName();
         newControl.hash_ = animation->GetNameHash();
         newControl.hash_ = animation->GetNameHash();
         animations_.Push(newControl);
         animations_.Push(newControl);
         index = animations_.Size() - 1;
         index = animations_.Size() - 1;
@@ -494,7 +495,8 @@ void AnimationController::SetAnimationsAttr(VariantVector value)
     while (index + 4 < value.Size())    // Prevent out-of-bound index access
     while (index + 4 < value.Size())    // Prevent out-of-bound index access
     {
     {
         AnimationControl newControl;
         AnimationControl newControl;
-        newControl.hash_ = value[index++].GetStringHash();
+        newControl.name_ = value[index++].GetString();
+        newControl.hash_ = StringHash(newControl.name_);
         newControl.speed_ = value[index++].GetFloat();
         newControl.speed_ = value[index++].GetFloat();
         newControl.targetWeight_ = value[index++].GetFloat();
         newControl.targetWeight_ = value[index++].GetFloat();
         newControl.fadeTime_ = value[index++].GetFloat();
         newControl.fadeTime_ = value[index++].GetFloat();
@@ -515,14 +517,15 @@ void AnimationController::SetNetAnimationsAttr(const PODVector<unsigned char>& v
     unsigned numAnimations = buf.ReadVLE();
     unsigned numAnimations = buf.ReadVLE();
     while (numAnimations--)
     while (numAnimations--)
     {
     {
-        StringHash animHash = buf.ReadStringHash();
+        String animName = buf.ReadString();
+        StringHash animHash(animName);
         processedAnimations.Insert(animHash);
         processedAnimations.Insert(animHash);
         
         
         // Check if the animation state exists. If not, add new
         // Check if the animation state exists. If not, add new
         AnimationState* state = GetAnimationState(animHash);
         AnimationState* state = GetAnimationState(animHash);
         if (!state)
         if (!state)
         {
         {
-            Animation* newAnimation = GetSubsystem<ResourceCache>()->GetResource<Animation>(animHash);
+            Animation* newAnimation = GetSubsystem<ResourceCache>()->GetResource<Animation>(animName);
             state = AddAnimationState(newAnimation);
             state = AddAnimationState(newAnimation);
             if (!state)
             if (!state)
             {
             {
@@ -540,6 +543,7 @@ void AnimationController::SetNetAnimationsAttr(const PODVector<unsigned char>& v
         if (index == animations_.Size())
         if (index == animations_.Size())
         {
         {
             AnimationControl newControl;
             AnimationControl newControl;
+            newControl.name_ = animName;
             newControl.hash_ = animHash;
             newControl.hash_ = animHash;
             animations_.Push(newControl);
             animations_.Push(newControl);
         }
         }
@@ -617,7 +621,7 @@ void AnimationController::SetNodeAnimationStatesAttr(VariantVector value)
         {
         {
             // Note: null animation is allowed here for editing
             // Note: null animation is allowed here for editing
             const ResourceRef& animRef = value[index++].GetResourceRef();
             const ResourceRef& animRef = value[index++].GetResourceRef();
-            SharedPtr<AnimationState> newState(new AnimationState(GetNode(), cache->GetResource<Animation>(animRef.id_)));
+            SharedPtr<AnimationState> newState(new AnimationState(GetNode(), cache->GetResource<Animation>(animRef.name_)));
             nodeAnimationStates_.Push(newState);
             nodeAnimationStates_.Push(newState);
 
 
             newState->SetLooped(value[index++].GetBool());
             newState->SetLooped(value[index++].GetBool());
@@ -638,7 +642,7 @@ VariantVector AnimationController::GetAnimationsAttr() const
     ret.Reserve(animations_.Size() * 5);
     ret.Reserve(animations_.Size() * 5);
     for (Vector<AnimationControl>::ConstIterator i = animations_.Begin(); i != animations_.End(); ++i)
     for (Vector<AnimationControl>::ConstIterator i = animations_.Begin(); i != animations_.End(); ++i)
     {
     {
-        ret.Push(i->hash_);
+        ret.Push(i->name_);
         ret.Push(i->speed_);
         ret.Push(i->speed_);
         ret.Push(i->targetWeight_);
         ret.Push(i->targetWeight_);
         ret.Push(i->fadeTime_);
         ret.Push(i->fadeTime_);
@@ -680,7 +684,7 @@ const PODVector<unsigned char>& AnimationController::GetNetAnimationsAttr() cons
         if (i->setWeightTtl_ > 0.0f)
         if (i->setWeightTtl_ > 0.0f)
             ctrl |= CTRL_SETWEIGHT;
             ctrl |= CTRL_SETWEIGHT;
         
         
-        attrBuffer_.WriteStringHash(i->hash_);
+        attrBuffer_.WriteString(i->name_);
         attrBuffer_.WriteUByte(ctrl);
         attrBuffer_.WriteUByte(ctrl);
         attrBuffer_.WriteUByte(state->GetLayer());
         attrBuffer_.WriteUByte(state->GetLayer());
         attrBuffer_.WriteShort((short)Clamp(i->speed_ * 2048.0f, -32767.0f, 32767.0f));
         attrBuffer_.WriteShort((short)Clamp(i->speed_ * 2048.0f, -32767.0f, 32767.0f));
@@ -714,7 +718,7 @@ VariantVector AnimationController::GetNodeAnimationStatesAttr() const
     {
     {
         AnimationState* state = *i;
         AnimationState* state = *i;
         Animation* animation = state->GetAnimation();
         Animation* animation = state->GetAnimation();
-        ret.Push(ResourceRef(Animation::GetTypeStatic(), animation ? animation->GetNameHash() : StringHash()));
+        ret.Push(GetResourceRef(animation, Animation::GetTypeStatic()));
         ret.Push(state->IsLooped());
         ret.Push(state->IsLooped());
         ret.Push(state->GetTime());
         ret.Push(state->GetTime());
     }
     }

+ 2 - 0
Source/Engine/Graphics/AnimationController.h

@@ -51,6 +51,8 @@ struct AnimationControl
     {
     {
     }
     }
 
 
+    /// Animation resource name.
+    String name_;
     /// Animation resource name hash.
     /// Animation resource name hash.
     StringHash hash_;
     StringHash hash_;
     /// Animation speed.
     /// Animation speed.

+ 1 - 1
Source/Engine/Graphics/BillboardSet.cpp

@@ -236,7 +236,7 @@ Billboard* BillboardSet::GetBillboard(unsigned index)
 void BillboardSet::SetMaterialAttr(ResourceRef value)
 void BillboardSet::SetMaterialAttr(ResourceRef value)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    SetMaterial(cache->GetResource<Material>(value.id_));
+    SetMaterial(cache->GetResource<Material>(value.name_));
 }
 }
 
 
 void BillboardSet::SetBillboardsAttr(VariantVector value)
 void BillboardSet::SetBillboardsAttr(VariantVector value)

+ 4 - 4
Source/Engine/Graphics/CustomGeometry.cpp

@@ -414,8 +414,8 @@ void CustomGeometry::SetGeometryDataAttr(PODVector<unsigned char> value)
 void CustomGeometry::SetMaterialsAttr(const ResourceRefList& value)
 void CustomGeometry::SetMaterialsAttr(const ResourceRefList& value)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    for (unsigned i = 0; i < value.ids_.Size(); ++i)
-        SetMaterial(i, cache->GetResource<Material>(value.ids_[i]));
+    for (unsigned i = 0; i < value.names_.Size(); ++i)
+        SetMaterial(i, cache->GetResource<Material>(value.names_[i]));
 }
 }
 
 
 PODVector<unsigned char> CustomGeometry::GetGeometryDataAttr() const
 PODVector<unsigned char> CustomGeometry::GetGeometryDataAttr() const
@@ -451,9 +451,9 @@ PODVector<unsigned char> CustomGeometry::GetGeometryDataAttr() const
 
 
 const ResourceRefList& CustomGeometry::GetMaterialsAttr() const
 const ResourceRefList& CustomGeometry::GetMaterialsAttr() const
 {
 {
-    materialsAttr_.ids_.Resize(batches_.Size());
+    materialsAttr_.names_.Resize(batches_.Size());
     for (unsigned i = 0; i < batches_.Size(); ++i)
     for (unsigned i = 0; i < batches_.Size(); ++i)
-        materialsAttr_.ids_[i] = batches_[i].material_ ? batches_[i].material_->GetNameHash() : StringHash();
+        materialsAttr_.names_[i] = GetResourceName(batches_[i].material_);
     
     
     return materialsAttr_;
     return materialsAttr_;
 }
 }

+ 1 - 1
Source/Engine/Graphics/DecalSet.cpp

@@ -504,7 +504,7 @@ Material* DecalSet::GetMaterial() const
 void DecalSet::SetMaterialAttr(ResourceRef value)
 void DecalSet::SetMaterialAttr(ResourceRef value)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    SetMaterial(cache->GetResource<Material>(value.id_));
+    SetMaterial(cache->GetResource<Material>(value.name_));
 }
 }
 
 
 void DecalSet::SetDecalsAttr(PODVector<unsigned char> value)
 void DecalSet::SetDecalsAttr(PODVector<unsigned char> value)

+ 2 - 2
Source/Engine/Graphics/Light.cpp

@@ -427,13 +427,13 @@ const Matrix3x4& Light::GetVolumeTransform(Camera* camera)
 void Light::SetRampTextureAttr(ResourceRef value)
 void Light::SetRampTextureAttr(ResourceRef value)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    rampTexture_ = static_cast<Texture*>(cache->GetResource(value.type_, value.id_));
+    rampTexture_ = static_cast<Texture*>(cache->GetResource(value.type_, value.name_));
 }
 }
 
 
 void Light::SetShapeTextureAttr(ResourceRef value)
 void Light::SetShapeTextureAttr(ResourceRef value)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    shapeTexture_ = static_cast<Texture*>(cache->GetResource(value.type_, value.id_));
+    shapeTexture_ = static_cast<Texture*>(cache->GetResource(value.type_, value.name_));
 }
 }
 
 
 ResourceRef Light::GetRampTextureAttr() const
 ResourceRef Light::GetRampTextureAttr() const

+ 5 - 5
Source/Engine/Graphics/StaticModel.cpp

@@ -370,14 +370,14 @@ void StaticModel::SetNumGeometries(unsigned num)
 void StaticModel::SetModelAttr(ResourceRef value)
 void StaticModel::SetModelAttr(ResourceRef value)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    SetModel(cache->GetResource<Model>(value.id_));
+    SetModel(cache->GetResource<Model>(value.name_));
 }
 }
 
 
 void StaticModel::SetMaterialsAttr(const ResourceRefList& value)
 void StaticModel::SetMaterialsAttr(const ResourceRefList& value)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    for (unsigned i = 0; i < value.ids_.Size(); ++i)
-        SetMaterial(i, cache->GetResource<Material>(value.ids_[i]));
+    for (unsigned i = 0; i < value.names_.Size(); ++i)
+        SetMaterial(i, cache->GetResource<Material>(value.names_[i]));
 }
 }
 
 
 ResourceRef StaticModel::GetModelAttr() const
 ResourceRef StaticModel::GetModelAttr() const
@@ -387,9 +387,9 @@ ResourceRef StaticModel::GetModelAttr() const
 
 
 const ResourceRefList& StaticModel::GetMaterialsAttr() const
 const ResourceRefList& StaticModel::GetMaterialsAttr() const
 {
 {
-    materialsAttr_.ids_.Resize(batches_.Size());
+    materialsAttr_.names_.Resize(batches_.Size());
     for (unsigned i = 0; i < batches_.Size(); ++i)
     for (unsigned i = 0; i < batches_.Size(); ++i)
-        materialsAttr_.ids_[i] = batches_[i].material_ ? batches_[i].material_->GetNameHash() : StringHash();
+        materialsAttr_.names_[i] = GetResourceName(batches_[i].material_);
     
     
     return materialsAttr_;
     return materialsAttr_;
 }
 }

+ 2 - 2
Source/Engine/Graphics/Terrain.cpp

@@ -533,13 +533,13 @@ void Terrain::UpdatePatchLod(TerrainPatch* patch)
 void Terrain::SetMaterialAttr(ResourceRef value)
 void Terrain::SetMaterialAttr(ResourceRef value)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    SetMaterial(cache->GetResource<Material>(value.id_));
+    SetMaterial(cache->GetResource<Material>(value.name_));
 }
 }
 
 
 void Terrain::SetHeightMapAttr(ResourceRef value)
 void Terrain::SetHeightMapAttr(ResourceRef value)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    Image* image = cache->GetResource<Image>(value.id_);
+    Image* image = cache->GetResource<Image>(value.name_);
     SetHeightMapInternal(image, false);
     SetHeightMapInternal(image, false);
 }
 }
 
 

+ 4 - 4
Source/Engine/IO/Deserializer.cpp

@@ -251,7 +251,7 @@ ResourceRef Deserializer::ReadResourceRef()
 {
 {
     ResourceRef ret;
     ResourceRef ret;
     ret.type_ = ReadShortStringHash();
     ret.type_ = ReadShortStringHash();
-    ret.id_ = ReadStringHash();
+    ret.name_ = ReadString();
     return ret;
     return ret;
 }
 }
 
 
@@ -259,9 +259,9 @@ ResourceRefList Deserializer::ReadResourceRefList()
 {
 {
     ResourceRefList ret;
     ResourceRefList ret;
     ret.type_ = ReadShortStringHash();
     ret.type_ = ReadShortStringHash();
-    ret.ids_.Resize(ReadVLE());
-    if (ret.ids_.Size())
-        Read(&ret.ids_[0], ret.ids_.Size() * sizeof(StringHash));
+    ret.names_.Resize(ReadVLE());
+    for (unsigned i = 0; i < ret.names_.Size(); ++i)
+        ret.names_[i] = ReadString();
     return ret;
     return ret;
 }
 }
 
 

+ 6 - 5
Source/Engine/IO/Serializer.cpp

@@ -191,19 +191,20 @@ bool Serializer::WriteResourceRef(const ResourceRef& value)
 {
 {
     bool success = true;
     bool success = true;
     success &= WriteShortStringHash(value.type_);
     success &= WriteShortStringHash(value.type_);
-    success &= WriteStringHash(value.id_);
+    success &= WriteString(value.name_);
     return success;
     return success;
 }
 }
 
 
 bool Serializer::WriteResourceRefList(const ResourceRefList& value)
 bool Serializer::WriteResourceRefList(const ResourceRefList& value)
 {
 {
     bool success = true;
     bool success = true;
-    unsigned size = value.ids_.Size() * sizeof(StringHash);
+    unsigned size = value.names_.Size() * sizeof(StringHash);
     
     
     success &= WriteShortStringHash(value.type_);
     success &= WriteShortStringHash(value.type_);
-    success &= WriteVLE(value.ids_.Size());
-    if (size)
-        success &= Write(&value.ids_[0], size) == size;
+    success &= WriteVLE(value.names_.Size());
+    for (unsigned i = 0; i < value.names_.Size(); ++i)
+        success &= WriteString(value.names_[i]);
+    
     return success;
     return success;
 }
 }
 
 

+ 2 - 2
Source/Engine/LuaScript/pkgs/Core/Variant.pkg

@@ -27,11 +27,11 @@ struct ResourceRef
 {
 {
     ResourceRef();
     ResourceRef();
     ResourceRef(ShortStringHash type);
     ResourceRef(ShortStringHash type);
-    ResourceRef(ShortStringHash type, StringHash id);
+    ResourceRef(ShortStringHash type, String name);
     ResourceRef(const ResourceRef& rhs);
     ResourceRef(const ResourceRef& rhs);
     
     
     ShortStringHash type_ @ type;
     ShortStringHash type_ @ type;
-    StringHash id_ @ id;
+    String name_ @ name;
 
 
     bool operator == (const ResourceRef& rhs) const;
     bool operator == (const ResourceRef& rhs) const;
 };
 };

+ 0 - 2
Source/Engine/LuaScript/pkgs/Resource/ResourceCache.pkg

@@ -13,11 +13,9 @@ class ResourceCache
     Resource* GetResource(const String type, const String name);
     Resource* GetResource(const String type, const String name);
     
     
     bool Exists(const String name) const;
     bool Exists(const String name) const;
-    bool Exists(StringHash nameHash) const;
     unsigned GetMemoryBudget(ShortStringHash type) const;
     unsigned GetMemoryBudget(ShortStringHash type) const;
     unsigned GetMemoryUse(ShortStringHash type) const;
     unsigned GetMemoryUse(ShortStringHash type) const;
     unsigned GetTotalMemoryUse() const;
     unsigned GetTotalMemoryUse() const;
-    const String GetResourceName(StringHash nameHash) const;
     String GetResourceFileName(const String name) const;
     String GetResourceFileName(const String name) const;
     
     
     bool GetAutoReloadResources() const;
     bool GetAutoReloadResources() const;

+ 1 - 1
Source/Engine/Physics/CollisionShape.cpp

@@ -721,7 +721,7 @@ void CollisionShape::NotifyRigidBody(bool updateMass)
 void CollisionShape::SetModelAttr(ResourceRef value)
 void CollisionShape::SetModelAttr(ResourceRef value)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    model_ = cache->GetResource<Model>(value.id_);
+    model_ = cache->GetResource<Model>(value.name_);
     recreateShape_ = true;
     recreateShape_ = true;
     MarkNetworkUpdate();
     MarkNetworkUpdate();
 }
 }

+ 6 - 11
Source/Engine/Resource/Resource.h

@@ -73,14 +73,9 @@ private:
     unsigned memoryUse_;
     unsigned memoryUse_;
 };
 };
 
 
-inline StringHash GetResourceHash(Resource* resource)
+inline const String& GetResourceName(Resource* resource)
 {
 {
-    return resource ? resource->GetNameHash() : StringHash();
-}
-
-inline String GetResourceName(Resource* resource)
-{
-    return resource ? resource->GetName() : String();
+    return resource ? resource->GetName() : String::EMPTY;
 }
 }
 
 
 inline ShortStringHash GetResourceType(Resource* resource, ShortStringHash defaultType)
 inline ShortStringHash GetResourceType(Resource* resource, ShortStringHash defaultType)
@@ -90,21 +85,21 @@ inline ShortStringHash GetResourceType(Resource* resource, ShortStringHash defau
 
 
 inline ResourceRef GetResourceRef(Resource* resource, ShortStringHash defaultType)
 inline ResourceRef GetResourceRef(Resource* resource, ShortStringHash defaultType)
 {
 {
-    return ResourceRef(GetResourceType(resource, defaultType), GetResourceHash(resource));
+    return ResourceRef(GetResourceType(resource, defaultType), GetResourceName(resource));
 }
 }
 
 
-template <class T> Vector<StringHash> GetResourceHashes(const Vector<SharedPtr<T> >& resources)
+template <class T> Vector<String> GetResourceNames(const Vector<SharedPtr<T> >& resources)
 {
 {
     Vector<StringHash> ret(resources.Size());
     Vector<StringHash> ret(resources.Size());
     for (unsigned i = 0; i < resources.Size(); ++i)
     for (unsigned i = 0; i < resources.Size(); ++i)
-        ret[i] = GetResourceHash(resources[i]);
+        ret[i] = GetResourceName(resources[i]);
     
     
     return ret;
     return ret;
 }
 }
 
 
 template <class T> ResourceRefList GetResourceRefList(const Vector<SharedPtr<T> >& resources)
 template <class T> ResourceRefList GetResourceRefList(const Vector<SharedPtr<T> >& resources)
 {
 {
-    return ResourceRefList(T::GetTypeStatic(), GetResourceHashes(resources));
+    return ResourceRefList(T::GetTypeStatic(), GetResourceNames(resources));
 }
 }
 
 
 }
 }

+ 7 - 66
Source/Engine/Resource/ResourceCache.cpp

@@ -90,12 +90,6 @@ bool ResourceCache::AddResourceDir(const String& pathName)
     
     
     resourceDirs_.Push(fixedPath);
     resourceDirs_.Push(fixedPath);
     
     
-    // Scan the path for files recursively and add their hash-to-name mappings
-    Vector<String> fileNames;
-    fileSystem->ScanDir(fileNames, fixedPath, "*.*", SCAN_FILES, true);
-    for (unsigned i = 0; i < fileNames.Size(); ++i)
-        StoreNameHash(fileNames[i]);
-    
     // If resource auto-reloading active, create a file watcher for the directory
     // If resource auto-reloading active, create a file watcher for the directory
     if (autoReloadResources_)
     if (autoReloadResources_)
     {
     {
@@ -119,11 +113,6 @@ void ResourceCache::AddPackageFile(PackageFile* package, bool addAsFirst)
     else
     else
         packages_.Push(SharedPtr<PackageFile>(package));
         packages_.Push(SharedPtr<PackageFile>(package));
     
     
-    // Scan the package for files and add their hash-to-name mappings
-    const HashMap<String, PackageEntry>& entries = package->GetEntries();
-    for (HashMap<String, PackageEntry>::ConstIterator i = entries.Begin(); i != entries.End(); ++i)
-        StoreNameHash(i->first_);
-    
     LOGINFO("Added resource package " + package->GetName());
     LOGINFO("Added resource package " + package->GetName());
 }
 }
 
 
@@ -142,7 +131,6 @@ bool ResourceCache::AddManualResource(Resource* resource)
         return false;
         return false;
     }
     }
     
     
-    StoreNameHash(name);
     resource->ResetUseTimer();
     resource->ResetUseTimer();
     resourceGroups_[resource->GetType()].resources_[resource->GetNameHash()] = resource;
     resourceGroups_[resource->GetType()].resources_[resource->GetNameHash()] = resource;
     UpdateResourceGroup(resource->GetType());
     UpdateResourceGroup(resource->GetType());
@@ -383,39 +371,25 @@ SharedPtr<File> ResourceCache::GetFile(const String& nameIn)
     return SharedPtr<File>();
     return SharedPtr<File>();
 }
 }
 
 
-Resource* ResourceCache::GetResource(ShortStringHash type, const String& nameIn)
-{
-    String name = SanitateResourceName(nameIn);
-    
-    // Add the name to the hash map, so if this is an unknown resource, the error will not be unintelligible
-    StoreNameHash(name);
-    
-    return GetResource(type, StringHash(name));
-}
-
 Resource* ResourceCache::GetResource(ShortStringHash type, const char* name)
 Resource* ResourceCache::GetResource(ShortStringHash type, const char* name)
 {
 {
     return GetResource(type, String(name));
     return GetResource(type, String(name));
 }
 }
 
 
-Resource* ResourceCache::GetResource(ShortStringHash type, StringHash nameHash)
+Resource* ResourceCache::GetResource(ShortStringHash type, const String& nameIn)
 {
 {
-    // If null hash, return null pointer immediately
-    if (!nameHash)
+    String name = SanitateResourceName(nameIn);
+    
+    // If empty name, return null pointer immediately
+    if (name.Empty())
         return 0;
         return 0;
     
     
+    StringHash nameHash(name);
     const SharedPtr<Resource>& existing = FindResource(type, nameHash);
     const SharedPtr<Resource>& existing = FindResource(type, nameHash);
     if (existing)
     if (existing)
         return existing;
         return existing;
     
     
     SharedPtr<Resource> resource;
     SharedPtr<Resource> resource;
-    const String& name = GetResourceName(nameHash);
-    if (name.Empty())
-    {
-        LOGERROR("Could not load unknown resource " + String(nameHash));
-        return 0;
-    }
-    
     // Make sure the pointer is non-null and is a Resource subclass
     // Make sure the pointer is non-null and is a Resource subclass
     resource = DynamicCast<Resource>(context_->CreateObject(type));
     resource = DynamicCast<Resource>(context_->CreateObject(type));
     if (!resource)
     if (!resource)
@@ -481,11 +455,6 @@ bool ResourceCache::Exists(const String& nameIn) const
     return false;
     return false;
 }
 }
 
 
-bool ResourceCache::Exists(StringHash nameHash) const
-{
-    return Exists(GetResourceName(nameHash));
-}
-
 unsigned ResourceCache::GetMemoryBudget(ShortStringHash type) const
 unsigned ResourceCache::GetMemoryBudget(ShortStringHash type) const
 {
 {
     HashMap<ShortStringHash, ResourceGroup>::ConstIterator i = resourceGroups_.Find(type);
     HashMap<ShortStringHash, ResourceGroup>::ConstIterator i = resourceGroups_.Find(type);
@@ -512,15 +481,6 @@ unsigned ResourceCache::GetTotalMemoryUse() const
     return total;
     return total;
 }
 }
 
 
-const String& ResourceCache::GetResourceName(StringHash nameHash) const
-{
-    HashMap<StringHash, String>::ConstIterator i = hashToName_.Find(nameHash);
-    if (i == hashToName_.End())
-        return String::EMPTY;
-    else
-        return i->second_;
-}
-
 String ResourceCache::GetResourceFileName(const String& name) const
 String ResourceCache::GetResourceFileName(const String& name) const
 {
 {
     FileSystem* fileSystem = GetSubsystem<FileSystem>();
     FileSystem* fileSystem = GetSubsystem<FileSystem>();
@@ -603,26 +563,7 @@ String ResourceCache::SanitateResourceName(const String& nameIn) const
         name = namePath + GetFileNameAndExtension(name);
         name = namePath + GetFileNameAndExtension(name);
     }
     }
 
 
-    return name;
-}
-
-void ResourceCache::StoreNameHash(const String& name)
-{
-    if (name.Empty())
-        return;
-    
-    StringHash hash(name);
-    
-    // If entry exists, check for difference (collision)
-    HashMap<StringHash, String>::Iterator i = hashToName_.Find(hash);
-    if (i != hashToName_.End())
-    {
-        if (i->second_.Compare(name, false))
-            LOGERROR("Resource hash collision " + i->second_ + " vs " + name);
-        i->second_ = name;
-    }
-    else
-        hashToName_[hash] = name;
+    return name.Trimmed();
 }
 }
 
 
 void ResourceCache::StoreResourceDependency(Resource* resource, const String& dependency)
 void ResourceCache::StoreResourceDependency(Resource* resource, const String& dependency)

+ 0 - 18
Source/Engine/Resource/ResourceCache.h

@@ -96,8 +96,6 @@ public:
     Resource* GetResource(ShortStringHash type, const String& name);
     Resource* GetResource(ShortStringHash type, const String& name);
     /// Return a resource by type and name. Load if not loaded yet. Return null if fails.
     /// Return a resource by type and name. Load if not loaded yet. Return null if fails.
     Resource* GetResource(ShortStringHash type, const char* name);
     Resource* GetResource(ShortStringHash type, const char* name);
-    /// Return a resource by type and name hash. Load if not loaded yet. Return null if fails.
-    Resource* GetResource(ShortStringHash type, StringHash nameHash);
     /// Return all loaded resources of a specific type.
     /// Return all loaded resources of a specific type.
     void GetResources(PODVector<Resource*>& result, ShortStringHash type) const;
     void GetResources(PODVector<Resource*>& result, ShortStringHash type) const;
     /// Return all loaded resources.
     /// Return all loaded resources.
@@ -110,22 +108,16 @@ public:
     template <class T> T* GetResource(const String& name);
     template <class T> T* GetResource(const String& name);
     /// Template version of returning a resource by name.
     /// Template version of returning a resource by name.
     template <class T> T* GetResource(const char* name);
     template <class T> T* GetResource(const char* name);
-    /// Template version of returning a resource by name hash.
-    template <class T> T* GetResource(StringHash nameHash);
     /// Template version of returning loaded resources of a specific type.
     /// Template version of returning loaded resources of a specific type.
     template <class T> void GetResources(PODVector<T*>& result) const;
     template <class T> void GetResources(PODVector<T*>& result) const;
     /// Return whether a file exists by name.
     /// Return whether a file exists by name.
     bool Exists(const String& name) const;
     bool Exists(const String& name) const;
-    /// Return whether a file exists by name hash.
-    bool Exists(StringHash nameHash) const;
     /// Return memory budget for a resource type.
     /// Return memory budget for a resource type.
     unsigned GetMemoryBudget(ShortStringHash type) const;
     unsigned GetMemoryBudget(ShortStringHash type) const;
     /// Return total memory use for a resource type.
     /// Return total memory use for a resource type.
     unsigned GetMemoryUse(ShortStringHash type) const;
     unsigned GetMemoryUse(ShortStringHash type) const;
     /// Return total memory use for all resources.
     /// Return total memory use for all resources.
     unsigned GetTotalMemoryUse() const;
     unsigned GetTotalMemoryUse() const;
-    /// Return resource name from hash, or empty if not found.
-    const String& GetResourceName(StringHash nameHash) const;
     /// Return full absolute file name of resource if possible.
     /// Return full absolute file name of resource if possible.
     String GetResourceFileName(const String& name) const;
     String GetResourceFileName(const String& name) const;
     /// Return whether automatic resource reloading is enabled.
     /// Return whether automatic resource reloading is enabled.
@@ -135,8 +127,6 @@ public:
     String GetPreferredResourceDir(const String& path) const;
     String GetPreferredResourceDir(const String& path) const;
     /// Remove unsupported constructs from the resource name to prevent ambiguity, and normalize absolute filename to resource path relative if possible.
     /// Remove unsupported constructs from the resource name to prevent ambiguity, and normalize absolute filename to resource path relative if possible.
     String SanitateResourceName(const String& name) const;
     String SanitateResourceName(const String& name) const;
-    /// Store a hash-to-name mapping.
-    void StoreNameHash(const String& name);
     /// Store a dependency for a resource. If a dependency file changes, the resource will be reloaded.
     /// Store a dependency for a resource. If a dependency file changes, the resource will be reloaded.
     void StoreResourceDependency(Resource* resource, const String& dependency);
     void StoreResourceDependency(Resource* resource, const String& dependency);
     /// Reset dependencies for a resource.
     /// Reset dependencies for a resource.
@@ -162,8 +152,6 @@ private:
     Vector<SharedPtr<FileWatcher> > fileWatchers_;
     Vector<SharedPtr<FileWatcher> > fileWatchers_;
     /// Package files.
     /// Package files.
     Vector<SharedPtr<PackageFile> > packages_;
     Vector<SharedPtr<PackageFile> > packages_;
-    /// Mapping of hashes to filenames.
-    HashMap<StringHash, String> hashToName_;
     /// Dependent resources.
     /// Dependent resources.
     HashMap<StringHash, HashSet<StringHash> > dependentResources_;
     HashMap<StringHash, HashSet<StringHash> > dependentResources_;
     /// Automatic resource reloading flag.
     /// Automatic resource reloading flag.
@@ -182,12 +170,6 @@ template <class T> T* ResourceCache::GetResource(const char* name)
     return static_cast<T*>(GetResource(type, name));
     return static_cast<T*>(GetResource(type, name));
 }
 }
 
 
-template <class T> T* ResourceCache::GetResource(StringHash nameHash)
-{
-    ShortStringHash type = T::GetTypeStatic();
-    return static_cast<T*>(GetResource(type, nameHash));
-}
-
 template <class T> void ResourceCache::GetResources(PODVector<T*>& result) const
 template <class T> void ResourceCache::GetResources(PODVector<T*>& result) const
 {
 {
     PODVector<Resource*>& resources = reinterpret_cast<PODVector<Resource*>&>(result);
     PODVector<Resource*>& resources = reinterpret_cast<PODVector<Resource*>&>(result);

+ 8 - 24
Source/Engine/Resource/XMLElement.cpp

@@ -23,7 +23,6 @@
 #include "Precompiled.h"
 #include "Precompiled.h"
 #include "Context.h"
 #include "Context.h"
 #include "Log.h"
 #include "Log.h"
-#include "ResourceCache.h"
 #include "StringUtils.h"
 #include "StringUtils.h"
 #include "XMLFile.h"
 #include "XMLFile.h"
 
 
@@ -361,11 +360,10 @@ bool XMLElement::SetResourceRef(const ResourceRef& value)
     if (!file_ || (!node_ && !xpathNode_))
     if (!file_ || (!node_ && !xpathNode_))
         return false;
         return false;
 
 
-    // Need the context & resource cache to query for reverse hash mappings
+    // Need the context to query for the type
     Context* context = file_->GetContext();
     Context* context = file_->GetContext();
-    ResourceCache* cache = file_->GetSubsystem<ResourceCache>();
 
 
-    return SetAttribute("value", String(context->GetTypeName(value.type_)) + ";" + cache->GetResourceName(value.id_));
+    return SetAttribute("value", String(context->GetTypeName(value.type_)) + ";" + value.name_);
 }
 }
 
 
 bool XMLElement::SetResourceRefList(const ResourceRefList& value)
 bool XMLElement::SetResourceRefList(const ResourceRefList& value)
@@ -373,15 +371,14 @@ bool XMLElement::SetResourceRefList(const ResourceRefList& value)
     if (!file_ || (!node_ && !xpathNode_))
     if (!file_ || (!node_ && !xpathNode_))
         return false;
         return false;
 
 
-    // Need the context & resource cache to query for reverse hash mappings
+    // Need the context to query for the type
     Context* context = file_->GetContext();
     Context* context = file_->GetContext();
-    ResourceCache* cache = file_->GetSubsystem<ResourceCache>();
 
 
     String str(context->GetTypeName(value.type_));
     String str(context->GetTypeName(value.type_));
-    for (unsigned i = 0; i < value.ids_.Size(); ++i)
+    for (unsigned i = 0; i < value.names_.Size(); ++i)
     {
     {
         str += ";";
         str += ";";
-        str += cache->GetResourceName(value.ids_[i]);
+        str += value.names_[i];
     }
     }
 
 
     return SetAttribute("value", str.CString());
     return SetAttribute("value", str.CString());
@@ -734,12 +731,7 @@ ResourceRef XMLElement::GetResourceRef() const
     if (values.Size() == 2)
     if (values.Size() == 2)
     {
     {
         ret.type_ = values[0];
         ret.type_ = values[0];
-        ret.id_ = values[1];
-
-        // Whenever we encounter a resource name read from a ResourceRef XML element, store the reverse mapping to
-        // ResourceCache if possible. We will probably use the hash to request a resource shortly afterward
-        if (file_)
-            file_->GetSubsystem<ResourceCache>()->StoreNameHash(values[1]);
+        ret.name_ = values[1];
     }
     }
 
 
     return ret;
     return ret;
@@ -752,18 +744,10 @@ ResourceRefList XMLElement::GetResourceRefList() const
     Vector<String> values = GetAttribute("value").Split(';');
     Vector<String> values = GetAttribute("value").Split(';');
     if (values.Size() >= 1)
     if (values.Size() >= 1)
     {
     {
-        // Whenever we encounter resource names read from a ResourceRefList XML element, store the reverse mapping to
-        // ResourceCache if possible. We will probably use the hashes to request resources shortly afterward
-        ResourceCache* cache = file_ ? file_->GetSubsystem<ResourceCache>() : 0;
-
         ret.type_ = values[0];
         ret.type_ = values[0];
-        ret.ids_.Resize(values.Size() - 1);
+        ret.names_.Resize(values.Size() - 1);
         for (unsigned i = 1; i < values.Size(); ++i)
         for (unsigned i = 1; i < values.Size(); ++i)
-        {
-            ret.ids_[i - 1] = StringHash(values[i]);
-            if (cache)
-                cache->StoreNameHash(values[i]);
-        }
+            ret.names_[i - 1] = values[i];
     }
     }
 
 
     return ret;
     return ret;

+ 13 - 13
Source/Engine/Script/CoreAPI.cpp

@@ -154,39 +154,39 @@ static void DestructResourceRefList(ResourceRefList* ptr)
 
 
 static void ResourceRefListResize(unsigned size, ResourceRefList* ptr)
 static void ResourceRefListResize(unsigned size, ResourceRefList* ptr)
 {
 {
-    ptr->ids_.Resize(size);
+    ptr->names_.Resize(size);
 }
 }
 
 
 static unsigned ResourceRefListGetSize(ResourceRefList* ptr)
 static unsigned ResourceRefListGetSize(ResourceRefList* ptr)
 {
 {
-    return ptr->ids_.Size();
+    return ptr->names_.Size();
 }
 }
 
 
 static bool ResourceRefListIsEmpty(ResourceRefList* ptr)
 static bool ResourceRefListIsEmpty(ResourceRefList* ptr)
 {
 {
-    return ptr->ids_.Size() == 0;
+    return ptr->names_.Size() == 0;
 }
 }
 
 
-static void ResourceRefListSetId(unsigned index, const StringHash& id, ResourceRefList* ptr)
+static void ResourceRefListSetName(unsigned index, const String& name, ResourceRefList* ptr)
 {
 {
-    if (index >= ptr->ids_.Size())
+    if (index >= ptr->names_.Size())
     {
     {
         asGetActiveContext()->SetException("Index out of bounds");
         asGetActiveContext()->SetException("Index out of bounds");
         return;
         return;
     }
     }
 
 
-    ptr->ids_[index] = id;
+    ptr->names_[index] = name;
 }
 }
 
 
-static StringHash ResourceRefListGetId(unsigned index, ResourceRefList* ptr)
+static const String& ResourceRefListGetName(unsigned index, ResourceRefList* ptr)
 {
 {
-    if (index >= ptr->ids_.Size())
+    if (index >= ptr->names_.Size())
     {
     {
         asGetActiveContext()->SetException("Index out of bounds");
         asGetActiveContext()->SetException("Index out of bounds");
-        return StringHash();
+        return String::EMPTY;
     }
     }
 
 
-    return ptr->ids_[index];
+    return ptr->names_[index];
 }
 }
 
 
 void ArrayToVariantVector(CScriptArray* arr, VariantVector& dest)
 void ArrayToVariantVector(CScriptArray* arr, VariantVector& dest)
@@ -413,7 +413,7 @@ static void RegisterVariant(asIScriptEngine* engine)
     engine->RegisterObjectMethod("ResourceRef", "ResourceRef& opAssign(const ResourceRef&in)", asMETHOD(ResourceRef, operator =), asCALL_THISCALL);
     engine->RegisterObjectMethod("ResourceRef", "ResourceRef& opAssign(const ResourceRef&in)", asMETHOD(ResourceRef, operator =), asCALL_THISCALL);
     engine->RegisterObjectMethod("ResourceRef", "bool opEquals(const ResourceRef&in) const", asMETHOD(ResourceRef, operator ==), asCALL_THISCALL);
     engine->RegisterObjectMethod("ResourceRef", "bool opEquals(const ResourceRef&in) const", asMETHOD(ResourceRef, operator ==), asCALL_THISCALL);
     engine->RegisterObjectProperty("ResourceRef", "ShortStringHash type", offsetof(ResourceRef, type_));
     engine->RegisterObjectProperty("ResourceRef", "ShortStringHash type", offsetof(ResourceRef, type_));
-    engine->RegisterObjectProperty("ResourceRef", "StringHash id", offsetof(ResourceRef, id_));
+    engine->RegisterObjectProperty("ResourceRef", "String name", offsetof(ResourceRef, name_));
 
 
     engine->RegisterObjectType("ResourceRefList", sizeof(ResourceRefList), asOBJ_VALUE | asOBJ_APP_CLASS_C);
     engine->RegisterObjectType("ResourceRefList", sizeof(ResourceRefList), asOBJ_VALUE | asOBJ_APP_CLASS_C);
     engine->RegisterObjectBehaviour("ResourceRefList", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructResourceRefList), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("ResourceRefList", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructResourceRefList), asCALL_CDECL_OBJLAST);
@@ -424,8 +424,8 @@ static void RegisterVariant(asIScriptEngine* engine)
     engine->RegisterObjectMethod("ResourceRefList", "void Resize(uint)", asFUNCTION(ResourceRefListResize), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("ResourceRefList", "void Resize(uint)", asFUNCTION(ResourceRefListResize), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("ResourceRefList", "uint get_length() const", asFUNCTION(ResourceRefListGetSize), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("ResourceRefList", "uint get_length() const", asFUNCTION(ResourceRefListGetSize), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("ResourceRefList", "bool get_empty() const", asFUNCTION(ResourceRefListIsEmpty), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("ResourceRefList", "bool get_empty() const", asFUNCTION(ResourceRefListIsEmpty), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("ResourceRefList", "void set_ids(uint, const StringHash&in) const", asFUNCTION(ResourceRefListSetId), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("ResourceRefList", "StringHash get_ids(uint) const", asFUNCTION(ResourceRefListGetId), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("ResourceRefList", "void set_names(uint, const String&in) const", asFUNCTION(ResourceRefListSetName), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("ResourceRefList", "const String& get_names(uint) const", asFUNCTION(ResourceRefListGetName), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectProperty("ResourceRefList", "ShortStringHash type", offsetof(ResourceRef, type_));
     engine->RegisterObjectProperty("ResourceRefList", "ShortStringHash type", offsetof(ResourceRef, type_));
 
 
     engine->RegisterObjectType("Variant", sizeof(Variant), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK);
     engine->RegisterObjectType("Variant", sizeof(Variant), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK);

+ 0 - 2
Source/Engine/Script/ResourceAPI.cpp

@@ -114,10 +114,8 @@ static void RegisterResourceCache(asIScriptEngine* engine)
     engine->RegisterObjectMethod("ResourceCache", "File@ GetFile(const String&in)", asFUNCTION(ResourceCacheGetFile), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("ResourceCache", "File@ GetFile(const String&in)", asFUNCTION(ResourceCacheGetFile), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("ResourceCache", "String GetPreferredResourceDir(const String&in) const", asMETHOD(ResourceCache, GetPreferredResourceDir), asCALL_THISCALL);
     engine->RegisterObjectMethod("ResourceCache", "String GetPreferredResourceDir(const String&in) const", asMETHOD(ResourceCache, GetPreferredResourceDir), asCALL_THISCALL);
     engine->RegisterObjectMethod("ResourceCache", "String SanitateResourceName(const String&in) const", asMETHOD(ResourceCache, SanitateResourceName), asCALL_THISCALL);
     engine->RegisterObjectMethod("ResourceCache", "String SanitateResourceName(const String&in) const", asMETHOD(ResourceCache, SanitateResourceName), asCALL_THISCALL);
-    engine->RegisterObjectMethod("ResourceCache", "const String& GetResourceName(StringHash) const", asMETHOD(ResourceCache, GetResourceName), asCALL_THISCALL);
     engine->RegisterObjectMethod("ResourceCache", "String GetResourceFileName(const String&in) const", asMETHOD(ResourceCache, GetResourceFileName), asCALL_THISCALL);
     engine->RegisterObjectMethod("ResourceCache", "String GetResourceFileName(const String&in) const", asMETHOD(ResourceCache, GetResourceFileName), asCALL_THISCALL);
     engine->RegisterObjectMethod("ResourceCache", "Resource@+ GetResource(const String&in, const String&in)", asFUNCTION(ResourceCacheGetResource), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("ResourceCache", "Resource@+ GetResource(const String&in, const String&in)", asFUNCTION(ResourceCacheGetResource), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("ResourceCache", "Resource@+ GetResource(ShortStringHash, StringHash)", asMETHODPR(ResourceCache, GetResource, (ShortStringHash, StringHash), Resource*), asCALL_THISCALL);
     engine->RegisterObjectMethod("ResourceCache", "Resource@+ GetResource(ShortStringHash, const String&in)", asMETHODPR(ResourceCache, GetResource, (ShortStringHash, const String&), Resource*), asCALL_THISCALL);
     engine->RegisterObjectMethod("ResourceCache", "Resource@+ GetResource(ShortStringHash, const String&in)", asMETHODPR(ResourceCache, GetResource, (ShortStringHash, const String&), Resource*), asCALL_THISCALL);
     engine->RegisterObjectMethod("ResourceCache", "void set_memoryBudget(const String&in, uint)", asFUNCTION(ResourceCacheSetMemoryBudget), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("ResourceCache", "void set_memoryBudget(const String&in, uint)", asFUNCTION(ResourceCacheSetMemoryBudget), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("ResourceCache", "uint get_memoryBudget(const String&in) const", asFUNCTION(ResourceCacheGetMemoryBudget), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("ResourceCache", "uint get_memoryBudget(const String&in) const", asFUNCTION(ResourceCacheGetMemoryBudget), asCALL_CDECL_OBJLAST);

+ 3 - 4
Source/Engine/Script/ScriptInstance.cpp

@@ -108,7 +108,7 @@ void ScriptInstance::OnSetAttribute(const AttributeInfo& attr, const Variant& sr
         if (resourcePtr)
         if (resourcePtr)
             resourcePtr->ReleaseRef();
             resourcePtr->ReleaseRef();
         const ResourceRef& ref = src.GetResourceRef();
         const ResourceRef& ref = src.GetResourceRef();
-        resourcePtr = GetSubsystem<ResourceCache>()->GetResource(ref.type_, ref.id_);
+        resourcePtr = GetSubsystem<ResourceCache>()->GetResource(ref.type_, ref.name_);
         if (resourcePtr)
         if (resourcePtr)
             resourcePtr->AddRef();
             resourcePtr->AddRef();
     }
     }
@@ -145,8 +145,7 @@ void ScriptInstance::OnGetAttribute(const AttributeInfo& attr, Variant& dest) co
     {
     {
         Resource* resource = *(reinterpret_cast<Resource**>(attr.ptr_));
         Resource* resource = *(reinterpret_cast<Resource**>(attr.ptr_));
         // If resource is non-null get its type and name hash. Otherwise get type from the default value
         // If resource is non-null get its type and name hash. Otherwise get type from the default value
-        dest = resource ? ResourceRef(resource->GetType(), resource->GetNameHash()) :
-            ResourceRef(attr.defaultValue_.GetResourceRef().type_);
+        dest = GetResourceRef(resource, attr.defaultValue_.GetResourceRef().type_);
     }
     }
     else
     else
         Serializable::OnGetAttribute(attr, dest);
         Serializable::OnGetAttribute(attr, dest);
@@ -345,7 +344,7 @@ void ScriptInstance::AddEventHandler(Object* sender, StringHash eventType, const
 void ScriptInstance::SetScriptFileAttr(ResourceRef value)
 void ScriptInstance::SetScriptFileAttr(ResourceRef value)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    SetScriptFile(cache->GetResource<ScriptFile>(value.id_));
+    SetScriptFile(cache->GetResource<ScriptFile>(value.name_));
 }
 }
 
 
 void ScriptInstance::SetDelayedCallsAttr(PODVector<unsigned char> value)
 void ScriptInstance::SetDelayedCallsAttr(PODVector<unsigned char> value)

+ 1 - 1
Source/Engine/UI/BorderImage.cpp

@@ -189,7 +189,7 @@ void BorderImage::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vert
 void BorderImage::SetTextureAttr(ResourceRef value)
 void BorderImage::SetTextureAttr(ResourceRef value)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    SetTexture(cache->GetResource<Texture2D>(value.id_));
+    SetTexture(cache->GetResource<Texture2D>(value.name_));
 }
 }
 
 
 ResourceRef BorderImage::GetTextureAttr() const
 ResourceRef BorderImage::GetTextureAttr() const

+ 1 - 1
Source/Engine/UI/Cursor.cpp

@@ -172,7 +172,7 @@ void Cursor::SetShapesAttr(VariantVector value)
             ResourceRef ref = value[index++].GetResourceRef();
             ResourceRef ref = value[index++].GetResourceRef();
             IntRect imageRect = value[index++].GetIntRect();
             IntRect imageRect = value[index++].GetIntRect();
             IntVector2 hotSpot = value[index++].GetIntVector2();
             IntVector2 hotSpot = value[index++].GetIntVector2();
-            DefineShape(shape, GetSubsystem<ResourceCache>()->GetResource<Image>(ref.id_), imageRect, hotSpot);
+            DefineShape(shape, GetSubsystem<ResourceCache>()->GetResource<Image>(ref.name_), imageRect, hotSpot);
         }
         }
         else
         else
             index += 3;
             index += 3;

+ 1 - 1
Source/Engine/UI/Sprite.cpp

@@ -267,7 +267,7 @@ const Matrix3x4& Sprite::GetTransform() const
 void Sprite::SetTextureAttr(ResourceRef value)
 void Sprite::SetTextureAttr(ResourceRef value)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    SetTexture(cache->GetResource<Texture2D>(value.id_));
+    SetTexture(cache->GetResource<Texture2D>(value.name_));
 }
 }
 
 
 ResourceRef Sprite::GetTextureAttr() const
 ResourceRef Sprite::GetTextureAttr() const

+ 1 - 1
Source/Engine/UI/Text.cpp

@@ -382,7 +382,7 @@ void Text::SetEffectDepthBias(float bias)
 void Text::SetFontAttr(ResourceRef value)
 void Text::SetFontAttr(ResourceRef value)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    font_ = cache->GetResource<Font>(value.id_);
+    font_ = cache->GetResource<Font>(value.name_);
 }
 }
 
 
 ResourceRef Text::GetFontAttr() const
 ResourceRef Text::GetFontAttr() const

+ 2 - 2
Source/Engine/UI/Text3D.cpp

@@ -410,13 +410,13 @@ void Text3D::MarkTextDirty()
 void Text3D::SetMaterialAttr(ResourceRef value)
 void Text3D::SetMaterialAttr(ResourceRef value)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    SetMaterial(cache->GetResource<Material>(value.id_));
+    SetMaterial(cache->GetResource<Material>(value.name_));
 }
 }
 
 
 void Text3D::SetFontAttr(ResourceRef value)
 void Text3D::SetFontAttr(ResourceRef value)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
-    text_.font_ = cache->GetResource<Font>(value.id_);
+    text_.font_ = cache->GetResource<Font>(value.name_);
 }
 }
 
 
 ResourceRef Text3D::GetMaterialAttr() const
 ResourceRef Text3D::GetMaterialAttr() const

部分文件因为文件数量过多而无法显示