Jump to content

Create component using IDE


photo

Recommended Posts

Hi Cylau464,

Yes, it is possible. You can also create any component without a GUID and use it via code.
But, if you want to use them in the Editor, you need to call ComponentSystem.SaveProperties() somewhere in your AppSystemLogic.Init() method (or open the Editor). It's needed to create properties (links between data and code).

Best regards,
Alexander

  • Like 1
Link to comment
  • 3 weeks later...

Finally there was time to continue studying Unigine. And after trying to create components i ran into some difficulties.
First: properties from components without a GUID are automatically created in the root data folder. Is there any way to choose the folder in which they will be created?
Second: inheritance between components with a GUID does not work with components without it.
Third: inability to attach a component using Drag'n'drop if it does not have a GUID. It is possible only through the properties tab. It's a small thing, of course, but I still want it to work

Learn more about the second problem. I did a few manipulations with the components and eventually my engine crashed.
The algorithm of my actions:

  1. Created two components in the editor
  2. Inherited the second component from the first
  3. Two properties with inheritance were created
  4. I created another component, but already through the IDE
  5. Inherited it from the first component
  6. The new property was not created at all
  7. Removed the Component attribute from the first component
  8. The old hierarchy of properties of the first and second components has been removed
  9. A new hierarchy of properties of the first and third components has been created
  10. Returned the Component attribute to the first component with its former GUID
  11. The engine crashed
  12. After reopening the project, both property hierarchies were created

After the second attempt to do the same thing, the project stopped opening at all

  • I deleted all properties from components without GUID through the explorer and it didn't help
  • The project started only after I deleted the Component attribute from the first component again
  • I also tried to first delete the entire hierarchy of component properties without a GUID and only then return the Component attribute to the first component. It didn't work and the engine crashes anyway.

In general, as I understand it, you can work normally with components only by creating them all either in the editor or in the IDE
Inheritance of components with and without GUID is not possible because properties will not be created. I tried to apply the same approach to creating components that I use in Unity. And maybe I didn't understand something.
If it is still possible to generate a GUID for components that were not created in the editor, this would solve all the problems. Is there a function for this, which is called when creating a component in the editor? Can it be run manually for example in AppEditorLogic?

Link to comment

UGUIDs are needed for one-to-one match between a class in C# and a configured component in the editor.

There are two ways to assign a guid - through [Component(PropertyGuid = ...)] in the code or through a prop file.

In the first case, you can assign the component to a node directly by dragging file.cs onto the node.
In the second case, you need to drag the generated file.prop onto the node.

In the first case, when creating through the editor, a unique random UGUID is generated, but you can also assign any unused UGUID manually. for example

[Component(PropertyGuid = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1")]

The editor calls a function inside like this

private static UGUID GenerateGuid()
{
    UGUID guid = UGUID.Generate();
    while (Properties.IsProperty(guid)) 
    {
        guid = UGUID.Generate();
    }
    return guid;
}

In this case, you can name classes with the same names - they will receive different GUIDs and will be unambiguously interpreted.

In the second case, you are not protected from duplicate names. The component receives a GUID that depends on the name - literally SHA1 from the name.

Quote

properties from components without a GUID are automatically created in the root data folder. Is there any way to choose the folder in which they will be created?

No, they are generated automatically by the editor in the root directory. However, you can manually move them to another directory after generation and they will continue to be updated without being moved.

Quote

Second: inheritance between components with a GUID does not work with components without it.

yes, it is a known issue that currently has no solution - it is related to inheritance of property files

Quote

Third: inability to attach a component using Drag'n'drop if it does not have a GUID. It is possible only through the properties tab. It's a small thing, of course, but I still want it to work

in this case you need to drag and drop not the code file but the generated .prop file.

Quote

In general, as I understand it, you can work normally with components only by creating them all either in the editor or in the IDE Inheritance of components with and without GUID is not possible because properties will not be created. I tried to apply the same approach to creating components that I use in Unity. And maybe I didn't understand something.

Yes, it's better not to mix the two approaches.

Quote

If it is still possible to generate a GUID for components that were not created in the editor, this would solve all the problems. Is there a function for this, which is called when creating a component in the editor? 

Above I told you a couple of ways to create your own uguid. The simplest one is you can take SHA1 from the name and register it in the class properties in the code. [Component(PropertyGuid = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")]

Quote

Can it be run manually for example in AppEditorLogic?

this file has nothing to do with the editor. this is for writing your own editor.

-------

As for the engine crash, we will try to reproduce it and figure out what went wrong. thank you for message

  • Like 1
Link to comment
4 hours ago, cash-metall said:

UGUIDs are needed for one-to-one match between a class in C# and a configured component in the editor.

There are two ways to assign a guid - through [Component(PropertyGuid = ...)] in the code or through a prop file.

In the first case, you can assign the component to a node directly by dragging file.cs onto the node.
In the second case, you need to drag the generated file.prop onto the node.

In the first case, when creating through the editor, a unique random UGUID is generated, but you can also assign any unused UGUID manually. for example

[Component(PropertyGuid = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1")]

The editor calls a function inside like this

private static UGUID GenerateGuid()
{
    UGUID guid = UGUID.Generate();
    while (Properties.IsProperty(guid)) 
    {
        guid = UGUID.Generate();
    }
    return guid;
}

In this case, you can name classes with the same names - they will receive different GUIDs and will be unambiguously interpreted.

In the second case, you are not protected from duplicate names. The component receives a GUID that depends on the name - literally SHA1 from the name.

No, they are generated automatically by the editor in the root directory. However, you can manually move them to another directory after generation and they will continue to be updated without being moved.

yes, it is a known issue that currently has no solution - it is related to inheritance of property files

in this case you need to drag and drop not the code file but the generated .prop file.

Yes, it's better not to mix the two approaches.

Above I told you a couple of ways to create your own uguid. The simplest one is you can take SHA1 from the name and register it in the class properties in the code. [Component(PropertyGuid = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")]

this file has nothing to do with the editor. this is for writing your own editor.

-------

As for the engine crash, we will try to reproduce it and figure out what went wrong. thank you for message

Thank you for the detailed answer. It looks like I'll have to use an approach without using GUID, because it's more convenient for me to create components directly from IDE.

Link to comment
13 hours ago, Cylau464 said:

Thank you for the detailed answer. It looks like I'll have to use an approach without using GUID, because it's more convenient for me to create components directly from IDE.

then the best way is to add a random guide to them.

then they will look the same as created in the editor and you can work with them directly in the editor

 

  • Like 1
Link to comment
×
×
  • Create New...