All Classes Namespaces Functions Variables Enumerations Enumerator Properties
plyCommonEditor.plyEdUtil Class Reference

Contain some helper functions for when working with Unity editor related scripts. More...

Static Public Member Functions

static ScriptableObject LoadOrCreateAsset< T > (string fn, string prettyName)
 Loads asset at given path and filename (fn), else create it. Pretty name will be shown to the user in a popup when asking if the asset may be created. Set prettyName = null to have it silently create the asset. More...
 
static GameObject CreatePrefab (string type, string name, string fn)
 Creates a new prefab and adds a component to it. More...
 
static GameObject CreatePrefab< T > (string name, string fn)
 Creates a new prefab and adds component of type T to it. More...
 
static GameObject LoadOrCreatePrefab< T > (string name, string fn)
 Loads a prefab. Creates the prefab if it does not exist. Makes sure that component T is on it. More...
 
static GameObject CopyPrefab (string prefabFn, string targetFn)
 
static void DeletePrefab (GameObject fab)
 
static List< T > FindPrefabsOfTypeAll< T > (string progressbarTitle, string progressbarInfo)
 Returns a list of prefabs of given type More...
 
static List< T > FindPrefabsOfTypeAll< T > (string progressbarTitle, string progressbarInfo, string underFolder)
 Returns a list of prefabs of given type More...
 
static void RegisterDataPathChangeListener (GeneralCallback callback)
 
static void ChangeDataPath (ref string newPath, ref string prevPath)
 
static string PackagesPathStart ()
 Will return a path relative to where the package path starts. It is assumed that plyCommonEditor.dll is in /plyCommon/Editor/. More...
 
static string PackagesRelativePathStart ()
 Uses PackagesPathStart() to get the path but will return the 'Assets/.../' relative path rather than the full path. More...
 
static string ProjectRelativePath (string fullPath)
 Return a relative path from a full path, or null if given path does not lead to a file in this project's Assets folder. Relative paths starts with 'Assets/'. More...
 
static string ToAssetsRelativePath (string relativePath)
 Removes the starting 'Assets/' from a relative path. More...
 
static string ToRelativePath (string fullPath)
 Convert Full Path to Relative Path that starts with "Assets/" More...
 
static bool RelativeFileExist (string filePath)
 Return true if the file exist (filePath should start with 'Assets') More...
 
static bool RelativePathExist (string path)
 Return true if the path exist (path should start with 'Assets') More...
 
static string GetProjectName ()
 Get project name via the project's folder name. More...
 
static string GetFileName (string path)
 Returns file name from path. More...
 
static string RemoveFileExt (string fn)
 Removes the extension from the file name. More...
 
static string GetFolder (string fn)
 Removes the file.ext form the path and return only folder. More...
 
static void CheckPath (string path)
 Checks that the path exist. Do not send a path that includes a file name. Path should start at 'Assets'. More...
 
static string MoveContents (string from, string to)
 Moves contents of 'from' path to 'to' path. Returns error message if failed, else null. Path should start at 'Assets'. More...
 
static string SceneNameFromPath (string path)
 Return only the name of the scene after removing path and '.unity' part. More...
 
static string FullPathFromPattern (string pattern)
 Looks for the specified path to file pattern in the full project path and return full path up to the file, if found. Return null if not found. More...
 
static string CheckDataPath (string parentPath, string newPath)
 Check if the newPath exist. If it does not exist it will be created. newPath must be direct child folder of parentPath. More...
 
static Color EdPrefs_GetColor (string key, Color col)
 Read saved colour value from EditorPrefs. More...
 
static void EdPrefs_SetColor (string key, Color col)
 Write colour value to EditorPrefs. More...
 
static GameObject CreateGameObjectInSceneView (string name, Vector3 offset, bool checkColliders, int mask)
 
static GameObject CreateGameObjectInSceneView (string name, Vector3 offset, bool checkColliders, int mask, GameObject prefab)
 Creates new GameObject and try to place it around where scene view camera is looking. More...
 
static Vector3 GetCreatePositionInSceneView (Vector3 offset, bool checkColliders, int mask)
 Return a position that a new object can be created at More...
 
static void PeakScriptableObject (string fn)
 
static string BuildLinkFileData (bool delOldFile, List< System.Type > usedTypes)
 
