Difference between revisions of "LevelEditor"

From Project Wiki
Jump to navigation Jump to search
Line 56: Line 56:
 
This is not nearly as easy as adding new Variants to the Leveleditor, so this should only be done by a programmer.
 
This is not nearly as easy as adding new Variants to the Leveleditor, so this should only be done by a programmer.
  
==== Where it needs to be added ====
+
=== Object Template ===
 +
<code>public GameObject[] objectName = null;</code>
 +
 
 +
and
 +
 
 +
<code>if (objectName != null)</code>
 +
 
 +
<code>           list.Add(objectName);</code>
  
 
== FAQ ==
 
== FAQ ==

Revision as of 13:40, 3 June 2021

LayoutLevelEdit.png

How do I build a new Level?

Placing Objects

Select the Object Type from the left Sidebar.

Select the Variant and Rotation as well.

Press [Leftclick], when the crosshair is green to place the object.

Editing Objects

Press [Leftclick], when the crosshair is red to select the object.

The Inspector in the right Sidebar should now show all variables you can edit.

Use the Sliders, Inputfields, etc. to edit the object.

Removing Objects

Press [Rightclick], when the crosshair is red, to remove the object.

Saving Levels (Needs Edit once Naming System exists)

Use the Save Button on the left sidebar.

How do I edit an existing Level?

Loading Levels (Needs Edit once Naming System exists)

Use the Load Button on the left sidebar.

How can I test a Level?

In the current state, you can move the maincharacter with the usual inputs while in Edit Mode, instantly testing while you build.

It's recommended to SAVE before testing out, and LOAD after you're done testing, else it could potentially cause problems.

Soon there will be a dedicated test feature utilizing the "Play Mode"

How do I add new Variants to the Leveleditor?

Variants here mean mostly visual variants to an already existing template object, for example a green version of a Sentry.

Creating the Variant

Currently, in Assets/Prefabs/Interactables/Templates, there is a Template Prefab with only the code-relavant part.

Add the Visual Change below the "Model" child object.

After you're done with the changes, save the prefab as a Variant.

Adding the Variant

Currently, in Assets/Scripts/Leveleditor there is a file called "Editor Template"

It contains mulitple list of Variant-Prefabs.

Add the Variant-Prefab you created to the list, to automatically add it to the Leveleditor system.

How do I add new Objects to the Leveleditor?

This is not nearly as easy as adding new Variants to the Leveleditor, so this should only be done by a programmer.

Object Template

public GameObject[] objectName = null;

and

if (objectName != null)

           list.Add(objectName);

FAQ

What does the Colour of the crosshair mean?

- Green: Grid is Empty

- Red: Grid is not Empty

- Purple: Object is Selected

More added when Questions occur

OLD

How to use the Level Editor? (Is to general)

Placing Objects:

  1. Aim the cursor at the place you want to place the object
  2. Check that the outline is green
  3. Click the left mouse button

Removing Objects:

  1. Aim the cursor at the place you want to remove the object
  2. Check that the outline is red
  3. Click the right mouse button

Saving Levels:

  1. Click the 'Save Level' button

Loading Levels:

  1. Click the 'Load Level' button

How does the Level Editor work? (Maybe Remove this?)

Placing Objects:

  1. Checking the world position of the cursor
  2. Checking if the grid is empty or not
  3. Instantiating the selected object as child of the "Parent" tagged object

Removing Objects:

  1. Checking the world position of the cursor
  2. Checking if the grid is empty or not
  3. Destroy object in selected grid

Saving Levels:

  1. Find all categorised objects using tags (Wall, Sentry, etc.)
  2. Convert them all into a stripped down serializable datatype
  3. Insert the stripped down data into an array
  4. Create a LevelData from all of the data arrays
  5. Use a binary formatter to encrypt the level data
  6. Save the encrypted data to file

Loadng Levels:

  1. Read the data from file
  2. Use a binary formatter to decrypt the data into a LevelData
  3. Clearing the level by destroying all objects of the "Parent" tagged object
  4. Building the level by instantiating every object from LevelData as child of the "Parent" tagged object according to the list of prefabs given by the ObjectTemplate