PrefabComponent.h 861 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #pragma once
  2. #include "../Scene/Component.h"
  3. namespace Atomic
  4. {
  5. class PrefabComponent : public Component
  6. {
  7. OBJECT(PrefabComponent);
  8. public:
  9. /// Construct.
  10. PrefabComponent(Context* context);
  11. /// Destruct.
  12. virtual ~PrefabComponent();
  13. /// Register object factory.
  14. static void RegisterObject(Context* context);
  15. void SetPrefabGUID(const String& guid);
  16. const String& GetPrefabGUID() const { return prefabGUID_; }
  17. bool SavePrefab();
  18. void UndoPrefab();
  19. void BreakPrefab();
  20. Node* GetPrefabNode() { return prefabNode_; }
  21. protected:
  22. /// Handle scene node being assigned at creation.
  23. virtual void OnNodeSet(Node* node);
  24. private:
  25. void HandlePrefabChanged(StringHash eventType, VariantMap& eventData);
  26. void LoadPrefabNode();
  27. SharedPtr<Node> prefabNode_;
  28. String prefabGUID_;
  29. };
  30. }