static void PlayAudioClip (AudioClip clip)
 Play audio clip in editor. More...
 
static void StopAllAudioClips ()
 Stops all audio clips playing in editor. More...
 
static GUIContent IconContent (string name, string tooltip)
 Created a GUIContent object that is an icon and tooltip. The icon is retrieved by looking up the . This is a wrapper that expose UnityEditor.EditorGUIUtility.IconContent() More...
 
static float EditorGUIIndent ()
 Get the pixel size of an indent More...
 
static Texture2D LoadIcon (string iconName)
 load internal (Unity Editor) icon More...
 
static void SetIconForObject (Object obj, Texture2D icon)
 set the icon of an object. as seen in inspector and on gizmo. More...
 
static void GetIconForObject (Object obj)
 get the icon of an object. More...
 
static void RepaintInspector (System.Type t)
 fore an inspector to repaint if it is active More...
 

Properties

static string DataPath [get, set]
 
static string FullProjectPath [get]
 The full path of the project, just before the "Assets" folder of the project (includes last slash) More...
 
static string FullProjectAssetsPath [get]
 The full path up to to the "Assets" folder of the project (excludes last slash) More...
 

Detailed Description

Contain some helper functions for when working with Unity editor related scripts.

Member Function Documentation

static string plyCommonEditor.plyEdUtil.CheckDataPath ( string  parentPath,
string  newPath 
)
static

Check if the newPath exist. If it does not exist it will be created. newPath must be direct child folder of parentPath.

static void plyCommonEditor.plyEdUtil.CheckPath ( string  path)
static

Checks that the path exist. Do not send a path that includes a file name. Path should start at 'Assets'.

static GameObject plyCommonEditor.plyEdUtil.CreateGameObjectInSceneView ( string  name,
Vector3  offset,
bool  checkColliders,
int  mask,
GameObject  prefab 
)
static

Creates new GameObject and try to place it around where scene view camera is looking.

Parameters
nameName to give newly created object.
offsetOffset from where it would be placed. Useful if you also use collider check to find terrain/ floor and then make offset y=0.01f to place it just a tad higher.
checkCollidersTrue to check colliders.
maskThe mask to use when checking colliders. Layers not in the mask will be ignored. Only used if checkColliders = true.
prefabPrefab to instantiate new object from. If null then a simple GameObject will be created.
Returns
The new game object that was created.
static GameObject plyCommonEditor.plyEdUtil.CreatePrefab ( string  type,
string  name,
string  fn 
)
static

Creates a new prefab and adds a component to it.

Parameters
typeThe type of the component to add.
nameThe name of the new prefab.
fnThe path and file to save the new prefab as.
Returns
A reference to the newly created prefab object.
static GameObject plyCommonEditor.plyEdUtil.CreatePrefab< T > ( string  name,
string  fn 
)
static

Creates a new prefab and adds component of type T to it.

Template Parameters
TComponent to add to the prefab.
Parameters
nameThe name of the new prefab.
fnThe path and file to save the new prefab as.
Returns
A reference to the newly created prefab object.
Type Constraints
T :Component 
static float plyCommonEditor.plyEdUtil.EditorGUIIndent ( )
static

Get the pixel size of an indent

static Color plyCommonEditor.plyEdUtil.EdPrefs_GetColor ( string  key,
Color  col 
)
static

Read saved colour value from EditorPrefs.

static void plyCommonEditor.plyEdUtil.EdPrefs_SetColor ( string  key,
Color  col 
)
static

Write colour value to EditorPrefs.

static List<T> plyCommonEditor.plyEdUtil.FindPrefabsOfTypeAll< T > ( string  progressbarTitle,
string  progressbarInfo 
)
static

Returns a list of prefabs of given type

Type Constraints
T :Component 
static List<T> plyCommonEditor.plyEdUtil.FindPrefabsOfTypeAll< T > ( string  progressbarTitle,
string  progressbarInfo,
string  underFolder 
)
static

Returns a list of prefabs of given type

Type Constraints
T :Component 
static string plyCommonEditor.plyEdUtil.FullPathFromPattern ( string  pattern)
static

Looks for the specified path to file pattern in the full project path and return full path up to the file, if found. Return null if not found.

static Vector3 plyCommonEditor.plyEdUtil.GetCreatePositionInSceneView ( Vector3  offset,
bool  checkColliders,
int  mask 
)
static

Return a position that a new object can be created at

static string plyCommonEditor.plyEdUtil.GetFileName ( string  path)
static

Returns file name from path.

static string plyCommonEditor.plyEdUtil.GetFolder ( string  fn)
static

Removes the file.ext form the path and return only folder.

static void plyCommonEditor.plyEdUtil.GetIconForObject ( Object  obj)
static

get the icon of an object.

static string plyCommonEditor.plyEdUtil.GetProjectName ( )
static

Get project name via the project's folder name.

static GUIContent plyCommonEditor.plyEdUtil.IconContent ( string  name,
string  tooltip 
)
static

Created a GUIContent object that is an icon and tooltip. The icon is retrieved by looking up the . This is a wrapper that expose UnityEditor.EditorGUIUtility.IconContent()

static Texture2D plyCommonEditor.plyEdUtil.LoadIcon ( string  iconName)
static

load internal (Unity Editor) icon

static ScriptableObject plyCommonEditor.plyEdUtil.LoadOrCreateAsset< T > ( string  fn,
string  prettyName 
)
static

Loads asset at given path and filename (fn), else create it. Pretty name will be shown to the user in a popup when asking if the asset may be created. Set prettyName = null to have it silently create the asset.

static GameObject plyCommonEditor.plyEdUtil.LoadOrCreatePrefab< T > ( string  name,
string  fn 
)
static

Loads a prefab. Creates the prefab if it does not exist. Makes sure that component T is on it.

Template Parameters
TComponent to add to the prefab.
Parameters
nameThe name is new prefab will be created.
fnThe path and file to save the new prefab as.
Returns
Reference to the loaded or created prefab.
Type Constraints
T :Component 
static string plyCommonEditor.plyEdUtil.MoveContents ( string  from,
string  to 
)
static

Moves contents of 'from' path to 'to' path. Returns error message if failed, else null. Path should start at 'Assets'.

static string plyCommonEditor.plyEdUtil.PackagesPathStart ( )
static

Will return a path relative to where the package path starts. It is assumed that plyCommonEditor.dll is in /plyCommon/Editor/.

static string plyCommonEditor.plyEdUtil.PackagesRelativePathStart ( )
static

Uses PackagesPathStart() to get the path but will return the 'Assets/.../' relative path rather than the full path.

static void plyCommonEditor.plyEdUtil.PlayAudioClip ( AudioClip  clip)
static

Play audio clip in editor.

static string plyCommonEditor.plyEdUtil.ProjectRelativePath ( string  fullPath)
static

Return a relative path from a full path, or null if given path does not lead to a file in this project's Assets folder. Relative paths starts with 'Assets/'.

static bool plyCommonEditor.plyEdUtil.RelativeFileExist ( string  filePath)
static

Return true if the file exist (filePath should start with 'Assets')

static bool plyCommonEditor.plyEdUtil.RelativePathExist ( string  path)
static

Return true if the path exist (path should start with 'Assets')

static string plyCommonEditor.plyEdUtil.RemoveFileExt ( string  fn)
static

Removes the extension from the file name.

static void plyCommonEditor.plyEdUtil.RepaintInspector ( System.Type  t)
static

fore an inspector to repaint if it is active

static string plyCommonEditor.plyEdUtil.SceneNameFromPath ( string  path)
static

Return only the name of the scene after removing path and '.unity' part.

static void plyCommonEditor.plyEdUtil.SetIconForObject ( Object  obj,
Texture2D  icon 
)
static

set the icon of an object. as seen in inspector and on gizmo.

static void plyCommonEditor.plyEdUtil.StopAllAudioClips ( )
static

Stops all audio clips playing in editor.

static string plyCommonEditor.plyEdUtil.ToAssetsRelativePath ( string  relativePath)
static

Removes the starting 'Assets/' from a relative path.

static string plyCommonEditor.plyEdUtil.ToRelativePath ( string  fullPath)
static

Convert Full Path to Relative Path that starts with "Assets/"

Property Documentation

string plyCommonEditor.plyEdUtil.FullProjectAssetsPath
staticget

The full path up to to the "Assets" folder of the project (excludes last slash)

string plyCommonEditor.plyEdUtil.FullProjectPath
staticget

The full path of the project, just before the "Assets" folder of the project (includes last slash)