/// <summary> /// If object added is a scene, set the scene ID. /// </summary> /// <param name="data">Current data for this action field.</param> /// <returns>ID for the scene.</returns> private static void SetScene(ref UnityObjectFieldData data) { // if item is scene asset, add to to build settings SceneAsset testScene = data.fieldValue as SceneAsset; if (testScene != null) { // add the scene to the editor build settings if it doesn't already exist there. data.sceneID = HeroKitCommon.AddSceneToBuildSettings(testScene); data.sceneName = testScene.name; } }
/// <summary> /// Fields for the hero property (unity objects). /// </summary> private static void DrawUnityObjects() { List <UnityObjectField> items = propertyBlock.itemProperties.unityObjects.items; // exit early if there are no values if (items == null || items.Count == 0) { return; } SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB); for (int i = 0; i < items.Count; i++) { SimpleLayout.Label(items[i].name + ":"); switch (items[i].objectType) { case 1: // audio items[i].value = SimpleLayout.ObjectField(items[i].value as AudioClip, HeroKitCommon.GetWidthForField(60, 150)); break; case 2: // sprite items[i].value = SimpleLayout.ObjectField(items[i].value as Sprite, HeroKitCommon.GetWidthForField(60, 150)); break; case 3: // scene items[i].value = SimpleLayout.ObjectField(items[i].value as SceneAsset, HeroKitCommon.GetWidthForField(60, 150)); if (items[i].value != null) { // add the scene to the editor build settings if it doesn't already exist there. HeroKitCommon.AddSceneToBuildSettings(items[i].value as SceneAsset); } break; case 4: // particle system items[i].value = SimpleLayout.ObjectField(items[i].value as ParticleSystem, HeroKitCommon.GetWidthForField(60, 150)); break; case 5: // script items[i].value = SimpleLayout.ObjectField(items[i].value as MonoScript, HeroKitCommon.GetWidthForField(60, 150)); break; } } SimpleLayout.EndVertical(); }
/// <summary> /// Draw the body of the block. /// </summary> private static void DrawItems() { // exit early if there are no items if (items == null || items.Count == 0) { HeroKitCommon.DrawNoItemsInList(blockName); return; } SimpleLayout.BeginVertical(Box.StyleCanvasBox); // display items (move up, move down, int field, for (int i = 0; i < items.Count; i++) { SimpleLayout.BeginHorizontal(); HeroKitCommon.DrawListArrows(moveItemUp, moveItemDown, i); SimpleLayout.BeginVertical(); items[i].objectType = new UnityObjectTypeField().SetValues(items[i].objectType, HeroKitCommon.GetWidthForField(270, 150)); switch (items[i].objectType) { case 1: // audio items[i].value = SimpleLayout.ObjectField(items[i].value as AudioClip, HeroKitCommon.GetWidthForField(270, 150)); break; case 2: // sprite items[i].value = SimpleLayout.ObjectField(items[i].value as Sprite, HeroKitCommon.GetWidthForField(270, 150)); break; case 3: // scene items[i].value = SimpleLayout.ObjectField(items[i].value as SceneAsset, HeroKitCommon.GetWidthForField(270, 150)); if (items[i].value != null) { // add the scene to the editor build settings if it doesn't already exist there. HeroKitCommon.AddSceneToBuildSettings(items[i].value as SceneAsset); } break; case 4: // particle system items[i].value = SimpleLayout.ObjectField(items[i].value as ParticleSystem, HeroKitCommon.GetWidthForField(270, 150)); break; case 5: // mono script items[i].value = SimpleLayout.ObjectField(items[i].value as MonoScript, HeroKitCommon.GetWidthForField(270, 150)); break; } items[i].name = SimpleLayout.StringListField(items[i].name, HeroKitCommon.GetWidthForField(270, 150)); SimpleLayout.EndVertical(); HeroKitCommon.DrawListButtons(addItem, copyItem, pasteItem, deleteItem, i); SimpleLayout.EndHorizontal(); if (i != items.Count - 1) { SimpleLayout.Line(); } } SimpleLayout.EndVertical(); SimpleLayout.Space(20); }