Registering new entity. Disable exposing for Editor

#1
This is not a big issue, but I was just wondering if it's possible.

I have a few custom entities I wrote in C++ using that :

Code: Select all

class CMyEntity: public CGameObjectExtensionHelper<CMyEntity, ISimpleExtension>
{};

AND

class CMyEntityRegistrator
   : public IEntityRegistrator
{
   virtual void Register() override
   {
      CGamePlugin::RegisterEntityWithDefaultComponent<CMyEntity>("MyEntity");
   }

   virtual void Unregister() override
   {}
};
CMyEntityRegistrator gMyEntityRegistrator;


This is obviously just example, but that's the way I register it. All of these entities are available inside of the Editor (drag and drop), but I don't want them to. I wan't only a few of them be able to appear in the editor browser, rest of them are only my C++ entities and I want to use them only in runtime. Is there any other way to register entity? I still want to be able to do something like that:

Code: Select all

gEnv->pEntitySystem->GetClassRegistry()->FindClass(ClassName)

and use and spawn that entity.
Cryengine tutorial videos on my Youtube channel! Check it out !
https://www.youtube.com/user/MusicForLifePL20

Re: Registering new entity. Disable exposing for Editor

#3
If I understood it correctly then this should let you achieve what you want.

Code: Select all

// This should make the entity class invisible in the editor.
auto cls = gEnv->pEntitySystem->GetClassRegistry()->FindClass("MyEntity");
cls->SetFlags(cls->GetFlags() | ECLF_INVISIBLE);

I saw this part of code while browsing through the Chrysalis Project of Ivan Hawkes.
It removes the Entity from the Editor Entity list. Just add it to your register function on the bottom.

Re: Registering new entity. Disable exposing for Editor

#4
SOLVED! Thanks to everyone for help! mknmknmknjk, I looked into that function, but It didn't work out, I have learned something new though.
As savi said there is something called "flags" in entity decription. So.. I actualy managed to hide it from the editor AND create new classes for the editor to make it look tidy and so on! That's what you do :

GamePlugin.h - find that line.

Code: Select all

   template<class T>
   static void RegisterEntityWithDefaultComponent(const char *name)
   {
      IEntityClassRegistry::SEntityClassDesc clsDesc;
      clsDesc.sName = name;

      static CObjectCreator<T> _creator;

      gEnv->pGameFramework->GetIGameObjectSystem()->RegisterExtension(name, &_creator, &clsDesc);
   }

Now there is a couple of thing you can do. You can hide all of your entities which are using that method :

Code: Select all

   template<class T>
   static void RegisterEntityWithDefaultComponent(const char *name)
   {
      IEntityClassRegistry::SEntityClassDesc clsDesc;
      clsDesc.sName = name;
      clsDesc.flags= ECLF_INVISIBLE;

      static CObjectCreator<T> _creator;

      gEnv->pGameFramework->GetIGameObjectSystem()->RegisterExtension(name, &_creator, &clsDesc);
   }


And all entities using that method to register will be hidden. I did it a little bit different though.
In my game I have a few different types of entities and I wanted to manage them nicely inside of the editor, some put in different category or maybe hide some of them. In order to do that you need to create new method inside of CObjectCreator struct.

Code: Select all

   template<class T>
   static void RegisterMyTypeOfEntity(const char *name)
   {
      IEntityClassRegistry::SEntityClassDesc clsDesc;
      clsDesc.sName = name;
      clsDesc.editorClassInfo.sCategory = "MyEntityCategory"; //<-- this name will be seen inside of editor as different folder//
      clsDesc.flags = ECLF_INVISIBLE; //Obviously you can completely hide from the editor this type of entities//
      static CObjectCreator<T> _creator;

      gEnv->pGameFramework->GetIGameObjectSystem()->RegisterExtension(name, &_creator, &clsDesc);
   }


You can create as many categories as you need. I am very happy I found that! And thanks everyone for the hints!
Cryengine tutorial videos on my Youtube channel! Check it out !
https://www.youtube.com/user/MusicForLifePL20

Who is online

Users browsing this forum: No registered users and 0 guests