Unity Community

Results 1 to 15 of 15

  1. Location

    The power of Editor scripts

    Sorry, I couldn't hold myself to share with you the awesomeness that is Editor scripting.

    I don't know if other engines provide such a tool, but the ability to hack every step in the importing process is incredibly powerful.

    Just an example :
    Basically, I have fighting characters, with precise data like frame time, hit power for each move, collision time, etc..

    2 monthes ago, before I jumped into editor scripts, I had to enter myself all those datas in each fighter's class, and moreover enter manually all the split animations in the import settings... I got more than 60 anims per char .. A pain in the ass.

    Cherry on the cake : I'm using mirrored models for right side fighters. So if I don't want to hit my overall FPS by 50% with a negative X scale, I'd had to mirror all the anims manually in my 3D too, and name them properly in unity import settings... 120 x 8 x 3 forms to enter... Depressing.

    To make it short : now with classes like ModelImport, all I have to do is drag n drop any FBX in the editor, and bam, job's done.
    Datas are written to my classes, mirrors are generated automatically by a script, and anim split by diggin a simple .txt file that I update each time I'm producing a new anim.

    To an extent, we can imagine huge factorizing for some more complex applications, like automating avatar models creation from an external database.

    I wrote this thread because according to forum threads, I can't see that Editor scripts are that much popular. They should, because they can save a truckload of time, which is vital on iPhone production

  2. Location
    I use some editor scripting too. We're making a tilebased game, so I made a tile editor inside Unity with editor scripts. It basically catches the mouse buttons, and then spawns prefabs to the scene. Additionally it allows to pick a tile from the scene as the selection and remove tiles, which makes the editing quite convenient.
    The tiles are also created by a script that takes a model and splits all its submodels into separate prefabs, adds needed components and so on.

    So yes, I do wholeheartedly agree that editor scripting is a really powerful tool, although irritatingly buggy in Unity iPhone. But when used with care (remember those backups) it can speed up the development a lot.
    Dicework Games
    CEO, Programmer

  3. Location
    The way you are using editor scripts sounds awesome. Clic-and-go state of mind is priceless for game studios.

    Furthermore, what bugs are you speaking of, in Unity's particular iPhone version ?

  4. Location
    Quote Originally Posted by n0mad
    Furthermore, what bugs are you speaking of, in Unity's particular iPhone version ?
    The EditorGUI class doesn't work at all. The ordinary GUI methods can still be used, but it doesn't include all the useful editor elements. Creating prefabs with CreateAsset can mess up the whole project, and there are some crash bugs but I can't remember the details for those.
    Dicework Games
    CEO, Programmer

  5. Location
    San Francisco & Caribbean
    Same here.

    My game is heavily adventure based with several powerups. I have a Cheat Menu with several options to set the character at several stages in the game. I can also turn on and off all the items and powerups independently.

    One of the most useful scripts I have in my workflow is one that automatically generates optimized collision colliders as an AssetPostprocessor step.

    Actually, I wished editor scripting was more powerful. Blender (beta) is a step in the right direction. I still have to take a look at Unity's 2.6 features on this regard.

    Have to agree with Nomad 100%, editor scripts are extremely useful and probably underrated.

    EDIT: Main Unity editor features look a lot more powerful, very nice.
    rozgo - developer of
    Rawbots - robots crafting sandbox game

  6. Location
    Editor scripting does appear to be powerful, but needs better documentation, IMO.

    Even after reading the manual page, it still took me a lot of trial and error to get a simple editor script to work.

    And I have experienced a few editor related crashes as well. It looks like Unity created a second assets folder, and could no longer find my scripts!

  7. Location
    Yeah, Editor scripts are absolutely cool.

    But they, indeed, lack the documentation .
    I wish all the API was documented a bit more detailed, or even allow moderated adding of examples by users.

  8. Location
    I have to agree, Editor classes documentation is too vague.

    It lacks of examples and logical links between functions. Actually it's not that hard to produce an efficient automatizer in a short time, but it does involve some trial and error.

    Come on Unity people, communicate more about it, it will save the cheer leader

  9. Posts
    I haven't used Editor scripts yet, but I'm doing something similar in my new game - I'm using Adobe Flash as a level editor, and I wrote a jsfl script (Flash's equivalent to editor scripting) to export my levels to C# classes, which I then dump into my Unity project. So while I don't use Unity editor scripting (yet), I agree that editor scripting in general can be very useful.
    UniTile - 2d Tile-based Map Editor for Unity - now also available in the Asset Store.

    My games :
    - ReRave (for iOS and Arcade)
    - Robin Hood - Archer of the Woods (published by Chillingo/Clickgamer)
    - Pig Shot (published by Nexx Studio)
    - Captain Ludwig
    - Pinkvasion
    - Deep
    - iPigeon

  10. Location
    Lyon, France
    Editor scripts are great, indeed. A few months ago, I started a thread for sharing such scripts. If anyone is interested :

    By definition, nothingness doesn't exist...

  11. Location
    That's an excellent initiative Yann

    I guess the only reason why I didn't noticed this thread is once again because I didn't know how perful was Editor scripting, back in May ...

    I'll share my automatic animation splitter as soon as it fully works (planned to be next days).

    Clever Editor scripts can open a brand new world for indies, or even studios.

    Another example that came to mind : with the MonoScript class, you could even generate a whole runtime class in a single click, depending on which object you drag and drop on the scene.

    There should even be an Editor Scripting sub forum, imho.

  12. Posts

    Script for replacing objects in your scene with a prefab

    I just made this script because of the limited capabilities of Unity to merge scene objects from one scene file to another.

    This could prove great for doing environment scene layouts. Basically, you can replace any number of objects in your scene with another prefab in your project. So whenever you feel like updating some objects in your scene, or if you accidentally messed up some prefabs, just use this script

    1. using UnityEngine;
    2. using UnityEditor;
    4. public class ReplaceSelectionWithPrefab : ScriptableWizard
    5. {
    6.     public GameObject prefab;
    7.     public bool includeChildren = false;
    8.     public bool excludePrefabs = false;
    9.     public bool deleteSelectedObjects = true;
    10.     public bool copyPosition = true;
    11.     public bool copyRotation = true;
    12.     public bool copyScale = true;
    14.     private SelectionMode modePrefs;
    17.     [MenuItem("Custom/Replace Selection with Prefab %r")]
    18.     static void DoSet()
    19.     {
    20.         ScriptableWizard.DisplayWizard("Replace Selection with Prefab", typeof(ReplaceSelectionWithPrefab), "Set");
    22.     }
    24.     void OnWizardUpdate()
    25.     {
    26.         helpString = "Duplicate the selected prefab and place it around the scene to the position of the selected objects. Tick Include Children to also place the Prefab at the position of the children of selected objects or tick Exclude Prefabs if you don't want instanced objects (from prefabs) to be changed. Tick DeleteSelectedObjects to delete the original selection after placing the prefab. The new objects are nicely placed in the same hierarchy as the old ones.";
    27.     }
    30.     void OnWizardCreate()
    31.     {
    33.         if (includeChildren || excludePrefabs)
    35.             modePrefs = (SelectionMode.ExcludePrefab | SelectionMode.Editable | SelectionMode.Deep);
    36.         else
    37.             modePrefs = (SelectionMode.Editable);
    39.         Object[] objs = Selection.GetFiltered(typeof(GameObject), modePrefs);
    41.         foreach (GameObject go in objs)
    42.         {
    46.             clone.name = prefab.name;
    47.             clone.transform.parent = go.transform.parent;
    48.             if (copyPosition)
    49.             {
    50.                 clone.transform.localPosition = go.transform.localPosition;
    51.             }
    52.             if (copyRotation)
    53.             {
    54.                 clone.transform.localRotation = go.transform.localRotation;
    55.             }
    56.             if (copyScale)
    57.             {
    58.                 clone.transform.localScale = go.transform.localScale;
    59.             }
    62.         }
    63.         if (deleteSelectedObjects)
    64.         {
    65.             foreach (GameObject go in objs)
    66.             {
    67.                 DestroyImmediate(go.gameObject);
    68.             }
    69.         }
    71.     }
    72. }

  13. Location

    I finally finished mine, a mirrored animationClip generator.

    Unfortunately, I came to realize that it's so dependant on each character rig that I couldn't succeed with producing a generic script.

    So all I could do was a methods guideline.

    Hope it helps,


  14. Location
    SF Bay Area, CA, USA

  15. Posts
    I myself have just discovered this feature, which I believe on its own rises Unity FAR above the competition.

    I am an avid Maya user, and write custom scripts for my team at work, so this editor customization is pretty much an exact clone of how Maya works, so I totally appreciate it.

    I'm falling in love with Unity more and more each day.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts