Giter Site home page Giter Site logo

deadlykam / simpleinterface Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 221 KB

A Unity3D package that helps to place prefabs easily.

License: MIT License

C# 100.00%
unity solodev prefab simple interface simpleinterface unity3d unity3d-editor unity3d-plugin kamran-wali kamran wali

simpleinterface's Introduction

Simple Interface

Introduction

This is a simple Unity3D interface that helps to put prefabs easily into the editor.

Table of Contents:

Prerequisites

Unity Game Engine

Unity3D version of 2020.3.3f1 and above should work. The main branch version is 2020.3.3f1.


Stable Build

Stable-v1.0.1 is the latest stable build of the project. The unitypackage for this project can also be found there. If development is going to be done on this project then it is advised to branch off of any Stable branches because they will NOT be changed or update except for README.md. Any other branches are subjected to change including the main branch.


Installation

  1. First download the latest SimpleInterface-vx.x.x.unitypackage from the latest Stable build.
  2. Once download is completed open up the Unity project you want to use this project in.
  3. Now go to Assets -> Import Package -> Custom Package.
  4. Select the SimpleInterface-vx.x.x you just downloaded and open it.
  5. Make sure everything is selected in the Import Unity Package otherwise there will be errors. Press the Import button to import the package.
  6. Once import is done a new menu will popup called KamranWali.
  7. Finally to open SimpleInterface go to KamranWali -> SimpleInterface. This will open up the interface like the image below.


Setup

Before using SimpleInterface you must load the prefabs. There are two ways to load prefabs, as follows:

  1. All Search - Just press the Load Prefabs button. This will search your entire project, which is from the Assets folder, for prefabs and will load them. This is not recommended as it will also search folders where there are no prefabs.
  2. Path Search (Recommended) - In Unity under the Project tab go to a folder or folders that contains the prefab. Then right click that folder and select Copy Path. Then right click the Path text field and select Paste. Press enter. Now click the Load Prefabs button. This will now search for prefabs from the given path and will be faster than the previous method. This is the recommended way for loading the prefabs.

Once the prefabs have been loaded the drop down list called Prefab Paths will be loaded with all the prefab location and a selection grid will come up with it being populated with prefabs from a single path. Also the first prefab in the first selected path/folder will be shown in the preview window like the image below.


Features

Place Prefab:

Once Setup has been done you need to first decide on which mask layer should the prefabs be placed. To do this you need to select the mask layer in Collidable Layer. Now select the prefab you want to place from the selection grid. Finally in the Scene window left click on the objects with the Collidable Layer and colliders for placing the prefab. The prefabs will be placed into the default root GameObject.

You can also place the prefabs into a certain GameObject. To do this drag and drop a GameObject from the Hierarchy window into the Root field in the Simple Interface. Now any prefab placed will be inside the Root GameObject.

You can enable/disable Place Prefab by pressing the hotkey U. It is recommended to disable Place Prefab when not working with Simple Interface for avoiding any unnecessary prefab placement.

Limit Placement:

Limit Placement allows you to control how many prefabs can be placed. First follow Place Prefab. Then enable the Limit Placement by ticking it or by pressing the hotkey B. In the Max field give the maximum number of prefabs that can be placed. Below the Max field is a label which shows how many prefabs have been placed and how many are left. The Placed value should be 0 and the Left value should be the maximum value. If they are not then press the Reset button to reset the values.

Now start placing the prefabs. You will notice that the Placed and Left values are changing as the prefabs are being placed. Once the Placed value has become the maximum value and the Left value has become 0 you won't be able to place anymore prefabs. If you want to place more prefabs of the same amount then press the Reset button or press the hotkey N for resetting the Limit Placement and this will allow to place prefabs again.

You can enable/disable Limit Placement by pressing the hotkey B.

Drag:

Drag mode allows you to place multiple prefabs of the same type in one go by holding the left mouse button and then dragging the mouse. First follow Place Prefab. Then enable the Drag by ticking it or by pressing the hotkey M. In the Scene window hold the left mouse button and drag it around to place multiple prefabs in one go.

Note: This will add lot of prefabs while dragging. To help control the prefab placement in drag mode please see Limit Placement and Offset Position.

You can enable/disable Drag by pressing the hotkey M.

Fixed Position:

Fixed Position allows you to control the placement position of the prefab by giving a fixed value to any of the Vector3 axis. First follow Place Prefab. Then enable the Fixed Position by ticking it or by pressing the hotkey I. Now select the Vector3 axis that you want to give fixed value to which are X, Y and Z. After selecting the axis you can now give a fixed value to that axis. Now place a prefab in the Scene window. You will notice that the prefab is NOT placed where you clicked but is placed in a position with fixed values for the selected axis.

You can enable/disable Fixed Position by pressing the hotkey I.

Offset Position:

Offset Position allows you to control how far a prefab should be placed from the last placed position. First follow Place Prefab. Then enable the Offset Position by ticking it or by pressing the hotkey V. Now select the Vector3 axis that you want to give a distance threshold to which are X, Y and Z. After selecting the axis you can now give a threshold value to that axis. Now place a prefab in the Scene window. Then place another prefab near the last prefab. Depending on your selected axis and threshold value the second prefab will NOT be placed near the first prefab. You can only place another prefab that is further than the threshold value from the last prefab. This will allow you to not have prefabs jumbled up together when placing them.

You can enable/disable Offset Position by pressing the hotkey V.

Fixed Rotation:

Fixed Rotation allows you to control the placement rotation of the prefab by giving a fixed rotation value to any of the Quaternion angles. First follow Place Prefab. Then enable the Fixed Rotation by ticking it or by pressing the hotkey O. Now select the Quaternion angle that you want to give fixed value to which are X, Y and Z. After selecting the angle you can now give a fixed value to that angle. Now place a prefab in the Scene window. You will notice that the prefab has been placed with the given fixed rotation angles.

You can enable/disable Fixed Rotation by pressing the hotkey O.

Random Rotation:

Random Rotation allows you to give random placment rotation of the prefab by giving a random rotation range value to any of the Quaternion angles. First follow Place Prefab. Then enable the Random Rotation by ticking it or by pressing the hotkey J. Now select the Quaternion angle that you want to give a random value to which are X, Y and Z. After selecting the angle you can now give a range value for that angle in the Min and Max fields. Now place prefabs in the Scene window. You will notice that each prefab have different rotation angles. This is because each time a prefab is placed a random angle is given to that prefab from the range value.

You can enable/disable Random Rotation by pressing the hotkey J.

Fixed Scale:

Fixed Scale allows you to control the placement scale of the prefab by giving a fixed value. First follow Place Prefab. Then enable the Fixed Scale by ticking it or by pressing the hotkey K. Now give a scale value in the Scale field. Then place a prefab in the Scene window. You will notice that the scale of the prefab has changed to the one you have just given in the Scale field.

You can enable/disable Fixed Scale by pressing the hotkey K.

Random Scale:

Random Scale allows you to give random placement scale of the prefab by giving a random scale range value. First follow Place Prefab. Then enable the Random Scale by ticking it or by pressing the hotkey L. Now give a range scale in the Min and Max fields. Then place prefabs in the Scene window. You will notice that each prefab have different scale value. This is because each time a prefab is placed a random scale is given to that prefab from the range value.

You can enable/disable Random Scale by pressing the hotkey L

Hotkeys:

  • U = Toggling prefab placement.
  • I = Toggling fixed position.
  • O = Toggling fixed Rotation.
  • J = Toggling random Rotation.
  • K = Toggling fixed Scale.
  • L = Toggling random Scale.
  • B = Toggling placement limit.
  • N = Resetting the placement counter.
  • M = Toggling drag.

Developer

Simple Interface was made by keeping simple development process for developers in mind. There are blue prints that will help in adding new layout and features into Simple Interface.

This is the main class that helps to create all the other layouts and use all the features. New BaseLayouts must be initialized in this class. The BaseLayout _placementLayout must always be in the top and the BaseLayout _logoLayout must always be at the bottom. Place any BaseLayouts in between these two BaseLayouts It also contains three import methods called Vector3 GetActualPosition(Vector3), Quaternion GetActualRotation(Quaternion) and Vector3 GetActualScale(Vector3). These three method shares the new calculated position, rotation and scale with the main BaseLayout which is the BaseLayout _placementLayout. Put the appropriate functionality feature in the correct method from your custom BaseLayout.

