/// <summary> /// Overloading Unity function for initiatization for this script /// </summary> void Start() { this.urdf = new UrdfDb(); this.currState = UIState.Create; // assume that the default is to add a sensor right away this.sensors = new List <GameObject>(); categoryHolderList = new Dictionary <int, GameObject>(); setupForm(); SensorPanelSetup(); }
/// <summary> /// Handles post process on all assets within Unity Editor. Finds all meshes and creates /// a Unity prefab allowing easy instation at runtime. For more information about this Unity /// Message Handle: http://docs.unity3d.com/ScriptReference/AssetPostprocessor.OnPostprocessAllAssets.html /// </summary> /// <param name="importedAssets">List of paths to assets that have been imported</param> /// <param name="deletedAssets">List of paths to assets that have been deleted</param> /// <param name="movedAssets">List of paths to assets that have been moved</param> /// <param name="movedFromAssetPaths">List of paths to assets that have been moved from paths</param> static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { if (importedAssets.Length > 0) { FileType type = FileType.UNKNOWN; foreach (string assetPath in importedAssets) { string filename = FileManagerImpl.GetFileName(assetPath, false); type = FileManagerImpl.GetFileType(assetPath); UnityEngine.Object asset = AssetDatabase.LoadMainAssetAtPath(assetPath); // Creating prefab here will cause this function to be invoked again causing an infinite loop of // assets being generated. Proper Check of the Object is of type GameObject, isn't part of a prefab // and that the asset is a proper model that can become a prefab. if (asset.GetType() == typeof(GameObject) && PrefabUtility.GetPrefabParent(asset) == null && PrefabUtility.GetPrefabType(asset) == PrefabType.ModelPrefab) { // To properly create a prefab of the object we need to instantiate it into // the game world and save that object as a prefab. GameObject go = GameObject.Instantiate <GameObject>((GameObject)asset); go.name = asset.name; // remove the (clone) within the name. PrefabUtility.CreatePrefab(string.Format(prefabItemPathFormat, go.name), go); GameObject.DestroyImmediate(go); } else if (type == FileType.URDF || type == FileType.XACRO) { string prefabName = CreateUrdfRobot(assetPath); if (!String.IsNullOrEmpty(prefabName)) { UrdfItemModel item = new UrdfItemModel(); item.name = filename; item.urdfFilename = assetPath; item.prefabFilename = prefabName; item.visibility = 1; UrdfDb db = new UrdfDb(); db.AddSensor(item); } } } } }