MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / FindScript

Method FindScript

Source/Editor/Scripting/ScriptsBuilder.cpp:294–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294MClass* ScriptsBuilder::FindScript(const StringView& scriptName)
295{
296 PROFILE_CPU();
297 const StringAnsi scriptNameStd = scriptName.ToStringAnsi();
298
299 const ScriptingTypeHandle scriptingType = Scripting::FindScriptingType(scriptNameStd);
300 if (scriptingType)
301 {
302 MClass* mclass = scriptingType.GetType().ManagedClass;
303 if (mclass)
304 {
305 return mclass;
306 }
307 }
308
309 // Check all assemblies (ignoring the typename namespace)
310 auto& modules = BinaryModule::GetModules();
311 StringAnsi className;
312 GetClassName(scriptNameStd, className);
313 MClass* scriptClass = Script::GetStaticClass();
314 for (int32 j = 0; j < modules.Count(); j++)
315 {
316 auto managedModule = dynamic_cast<ManagedBinaryModule*>(modules[j]);
317 if (!managedModule)
318 continue;
319 auto assembly = managedModule->Assembly;
320 auto& classes = assembly->GetClasses();
321 for (auto i = classes.Begin(); i.IsNotEnd(); ++i)
322 {
323 MClass* mclass = i->Value;
324
325 // Managed scripts
326 if (mclass->IsSubClassOf(scriptClass) && !mclass->IsStatic() && !mclass->IsAbstract() && !mclass->IsInterface())
327 {
328 StringAnsi mclassName;
329 GetClassName(mclass->GetFullName(), mclassName);
330 if (className == mclassName)
331 {
332 LOG(Info, "Found {0} type for type {1} (assembly {2})", String(mclass->GetFullName()), String(scriptName.Get(), scriptName.Length()), assembly->ToString());
333 return mclass;
334 }
335 }
336 }
337 }
338
339 LOG(Warning, "Failed to find script class of name {0}", String(scriptNameStd));
340 return nullptr;
341}
342
343void ScriptsBuilder::GetExistingEditors(int32* result, int32 count)
344{

Callers 4

ScriptItemClass · 0.45
FromDragDataMethod · 0.45
ValidateScriptMethod · 0.45
AddScriptsMethod · 0.45

Calls 12

FindScriptingTypeFunction · 0.85
IsStaticMethod · 0.80
StringClass · 0.50
ToStringAnsiMethod · 0.45
GetTypeMethod · 0.45
CountMethod · 0.45
BeginMethod · 0.45
IsNotEndMethod · 0.45
IsSubClassOfMethod · 0.45
GetMethod · 0.45
LengthMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected