Skip to content

Commit c3074cf

Browse files
committed
readme update | fix behaviour reflect
Signed-off-by: Wojciech Czerski <[email protected]>
1 parent b46a517 commit c3074cf

File tree

2 files changed

+27
-72
lines changed

2 files changed

+27
-72
lines changed

Gems/FPSProfiler/Code/Source/Configurations/FPSProfilerConfig.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ namespace FPSProfiler::Configs
7575
behaviorContext->Class<FileSaveSettings>("FileSaveSettings")
7676
->Attribute(AZ::Script::Attributes::Category, "FPSProfiler")
7777
->Constructor<>()
78-
->Property("outputFilename", BehaviorValueProperty(&FileSaveSettings::m_OutputFilename))
79-
->Property("autoSave", BehaviorValueProperty(&FileSaveSettings::m_AutoSave))
80-
->Property("autoSaveAtFrame", BehaviorValueProperty(&FileSaveSettings::m_AutoSaveAtFrame))
81-
->Property("saveWithTimestamp", BehaviorValueProperty(&FileSaveSettings::m_SaveWithTimestamp));
78+
->Property("m_OutputFilename", BehaviorValueProperty(&FileSaveSettings::m_OutputFilename))
79+
->Property("m_AutoSave", BehaviorValueProperty(&FileSaveSettings::m_AutoSave))
80+
->Property("m_AutoSaveAtFrame", BehaviorValueProperty(&FileSaveSettings::m_AutoSaveAtFrame))
81+
->Property("m_SaveWithTimestamp", BehaviorValueProperty(&FileSaveSettings::m_SaveWithTimestamp));
8282
}
8383
}
8484

@@ -160,10 +160,10 @@ namespace FPSProfiler::Configs
160160
behaviorContext->Class<RecordSettings>("RecordSettings")
161161
->Attribute(AZ::Script::Attributes::Category, "FPSProfiler")
162162
->Constructor<>()
163-
->Property("recordType", BehaviorValueProperty(&RecordSettings::m_recordType))
164-
->Property("framesToSkip", BehaviorValueProperty(&RecordSettings::m_framesToSkip))
165-
->Property("framesToRecord", BehaviorValueProperty(&RecordSettings::m_framesToRecord))
166-
->Property("recordStats", BehaviorValueProperty(&RecordSettings::m_RecordStats));
163+
->Property("m_recordType", BehaviorValueProperty(&RecordSettings::m_recordType))
164+
->Property("m_framesToSkip", BehaviorValueProperty(&RecordSettings::m_framesToSkip))
165+
->Property("m_framesToRecord", BehaviorValueProperty(&RecordSettings::m_framesToRecord))
166+
->Property("m_RecordStats", BehaviorValueProperty(&RecordSettings::m_RecordStats));
167167
}
168168
}
169169

@@ -238,10 +238,10 @@ namespace FPSProfiler::Configs
238238
behaviorContext->Class<PrecisionSettings>("PrecisionSettings")
239239
->Attribute(AZ::Script::Attributes::Category, "FPSProfiler")
240240
->Constructor<>()
241-
->Property("NearZeroPrecision", BehaviorValueProperty(&PrecisionSettings::m_NearZeroPrecision))
242-
->Property("AvgFpsType", BehaviorValueProperty(&PrecisionSettings::m_avgFpsType))
243-
->Property("SmoothingFactor", BehaviorValueProperty(&PrecisionSettings::m_smoothingFactor))
244-
->Property("KeepHistory", BehaviorValueProperty(&PrecisionSettings::m_keepHistory));
241+
->Property("m_NearZeroPrecision", BehaviorValueProperty(&PrecisionSettings::m_NearZeroPrecision))
242+
->Property("m_avgFpsType", BehaviorValueProperty(&PrecisionSettings::m_avgFpsType))
243+
->Property("m_smoothingFactor", BehaviorValueProperty(&PrecisionSettings::m_smoothingFactor))
244+
->Property("m_keepHistory", BehaviorValueProperty(&PrecisionSettings::m_keepHistory));
245245
}
246246
}
247247

@@ -256,9 +256,9 @@ namespace FPSProfiler::Configs
256256

257257
serializeContext->Class<DebugSettings>()
258258
->Version(0)
259-
->Field("PrintDebugInfo", &DebugSettings::m_PrintDebugInfo)
260-
->Field("ShowFps", &DebugSettings::m_ShowFps)
261-
->Field("Color", &DebugSettings::m_Color);
259+
->Field("m_PrintDebugInfo", &DebugSettings::m_PrintDebugInfo)
260+
->Field("m_ShowFps", &DebugSettings::m_ShowFps)
261+
->Field("m_Color", &DebugSettings::m_Color);
262262

263263
if (auto* editContext = serializeContext->GetEditContext())
264264
{
@@ -296,9 +296,9 @@ namespace FPSProfiler::Configs
296296
behaviorContext->Class<DebugSettings>("DebugSettings")
297297
->Attribute(AZ::Script::Attributes::Category, "FPSProfiler")
298298
->Constructor<>()
299-
->Property("PrintDebugInfo", BehaviorValueProperty(&DebugSettings::m_PrintDebugInfo))
300-
->Property("ShowFps", BehaviorValueProperty(&DebugSettings::m_ShowFps))
301-
->Property("Color", BehaviorValueProperty(&DebugSettings::m_Color));
299+
->Property("m_PrintDebugInfo", BehaviorValueProperty(&DebugSettings::m_PrintDebugInfo))
300+
->Property("m_ShowFps", BehaviorValueProperty(&DebugSettings::m_ShowFps))
301+
->Property("m_Color", BehaviorValueProperty(&DebugSettings::m_Color));
302302
}
303303
}
304304
} // namespace FPSProfiler::Configs

readme.md

Lines changed: 9 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -421,65 +421,20 @@ void OnProfileStart(const Configs::FileSaveSettings& config) override
421421
```
422422
423423
### In Lua
424-
```shell
425-
-- Table to hold our script functions
426-
local profilerScript = {}
427-
428-
-- Function called when profiling starts
429-
function profilerScript:OnProfileStart(config)
430-
Debug.Log("Profiling started. Stopping in 60 seconds...")
431-
432-
-- Start a 60-second timer before stopping profiling
433-
self:StartTimer(60, function()
434-
Debug.Log("Stopping profiling now...")
435-
FPSProfilerRequestBus.Broadcast.StopProfiling()
436-
end)
437-
end
438-
439-
-- Function to start a timer
440-
function profilerScript:StartTimer(delay, callback)
441-
if self.timerEventId then
442-
-- Prevent multiple timers from stacking
443-
TickBus.Disconnect(self, self.timerEventId)
444-
end
445-
446-
self.timerTimeRemaining = delay
447-
self.timerCallback = callback
448-
self.timerEventId = TickBus.Connect(self)
449-
end
424+
```lua
425+
FPSProfilerHandler = {}
450426
451-
-- Tick event to track time
452-
function profilerScript:OnTick(deltaTime, timePoint)
453-
if self.timerTimeRemaining then
454-
self.timerTimeRemaining = self.timerTimeRemaining - deltaTime
455-
if self.timerTimeRemaining <= 0 then
456-
-- Time is up, trigger callback and disconnect
457-
if self.timerCallback then
458-
self.timerCallback()
459-
end
460-
TickBus.Disconnect(self, self.timerEventId)
461-
self.timerEventId = nil
462-
end
463-
end
427+
-- Called when a new file is created
428+
function FPSProfilerHandler:OnFileCreated(config)
429+
Debug.Log("File Created: " .. config.m_OutputFilename)
464430
end
465431
466-
-- Register as an FPSProfilerNotificationBus listener
467-
function profilerScript:OnActivate()
468-
FPSProfilerNotificationBus.Connect(self)
469-
end
470-
471-
-- Cleanup when script is deactivated
472-
function profilerScript:OnDeactivate()
473-
FPSProfilerNotificationBus.Disconnect(self)
474-
475-
-- Disconnect timer if still active
476-
if self.timerEventId then
477-
TickBus.Disconnect(self, self.timerEventId)
478-
end
432+
function FPSProfilerHandler:OnActivate()
433+
-- Connect the handler to listen for notifications
434+
FPSProfilerNotificationBus.Connect(FPSProfilerHandler)
479435
end
480436
481-
-- Return the table so O3DE can use it
482-
return profilerScript
437+
return FPSProfilerHandler
483438
```
484439

485440
### In Script Canvas

0 commit comments

Comments
 (0)