This is an abstract class and is the blue print for creating a new layout and functionality. Extending this class will import all the necessary methods that MUST be filled up. Check out the other classes that extends from BaseLayout to understand how it works. Here is a brief explanation of the methods:

  1. void SetupOnGUI(): This is the method where all the EditorGUILayout and GUILayout elements must be called. Basically this method handles the look of your layout.
  2. void Update(UnityEngine.Event): This is the method where user input must be handled and any continuous logic. Basically this method acts like Monobehaviour.Update() method.
  3. bool IsShown(): This method must contain the logic for saying if the layout is being shown or active.
  4. void Hide(): This method must contain the logic for hiding the layout.
  5. void SetupOnEnable(): This method contains all the logic for initializaing any local scope variable.

After filling up these methods you must initialize the custom BaseLayout in the SimpleInterfaceWindow. First add the BaseLayout with the other BaseLayout fields but in between BaseLayout _placementLayout and BaseLayout _logoLayout. Then in the void SimpleInterfaceWindow.Setup() method initialize the custom BaseLayout. Under the ===Linking Opposite Layouts=== comment add any layout that needs to be hidden when the custom BaseLayout is shown, this is optional. Now under the ===Ading Layouts=== comment add the BaseLayout to the _manager. Added right before _logoLayout. That is it and now when you open up Simple Interface in Unity3D your new custom layout will pop up at the bottom right before the logo.


Bug Fixes

  • Similar Folder Name(Issue #44): Fixed the bug where similar folder name could not populate the drop down box.

Versioning

The project uses Semantic Versioning. Available versions can be seen in tags on this repository.


Authors


License

This project is licensed under the MIT License - see the LICENSE.md file for details.


simpleinterface's People

Contributors

deadlykam avatar

Stargazers

 avatar

Watchers

 avatar  avatar

simpleinterface's Issues

Placement Fixed Rotation

Placement Fixed Rotation

Details:

Give a fixed rotation option during placement.
Hotkey = 'O'


Moving Objects

Moving Objects

Details:

The user will be able to move the objects in the scene world by selecting an object pressing a button and then pressing left click for stopping movement.

  • Selecting an object for movement.
  • Pressing a button for movement.
  • During movement mode pressing left mouse button stops the object from moving and places in the last moved position.

Simplify Editor Layout Placement

Simplify Editor Layout Placement

Detials:

Simplify the editor layout placement by making a base class that should be extended from for creating new layout. Also keep the placement position in mind for sharing the position and using it. See if this can be done like finite state machine design.

  • Base Layout Class.
  • Base Layout Class containing methods for easier creation of fields.
  • Sharing position to find actual position.

Scaling Objects

Scaling Objects

Details:

The user will be able to scale an object in the scene world by selecting the object and pressing a button to enter the scaling mode and then pressing left click for stopping scaling.

  • Selecting an object for scaling.
  • Pressing a button for scaling mode and dragging the mouse up will increase scale and moving down will decrease scale.
  • During scaling mode pressing left mosue button stops the object from scaling and keeps the last scale value.

Increment Offset Position

Increment Offset Position

Details:

A feature where the position is incremented on any given axis by any value per click. So the player does not have to keep changing the fixed position everytime.

Example:

Increment x by 10 units. First click is (10, 0, 0). Second click (20, 0, 0). etc.



Preview Background Image

Preview Background Image

Details:

Change the background image of the prefab preview. See how it is done currently and find a way to change it by giving a custom image which looks like the current Unity3D's prefab background.


Placing Objects

Placing Objects

Details:

The user will be able to place certain objects into the scene world by just pressing the left mouse button.

  • Place objects in the scene world by pressing left mouse button.
  • Toggle to activate/deactivate object placement. Hotkey = U.
  • Binding button to toggle activation/deactivateion.
  • Fixed axis value when placed. Hotkey = I

Placement Random Rotation

Placement Random Rotation

Details:

There should be an option for the user to enable/disable random rotation in any axis while placing objects.

  • Toggle random rotation. Hotkey = 'J'.
  • Input range for random rotation.

Prefab Preview

Prefab Preview

Details:

Add a preview for the selected prefab. This will help to see how the prefab looks when selecting.


Placing Prefabs

Placing Prefabs

Details:

User can select to load all the prefabs from a folder into a list of buttons so that the user can select the prefab to be placed in the scene world.


All Prefab Searching

All Prefab Searching

Details:

Make a system for searching for all of the prefabs in a project and store all the path locations to those prefabs in a drop down box. The user will simply select the prefabs from the drop down box. This will be much better to use.


Finish Writing ReadMe

Finish Writing ReadMe

Details:

Finish writing the read me file. Give as much detail as possible and make sure it is easy to understand. Give gifs as well for better understanding. Add the tutorial vid later when the vid is done making and shared.


Make Plugin

Make Plugin

Details:

Make a plugin so that it will be easier to install and start working.


First Folder Not Searched Bug

First Folder Not Searched Bug

Details:

The first folder is NOT searched for prefab. To recreate just copy paste path of a prefab folder that does NOT contain any other folders.


Similar Folder Name Issue

Similar Folder Name Issue

Detials:

Folders with similar names will only have one folder in the list and it is the last one added. Known places to look in.

  1. Directory search discards similar folder name.
  2. Combo box does not allow similar folder name.
  3. Sorting removes similar folder.

Solution Ideas:

  1. Another array storing names and if any similar names pops up then a number will be appended indicating how many of the same name exists.
  2. Adding numerical prefix to the names.

Drag Placement

Drag Placement

Details:

The user will be able to drag the mouse and hold left mouse button and keep placing objects.

  • Toggle to enable/disable drag placement. Hotkey = 'M'.
  • Button to handle toggle.
  • Pressing left mouse button and dragging mouse keeps placing objects.

Undo

Undo

Details:

User should be able to undo the actions made.


Material Search And Apply

Material Search And Apply

Material Search And Apply:

Allow the search for materials as well like the prefabs. Then select the game object that will need the updated material. Then the user can select materials from the list and the updated material will be applied to the game object while selecting.


Right Click Cancel

Right Click Cancel

Details:

Right click should cancel any changes being done in any mode and should return to the original state.

  • Store the original value/state when a mode has been selected.
  • Right click should stop the current mode and return the object to the original value/state.

Image, Icon and Version Number

Image, Icon and Version Number

Details:

At the very bottom give the image, icon and version number for SimpleInterface.


Prefab Alphabetical Order

Prefab Alphabetical Order

Details:

Order the prefab paths/folders alphabetically so that it will be easier to look and get the desired path quickly.


Placement Fixed Scale

Placement Fixed Scale

Details:

Give a fixed scale option during placement.
Hotkey = 'K'


Offset Position

Offset Position

Details:

The user should be able to place a prefab in an offset position from a previous prefab. This will help a lot during the drag mode.


Rotating Object

Rotating Object

Details:

The user will be able to rotate an object by selecting it and pressing a button for rotation and accepting the final rotation by left clicking.

  • Selecting an object for rotation.
  • Pressing a button to enter rotation mode and moving the mouse up increases rotation and moving down decreases rotation.
  • During rotation mode pressing left mouse button stops the object from rotating and places the object in last rotation.

Finite State Machine Methodology

Finite State Machine Methodology

Details:

Use the finite state machine methodology for setting up the layouts. This will ensure that the layout is only added in one place and the FSM will take care of all the update and OnGUI calls.


Placement Random Scale

Placement Random Scale

Details:

There should be an option for the user to enable/disable random scale uniformly while placing objects.

  • Toggle random scaling. Hotkey = 'L'
  • Input range for random scaling.

Placement Limit

Placement Limit

Details:

Toggle to enable/disable placement limit so the user will know how many objects needs to be placed and how many has been placed.

  • Toggle to enable/disable placement limit. Hotkey = 'B'.
  • Input for taking in placement limit. Input minimum value should be 1.
  • Display how many has been placed and how many left.
  • Button to reset the counters. Hotkey = 'N'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.