Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by ReggieBeRetro · Jan 19, 2019 at 01:07 AM · listscustom-inspector

List inside of a list in a custom window

Im working on a Quest Builder to manage and create quests for my game so to get right to it each Quest can have a required amount of enemies to be killed. I have everything pretty much working until I figured out my problem. When I select a Quest to edit the EnemyQuestData is populated to the editor window which is fine and all good. But when I try to edit a different Quest It is pulling from the same list of enemy prefabs. Each quest should have its own list of enemies that is required to be killed. Below is the whole code.

Im sure if I knew this from the start I would have this problem.

I am having trouble implementing EnemyQuestData into EnemyQuestDataLists then when the Edit button is pushed I would like to have the editor window populate with the correct EnemyQuestDataLists.EnemyQuestData.EnemyPrefabsList based on the index of the quest that is selected.

Edit button starts on line 258 OnGUI start on 318

I can provide the JSON database if needed.

I keep getting confused and frankly need a new pair of eyes on this.

Any help is much appreciated. Thank you

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEditor;
 using System.IO;
 using UnityEngine.UI;
 using System;
 [CustomEditor(typeof(DisplayPlayerQuestProgression))]
 public class DisplayPlayerQuestProgressionEditor : EditorWindow
 {
     public GUIStyle guiStyle;
     private string questDataFilePath = "coreQuestData.json";
     private string CoreQJsonDatabaseURLPath = "http://localhost/tictacttoe/quests/";
     public int itemnum;
     public new string QName;
     public int QItemIndex;
     public string QDescr;
     public int QID;
     public string digitLength;
     public int newQItemID;
     public Sprite QItemOverlay;
     public Sprite QItemArtWork;
     public GameObject QItemModel;
     public GameObject QItemPrefab;
     public string QItemFactionType;
     public string QItemClassType;
     public int[] QAwardedInventoryItemIDs;
     public int[] QAwardMultipliers;
     public int QnewAwardedInventoryItemID;
     public int QnewAwardMultiplier;
     public int[] QTriggerAwardedInventoryItemIDs;
     public int[] QTriggerAwardMultipliers;
     public int QnewTriggerAwardedInventoryItemID;
     public int QnewTriggerAwardMultiplier;
     public bool QCompletionStatus;
     public bool isQItemVisible;
     public bool QuestAwardsEnabled;
     public bool QuestTriggerAwardsEnabled;
     public bool IDGroupEnabled;
     public bool RandomSelectToggle;
     public bool GiveAllSelectToggle;
     public bool TriggerRandomSelectToggle;
     public bool TriggerGiveAllSelectToggle;
     public bool QPlayerInputSelectToggle;
     public bool QProxSelectToggle;
     public bool QCustIntSelectToggle;
     public bool QPrefabInventorySelectToggle;
     public List<GameObject> QIntPrefabItemPrefabs;
     public GameObject QIntPrefabItemPrefab;
     public GameObject QInteractionItemPrefab;
     public bool CompletionPrerequisitesEnabled;
     public int QProxUnits;
     public bool RemoveFailedSelectToggle;
     public bool QKillEnemeySelectToggle;
     public bool QIntReqSelectToggle;
     public int QnewPrereqKillCount;
     public GameObject QnewEnemyPrefab;
     public int[] QPrereqKillCounts;
     public List<GameObject> QEnemyPrefabs;
     bool QuestEventsEnabled;
     int selected = 0;
     int wasselected = 0;
     int selectedInputType = 0;
     int selectedprefabInputType = 0;
     int wasselectedprefabInputType = 0;
     int wasselectedInputType = 0;
     bool AwardSysEnabled = false;
     public EnemyQuestData eData;
     public EnemyQuestDataLists eDataLists;
     Vector2 scrollPos;
     Vector2 scrollPos2;
     Vector2 toolscrollPos;
     Vector2 questscrollPos;
     Vector2 awardscrollPos;
     Vector2 awardtriggerscrollPos;
     Vector2 scrollPos3;
     string t = "This is a Inventory Item inside a Scroll view!";
     public string[] options = new string[] {
   "Story",
   "Faction",
   "Random",
   "Drop",
   "Event",
   "Daily",
   "All",
  };
     public string[] optionsInputType = new string[] {
   "Proximity Only",
   "Left Mouse Down",
   "Right Mouse Down",
   "Use Interation Button",
   "Space Bar",
  };
     public string[] optionsprefabInputType = new string[] {
   "Prefab in Player Inventory",
   "Use Interation Button",
   "Sold Item",
   "Purchased Item",
   "Traded Item",
   "Gave Item",
   "Destroyed Item",
   "Recycled Item",
  };
 
     private int selectedTab = 0;
 
     // Add menu named "My Window" to the Window menu
     [MenuItem("Window/ClientX/QuestBuidler")]
     static void Init()
     {
         // Get existing open window or if none, make a new one:
         DisplayPlayerQuestProgressionEditor window = (DisplayPlayerQuestProgressionEditor)EditorWindow.GetWindow(typeof(DisplayPlayerQuestProgressionEditor));
 
         window.Show();
 
     }
     [System.Serializable]
     public class EnemyQuestDataLists
     {
         public List<List<EnemyQuestData>> EnemyPrefabsLists;
      
 
     }
     [System.Serializable]
     public class EnemyQuestData
     {
         public List<GameObject> EnemyPrefabsList;
         public List<int> EnemyKillCountList;
         public List<GameObject> InteractionPrefabsList;
     }
     [System.Serializable]
     public class ePrefab
     {
         public GameObject EnemyPrefabObj;
         public GameObject InterationPrefabObj;
     }
     [System.Serializable]
     public class QNode
     {
         public int QItemIndex;
         public string QdigitLength;
         public int QItemID;
         public string QItemName;
         public string QItemDescr;
         public string QItemType;
         public Sprite QItemOverlay;
         public Sprite QItemArtWork;
         public GameObject QItemModel;
         public GameObject QItemPrefab;
         public string QItemFactionType;
         public string QItemClassType;
         public int[] QAwardedInventoryItemIDs;
         public int[] QAwardMultipliers;
         // public int QnewAwardedInventoryItemID;
         // public int QnewAwardMultiplier;
         public int[] QTriggerAwardedInventoryItemIDs;
         public int[] QTriggerAwardMultipliers;
         public bool QCompletionStatus;
         public bool isQItemVisible;
         //  public int QnewTriggerAwardedInventoryItemID;
         // public int QnewTriggerAwardMultiplier;
         public bool QPlayerInputSelectToggle;
         public int QProxUnits;
         public bool QuestAwardsEnabled;
         public bool QuestTriggerAwardsEnabled;
         public bool IDGroupEnabled;
         public bool RandomSelectToggle;
         public bool GiveAllSelectToggle;
         public bool TriggerRandomSelectToggle;
         public bool TriggerGiveAllSelectToggle;
         public bool RemoveFailedSelectToggle;
         public bool QuestEventsEnabled;
         public bool QProxSelectToggle;
         public bool QCustIntSelectToggle;
         public bool QPrefabInventorySelectToggle;
         public List<GameObject> QIntPrefabItemPrefabs;
         public GameObject QInteractionItemPrefab;
         public GameObject QIntPrefabItemPrefab;
         public bool CompletionPrerequisitesEnabled;
         public int QnewPrereqKillCount;
         //public GameObject QnewEnemyPrefab;
         public int[] QPrereqKillCounts;
         public List<GameObject> QEnemyPrefabs;
         public bool QKillEnemeySelectToggle;
         public bool QIntReqSelectToggle;
     }
     [System.Serializable]
     public class QuestsData
     {
         public List<QNode> questItems;
     }
     public void LoadQuestsDataFile(string qtype)
     {
         string filePath = Application.dataPath + "/Editor/coreQuestsData.json";
         if (File.Exists(filePath))
         {
             string dataAsJson = File.ReadAllText(filePath);
             // string INVData = JsonUtility.FromJson<QNode>(dataAsJson);
             LoadQuestsData(dataAsJson, qtype);
         }
     }
     public void LoadQuestsData(string datatoparse, string qtype)
     {
         //string filePath = Application.dataPath + questDataProjectFilePath;
         itemnum = 0;
         if (datatoparse != null)
         {
             // string dataAsJson = File.ReadAllText(filePath);
             QuestsData qdata = JsonUtility.FromJson<QuestsData>(datatoparse);
             if (qdata.questItems.Count > 0)
             {
                 int itemnum = 0;
                 foreach (QNode qtemp in qdata.questItems)
                 {
                     //Debug.Log(itemp.QItemID);
                     if ((qtype == qtemp.QItemType) || (qtype == "All"))
                     {
                         if (qtemp.QItemIndex == itemnum)
                         {
                             SpawnQuestNode(qtemp.QItemIndex, qtemp.QdigitLength, qtemp.QItemID, qtemp.QItemName,
                              qtemp.QItemType, qtemp.QItemDescr, qtemp.QItemOverlay, qtemp.QItemArtWork, qtemp.QItemModel,
                              qtemp.QItemPrefab, qtemp.QItemFactionType, qtemp.QItemClassType, qtemp.QAwardedInventoryItemIDs,
                              qtemp.QAwardMultipliers, qtemp.QTriggerAwardedInventoryItemIDs, qtemp.QTriggerAwardMultipliers,
                              qtemp.QCompletionStatus, qtemp.isQItemVisible, qtemp.QPlayerInputSelectToggle, qtemp.QProxUnits,
                              qtemp.QuestAwardsEnabled, qtemp.QuestTriggerAwardsEnabled, qtemp.IDGroupEnabled,
                              qtemp.RandomSelectToggle, qtemp.GiveAllSelectToggle, qtemp.TriggerRandomSelectToggle,
                              qtemp.TriggerGiveAllSelectToggle, qtemp.RemoveFailedSelectToggle, qtemp.QuestEventsEnabled,
                              qtemp.QProxSelectToggle, qtemp.QCustIntSelectToggle, qtemp.QPrefabInventorySelectToggle,
                              qtemp.QIntPrefabItemPrefabs, qtemp.CompletionPrerequisitesEnabled, qtemp.QnewPrereqKillCount,
                              qtemp.QPrereqKillCounts, qtemp.QEnemyPrefabs, qtemp.QKillEnemeySelectToggle, qtemp.QIntReqSelectToggle, qtemp.QInteractionItemPrefab);
                         }
                     }
                     itemnum++;
                 }
             }
         }
         else
         {
             QuestsData qdata = new QuestsData();
         }
     }
     public void SpawnQuestNode(int itemindex, string digitLength, int itemid, string itemname, string itemtype, string itemdescr, Sprite itemoverlay, Sprite artWork, GameObject qItemModel, GameObject qItemPrefab, string itemfactionType, string itemclassType, int[] awardedInventoryItemIDs, int[] awardMultipliers, int[] triggerawardedInventoryItemIDs, int[] triggerawardMultipliers, bool qCompletionStatus, bool isqitemvisible, bool qPlayerInputSelectToggle, int qProxUnits, bool questAwardsEnabled, bool questTriggerAwardsEnabled, bool iDGroupEnabled, bool randomSelectToggle, bool giveAllSelectToggle, bool triggerRandomSelectToggle, bool triggerGiveAllSelectToggle, bool removeFailedSelectToggle, bool questEventsEnabled, bool qProxSelectToggle, bool qCustIntSelectToggle, bool qPrefabInventorySelectToggle, List<GameObject> qIntPrefabItemPrefabs, bool completionPrerequisitesEnabled, int qnewPrereqKillCount, int[] qPrereqKillCounts, List<GameObject> qEnemyPrefabs, bool qKillEnemeySelectToggle, bool qIntReqSelectToggle, GameObject qInteractionItemPrefab)
     {
         //parent at first history node.
         //Debug.Log(itemname);
         foreach (string qtype in options)
         {
             if (itemtype == qtype)
             {
                 // GUILayout.BeginArea(new Rect(10, 10, 300, 100));
                 EditorGUILayout.BeginHorizontal();
                 EditorGUILayout.BeginVertical();
                 GUILayout.Box("Index: " + itemindex);
                 GUILayout.Box("ID: " + itemid);
                 GUILayout.Box("Title: " + itemname);
                 EditorGUILayout.EndVertical();
                 EditorGUILayout.BeginVertical();
                 if (GUILayout.Button("Edit", GUILayout.Width(100), GUILayout.Height(40)))
                 {
                     // Debug.Log("viewing this quest item " + itemid);
                     QName = itemname;
                     QDescr = itemdescr;
                     newQItemID = itemid;
                     QItemIndex = itemindex;
                     QItemOverlay = itemoverlay;
                     QItemArtWork = artWork;
                     QItemModel = qItemModel;
                     QItemPrefab = qItemPrefab;
                     QItemFactionType = itemfactionType;
                     QItemClassType = itemclassType;
                     QTriggerAwardedInventoryItemIDs = triggerawardedInventoryItemIDs;
                     QTriggerAwardMultipliers = triggerawardMultipliers;
                     QAwardedInventoryItemIDs = awardedInventoryItemIDs;
                     QAwardMultipliers = awardMultipliers;
                     QCompletionStatus = qCompletionStatus;
                     isQItemVisible = isqitemvisible;
                     QPlayerInputSelectToggle = qPlayerInputSelectToggle;
                     QProxUnits = qProxUnits;
                     QuestAwardsEnabled = questAwardsEnabled;
                     QuestTriggerAwardsEnabled = questTriggerAwardsEnabled;
                     IDGroupEnabled = iDGroupEnabled;
                     RandomSelectToggle = randomSelectToggle;
                     GiveAllSelectToggle = giveAllSelectToggle;
                     TriggerRandomSelectToggle = triggerRandomSelectToggle;
                     TriggerGiveAllSelectToggle = triggerGiveAllSelectToggle;
                     RemoveFailedSelectToggle = removeFailedSelectToggle;
                     QuestEventsEnabled = questEventsEnabled;
                     QProxSelectToggle = qProxSelectToggle;
                     QCustIntSelectToggle = qCustIntSelectToggle;
                     QPrefabInventorySelectToggle = qPrefabInventorySelectToggle;
                     QIntPrefabItemPrefabs = qIntPrefabItemPrefabs;
                     CompletionPrerequisitesEnabled = completionPrerequisitesEnabled;
                     QnewPrereqKillCount = qnewPrereqKillCount;
                     QInteractionItemPrefab = qInteractionItemPrefab;
                     //public GameObject QnewEnemyPrefab;
                     QPrereqKillCounts = qPrereqKillCounts;
                     QEnemyPrefabs = qEnemyPrefabs;
                     QKillEnemeySelectToggle = qKillEnemeySelectToggle;
                     QIntReqSelectToggle = qIntReqSelectToggle;
                 }
                 EditorGUILayout.EndHorizontal();
                 EditorGUILayout.EndVertical();
                 //GUILayout.EndArea();
             }
         }
     }
     // Use this for initialization
     void Start()
     {
         eData = new EnemyQuestData();
         eDataLists = new EnemyQuestDataLists();
         //eDataLists.EnemyPrefabsLists.Add();
         
 
     }
     // Update is called once per frame
     void Update() { }
     void OnGUI()
     {
 
 
 
 
         EditorGUILayout.BeginHorizontal();
         EditorGUILayout.BeginVertical();
         GUILayout.Label("Quest Buidler", EditorStyles.boldLabel);
         selected = EditorGUILayout.Popup("Browse by type", selected, options);
         EditorGUILayout.Space();
         GUILayout.Label("" + options[selected] + " Quests", EditorStyles.boldLabel);
         scrollPos =
          EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(300), GUILayout.Height(400));
         EditorGUILayout.BeginVertical();
         DisplayQuestItems(selected);
         EditorGUILayout.Space();
         EditorGUILayout.EndVertical();
         EditorGUILayout.EndScrollView();
         if (options[selected] != "All")
         {
             if (GUILayout.Button("Create New " + options[selected] + " Quest", GUILayout.Width(300), GUILayout.Height(35)))
             {
                 QNode newQuestItem = new QNode();
                 newQuestItem.QItemName = "New " + options[selected] + " Quest";
                 newQuestItem.QItemType = options[selected];
                 string filePath = Application.dataPath + "/Editor/coreQuestsData.json";
                 string datatoparse = File.ReadAllText(filePath);
                 QuestsData qdata = JsonUtility.FromJson<QuestsData>(datatoparse);
                 newQuestItem.QItemIndex = qdata.questItems.Count;
                 int dnum = 0;
                 string digitInt = "";
                 string maxdigitInt = "";
                 newQuestItem.QdigitLength = "6";
                 int dLength;
                 int.TryParse(newQuestItem.QdigitLength, out dLength);
                 while (dnum < dLength)
                 {
                     digitInt = digitInt + "1";
                     maxdigitInt = maxdigitInt + "9";
                     dnum++;
                 }
                 int minlength;
                 int.TryParse(digitInt, out minlength);
                 int maxlength;
                 int.TryParse(maxdigitInt, out maxlength);
                 newQuestItem.QItemID = UnityEngine.Random.Range(minlength, maxlength);
                 newQuestItem.QItemDescr = "This is a new item description.";
                 newQuestItem.isQItemVisible = true;
                 int indexnum = 0;
                 bool inserted = false;
                 bool doneinsert = false;
                 int skippedindexes = 0;
                 foreach (QNode invnode in qdata.questItems)
                 {
                     if (qdata.questItems[indexnum].QItemIndex != indexnum)
                     {
                         newQuestItem.QItemIndex = invnode.QItemIndex + 1;
                     }
                     indexnum++;
                 }
                 //if all index's match append the new quest item to the end of the json database
                 qdata.questItems.Add(newQuestItem);
                 // Debug.Log(newQuestItem.QItemType);
                 string dataAsJson = JsonUtility.ToJson(qdata);
                 File.WriteAllText(filePath, dataAsJson);
             }
         }
         EditorGUILayout.Space();
         if (GUILayout.Button("Delete all (Wipe Quests Data)", GUILayout.Width(300), GUILayout.Height(25)))
         {
             string filePath = Application.dataPath + "/Editor/coreQuestsData.json";
             if (File.Exists(filePath))
             {
                 string datatoparse = File.ReadAllText(filePath);
                 QuestsData qdata = JsonUtility.FromJson<QuestsData>(datatoparse);
                 qdata.questItems.Clear();
                 //Debug.Log(newInventoryItem.InvItemType);
                 string dataAsJson = JsonUtility.ToJson(qdata);
                 File.WriteAllText(filePath, dataAsJson);
             }
         }
 
         EditorGUILayout.Space();
         EditorGUILayout.EndVertical();
 
         EditorGUILayout.BeginVertical();
         string[] tabs = {
    "Quest Details",
    "Completion Requirements",
    "Trigger Events",
    "Award System"
   };
         selectedTab = GUILayout.Toolbar(selectedTab, tabs);
 
         EditorGUILayout.Space();
 
         if (selectedTab == 0)
         {
             QName = EditorGUILayout.TextField("Quest Title:", QName);
             EditorGUILayout.Space();
             IDGroupEnabled = EditorGUILayout.BeginToggleGroup("Item ID Options", IDGroupEnabled);
             digitLength = EditorGUILayout.TextField("ID Digit Length", digitLength);
             if (GUILayout.Button("Generate Random ID", GUILayout.Width(300), GUILayout.Height(20)))
                 t += " \n New Random ID Generated!";
             newQItemID = EditorGUILayout.IntField("Item ID", newQItemID);
             EditorGUILayout.EndToggleGroup();
             EditorGUILayout.Space();
             QItemIndex = EditorGUILayout.IntField("Index", QItemIndex);
             EditorGUILayout.Space();
             QItemFactionType = EditorGUILayout.TextField("Faction Type", QItemFactionType);
             EditorGUILayout.Space();
             QItemClassType = EditorGUILayout.TextField("Class Type", QItemClassType);
             EditorGUILayout.Space();
             QDescr = EditorGUILayout.TextField("Description", QDescr);
             EditorGUILayout.Space();
             EditorGUILayout.BeginHorizontal();
             EditorGUILayout.PrefixLabel("Quest Overlay");
             QItemOverlay = (Sprite)EditorGUILayout.ObjectField(QItemOverlay, typeof(Sprite), allowSceneObjects: true);
             EditorGUILayout.EndHorizontal();
             EditorGUILayout.BeginHorizontal();
             EditorGUILayout.PrefixLabel("Quest Artwork");
             QItemArtWork = (Sprite)EditorGUILayout.ObjectField(QItemArtWork, typeof(Sprite), allowSceneObjects: true);
             EditorGUILayout.EndHorizontal();
             EditorGUILayout.Space();
             EditorGUILayout.BeginHorizontal();
             EditorGUILayout.PrefixLabel("Quest Prefab");
             QItemPrefab = (GameObject)EditorGUILayout.ObjectField(QItemPrefab, typeof(GameObject), allowSceneObjects: true);
             EditorGUILayout.EndHorizontal();
         }
         EditorGUILayout.Space();
         if (selectedTab == 1)
         {
            
 
 
             QKillEnemeySelectToggle = EditorGUILayout.Toggle("Kill Enemey Unit(s)", QKillEnemeySelectToggle);
             //start of enemey kill toggle
             if (QKillEnemeySelectToggle)
             {
                 EditorGUILayout.BeginHorizontal();
                 EditorGUILayout.BeginHorizontal();
                 EditorGUILayout.PrefixLabel("Enemy Prefab");
                 QnewEnemyPrefab = (GameObject)EditorGUILayout.ObjectField(QnewEnemyPrefab, typeof(GameObject), allowSceneObjects: true);
                 EditorGUILayout.EndHorizontal();
                 QnewPrereqKillCount = EditorGUILayout.IntSlider("Qty", QnewPrereqKillCount, 0, 1000);
                 if (GUILayout.Button("Add", GUILayout.Width(50), GUILayout.Height(20)))
                 {
                     GameObject newPrefab = new GameObject();
                     //newPrefab = QnewEnemyPrefab;
                     newPrefab = QnewEnemyPrefab;
                     // newPrefab.name = "test";
                     if (newPrefab)
                     {
                         eData.EnemyPrefabsList.Add(newPrefab);
                         QnewEnemyPrefab = null;
                     }
                     else
                     {
                         Debug.Log("Prefab Not found.");
                     }
                     Debug.Log("Added new prefab");
                 }
                 EditorGUILayout.EndHorizontal();
                 EditorGUILayout.Space();
                 int g = 0;
                 //EnemyQuestData eData;
                 // if (eData.EnemyPrefabsList.Count > 0) {
                 //foreach (ePrefab gobj in eData.EnemyPrefabsList) {
                 EditorGUILayout.BeginHorizontal();
                 EditorGUILayout.BeginVertical();
                 if (eData != null)
                 {
                     if (eData.EnemyPrefabsList.Count > 0)
                     {
                         //int g = 0;
                         foreach (GameObject prefabObj in eData.EnemyPrefabsList)
                         {
                             if (prefabObj)
                             {
                                 EditorGUILayout.BeginHorizontal();
                                 EditorGUILayout.BeginHorizontal();
                                 EditorGUILayout.PrefixLabel("Enemy Prefab");
                                 eData.EnemyPrefabsList[g] = (GameObject)EditorGUILayout.ObjectField(eData.EnemyPrefabsList[g], typeof(GameObject), allowSceneObjects: true);
                                 EditorGUILayout.EndHorizontal();
                                 if (QPrereqKillCounts[g] != null)
                                 {
                                     Debug.Log(g);
                                    // if (QPrereqKillCounts[g] > 0)
                                // {
                                 //    QPrereqKillCounts[g] = EditorGUILayout.IntSlider("Qty", QPrereqKillCounts[g], 0, 1000);
                                 //}
                             }
                                     if (GUILayout.Button("Remove", GUILayout.Width(65), GUILayout.Height(20)))
                                 {
                                     Debug.Log("removed enemy from list");
                                 }
                                 EditorGUILayout.EndHorizontal();
                             }
                             g++;
                         }
                     }
                     else
                     {
                         EditorGUILayout.PrefixLabel("No Prefabs found.");
                     }
                 }
                 else
                 {
                     EditorGUILayout.PrefixLabel("Error list not created.");
                 }
                 EditorGUILayout.EndVertical();
                 EditorGUILayout.EndHorizontal();
                 // End Of Prefab List
                  
                 
             }
             EditorGUILayout.BeginVertical();
             QIntReqSelectToggle = EditorGUILayout.Toggle("Interaction Required", QIntReqSelectToggle);
             if (QIntReqSelectToggle)
             {
                 EditorGUILayout.BeginHorizontal();
                 EditorGUILayout.BeginHorizontal();
                 EditorGUILayout.PrefixLabel("Prefab");
                 QIntPrefabItemPrefab = (GameObject)EditorGUILayout.ObjectField(QIntPrefabItemPrefab, typeof(GameObject), allowSceneObjects: true);
                 selectedprefabInputType = EditorGUILayout.Popup("", selectedprefabInputType, optionsprefabInputType);
                 EditorGUILayout.EndHorizontal();
                 if (GUILayout.Button("Add", GUILayout.Width(50), GUILayout.Height(20)))
                 {
                     GameObject newPrefab = new GameObject();
                     //newPrefab = QnewEnemyPrefab;
                     newPrefab = QIntPrefabItemPrefab;
                     // newPrefab.name = "test";
                     if (newPrefab)
                     {
                         eData.InteractionPrefabsList.Add(newPrefab);
                         QIntPrefabItemPrefab = null;
                     }
                     else
                     {
                         Debug.Log("Prefab Not found.");
                     }
                     Debug.Log("added new interaction prefab to list");
                 }
                 EditorGUILayout.EndHorizontal();
                 EditorGUILayout.Space();
                 int intnum = 0;
                 if (eData != null) { 
                 if (eData.InteractionPrefabsList.Count <= 0)
                 {
                     EditorGUILayout.PrefixLabel("No Prefabs found.");
                 }
                 else
                 {
                     //int g = 0;
                     foreach (GameObject prefabObj in eData.InteractionPrefabsList)
                     {
                         if (prefabObj)
                         {
                             EditorGUILayout.BeginHorizontal();
                             EditorGUILayout.BeginHorizontal();
                             EditorGUILayout.PrefixLabel("Interaction Prefab");
                             eData.InteractionPrefabsList[intnum] = (GameObject)EditorGUILayout.ObjectField(eData.InteractionPrefabsList[intnum], typeof(GameObject), allowSceneObjects: true);
                             EditorGUILayout.EndHorizontal();
                             // QPrereqKillCounts[g] = EditorGUILayout.IntSlider("Qty", QPrereqKillCounts[g], 0, 1000);
                             if (GUILayout.Button("Remove", GUILayout.Width(65), GUILayout.Height(20)))
                             {
                                 Debug.Log("removed interaction prefab from list");
                             }
                             EditorGUILayout.EndHorizontal();
                         }
                         intnum++;
                     }
                 }
             }
                 intnum++;
             }
             
         }
 
         EditorGUILayout.Space();
 
 
 
         if (selectedTab == 2)
         {
 
 
             QCustIntSelectToggle = EditorGUILayout.Toggle("Custom Interaction Prefab", QCustIntSelectToggle);
             EditorGUILayout.BeginHorizontal();
             EditorGUILayout.PrefixLabel("Interaction Prefab");
             if (!QCustIntSelectToggle)
             {
                 QIntPrefabItemPrefab = QItemPrefab;
             }
             QInteractionItemPrefab = (GameObject)EditorGUILayout.ObjectField(QInteractionItemPrefab, typeof(GameObject), allowSceneObjects: true);
             EditorGUILayout.EndHorizontal();
             EditorGUILayout.Space();
             EditorGUILayout.BeginHorizontal();
             QProxSelectToggle = EditorGUILayout.Toggle("Player proximity to prefab", QProxSelectToggle);
             QProxUnits = EditorGUILayout.IntField("x units away", QProxUnits);
             EditorGUILayout.EndHorizontal();
             EditorGUILayout.BeginHorizontal();
             QPlayerInputSelectToggle = EditorGUILayout.Toggle("Player input on prefab", QPlayerInputSelectToggle);
             selectedInputType = EditorGUILayout.Popup("", selectedInputType, optionsInputType);
             EditorGUILayout.EndHorizontal();
 
 
         }
         EditorGUILayout.Space();
 
 
         if (selectedTab == 3)
         {
             QuestTriggerAwardsEnabled = EditorGUILayout.BeginToggleGroup("Enable Awarded Items When Quest Accepted", QuestTriggerAwardsEnabled);
             if (QuestTriggerAwardsEnabled)
             {
                 EditorGUILayout.BeginVertical();
                 EditorGUILayout.Space();
                 EditorGUILayout.BeginHorizontal();
                 EditorGUILayout.PrefixLabel("If Player failed the quest ");
                 RemoveFailedSelectToggle = EditorGUILayout.Toggle("remove these items", RemoveFailedSelectToggle);
                 EditorGUILayout.EndHorizontal();
                 EditorGUILayout.Space();
                 EditorGUILayout.BeginHorizontal();
                 if (TriggerGiveAllSelectToggle)
                 {
                     TriggerRandomSelectToggle = false;
                     TriggerGiveAllSelectToggle = true;
                 }
                 TriggerRandomSelectToggle = EditorGUILayout.Toggle("RNG Select Only One", TriggerRandomSelectToggle);
                 if (TriggerRandomSelectToggle)
                 {
                     TriggerGiveAllSelectToggle = false;
                     TriggerRandomSelectToggle = true;
                 }
                 else
                 {
                     TriggerRandomSelectToggle = false;
                     TriggerGiveAllSelectToggle = true;
                 }
                 TriggerGiveAllSelectToggle = EditorGUILayout.Toggle("Give Player All Items", TriggerGiveAllSelectToggle);
                 EditorGUILayout.EndHorizontal();
                 EditorGUILayout.Space();
                 EditorGUILayout.BeginHorizontal();
                 EditorGUILayout.PrefixLabel("Add Inventory Item");
                 QnewTriggerAwardedInventoryItemID = EditorGUILayout.IntField("ID:", QnewTriggerAwardedInventoryItemID);
                 QnewTriggerAwardMultiplier = EditorGUILayout.IntField("Qty", QnewTriggerAwardMultiplier);
                 if (GUILayout.Button("Add", GUILayout.Width(50), GUILayout.Height(20)))
                 {
                     Debug.Log("addnew reward item to list");
                 }
                 EditorGUILayout.EndHorizontal();
                 EditorGUILayout.BeginVertical();
                 awardtriggerscrollPos =
                  EditorGUILayout.BeginScrollView(awardtriggerscrollPos, GUILayout.Width(550), GUILayout.Height(80));
                 int qnum = 0;
                 if (QTriggerAwardedInventoryItemIDs.ToString() != "")
                 {
                     if (QTriggerAwardedInventoryItemIDs.Length > 0)
                     {
                         foreach (int I in QTriggerAwardedInventoryItemIDs)
                         {
                             EditorGUILayout.BeginHorizontal();
                             EditorGUILayout.PrefixLabel("Inventory Item");
                             QTriggerAwardedInventoryItemIDs[qnum] = EditorGUILayout.IntField("ID:", QTriggerAwardedInventoryItemIDs[qnum]);
                             QTriggerAwardMultipliers[qnum] = EditorGUILayout.IntField("Qty", QTriggerAwardMultipliers[qnum]);
                             EditorGUILayout.EndHorizontal();
                             qnum++;
                         }
                     }
                 }
                 EditorGUILayout.EndScrollView();
                 EditorGUILayout.EndHorizontal();
                 
             }
             EditorGUILayout.EndToggleGroup();
             QuestAwardsEnabled = EditorGUILayout.BeginToggleGroup("Enable Awarded Items On Completion", QuestAwardsEnabled);
             if (QuestAwardsEnabled)
             {
                 EditorGUILayout.BeginVertical();
                 EditorGUILayout.BeginHorizontal();
                 if (GiveAllSelectToggle)
                 {
                     RandomSelectToggle = false;
                     GiveAllSelectToggle = true;
                 }
                 RandomSelectToggle = EditorGUILayout.Toggle("RNG Select Only One", RandomSelectToggle);
                 if (RandomSelectToggle)
                 {
                     GiveAllSelectToggle = false;
                     RandomSelectToggle = true;
                 }
                 else
                 {
                     RandomSelectToggle = false;
                     GiveAllSelectToggle = true;
                 }
                 GiveAllSelectToggle = EditorGUILayout.Toggle("Give Player All Items", GiveAllSelectToggle);
                 EditorGUILayout.EndHorizontal();
                 EditorGUILayout.Space();
                 EditorGUILayout.BeginHorizontal();
                 EditorGUILayout.PrefixLabel("Add Inventory Item");
                 QnewAwardedInventoryItemID = EditorGUILayout.IntField("ID:", QnewAwardedInventoryItemID);
                 QnewAwardMultiplier = EditorGUILayout.IntField("Qty", QnewAwardMultiplier);
                 if (GUILayout.Button("Add", GUILayout.Width(50), GUILayout.Height(20)))
                 {
                     Debug.Log("addnew reward item to list");
                 }
                 EditorGUILayout.EndHorizontal();
                 EditorGUILayout.BeginVertical();
                 awardscrollPos =
                  EditorGUILayout.BeginScrollView(awardscrollPos, GUILayout.Width(550), GUILayout.Height(80));
                 int qnum = 0;
                 if (QAwardedInventoryItemIDs.Length > 0)
                 {
                     if (QAwardedInventoryItemIDs.ToString() != "")
                     {
                         if (QAwardedInventoryItemIDs.Length > 0)
                         {
                             foreach (int I in QAwardedInventoryItemIDs)
                             {
                                 EditorGUILayout.BeginHorizontal();
                                 EditorGUILayout.PrefixLabel("Inventory Item");
                                 QAwardedInventoryItemIDs[qnum] = EditorGUILayout.IntField("ID:", QAwardedInventoryItemIDs[qnum]);
                                 QAwardMultipliers[qnum] = EditorGUILayout.IntField("Qty", QAwardMultipliers[qnum]);
                                 EditorGUILayout.EndHorizontal();
                                 qnum++;
                             }
                         }
                     }
                 }
                 EditorGUILayout.EndScrollView();
                 EditorGUILayout.EndVertical();
 
             }
 
             EditorGUILayout.EndToggleGroup();
 
         }
 
 
 
 
 
         EditorGUILayout.BeginHorizontal();
         if (GUILayout.Button("Delete selected quest", GUILayout.Width(200), GUILayout.Height(20)))
         {
             string filePath = Application.dataPath + "/Editor/coreQuestsData.json";
             string datatoparse = File.ReadAllText(filePath);
             QuestsData qdata = JsonUtility.FromJson<QuestsData>(datatoparse);
             qdata.questItems.RemoveAt(QItemIndex);
             //idata.inventoryItems.Insert(InvItemIndex, newInventoryItem);
             string dataAsJson = JsonUtility.ToJson(qdata);
             File.WriteAllText(filePath, dataAsJson);
         }
         if (GUILayout.Button("Save All Settings", GUILayout.Width(300), GUILayout.Height(30)))
         {
             string filePath = Application.dataPath + "/Editor/coreQuestsData.json";
             string datatoparse = File.ReadAllText(filePath);
             QuestsData qdata = JsonUtility.FromJson<QuestsData>(datatoparse);
 
             foreach (QNode QI in qdata.questItems)
             {
                 if (newQItemID == QI.QItemID)
                 {
                     QNode newQItem = new QNode();
                     newQItem.QItemName = QName;
                     newQItem.QItemType = options[selected];
                     filePath = Application.dataPath + "/Editor/coreQuestsData.json";
                     datatoparse = File.ReadAllText(filePath);
                     qdata = JsonUtility.FromJson<QuestsData>(datatoparse);
                     newQItem.QItemIndex = QItemIndex;
                     newQItem.QItemID = newQItemID;
                     newQItem.QItemDescr = QDescr;
                     newQItem.QItemArtWork = QItemArtWork;
                     newQItem.QItemOverlay = QItemOverlay;
                     newQItem.QItemModel = QItemModel;
                     newQItem.QItemPrefab = QItemPrefab;
                     newQItem.QItemFactionType = QItemFactionType;
                     newQItem.QItemClassType = QItemClassType;
                     newQItem.QAwardedInventoryItemIDs = QAwardedInventoryItemIDs;
                     newQItem.QAwardMultipliers = QAwardMultipliers;
                     //newQItem.QnewAwardedInventoryItemID = QnewAwardedInventoryItemID;
                     //newQItem.QnewAwardMultiplier = QnewAwardMultiplier;
                     newQItem.QTriggerAwardedInventoryItemIDs = QTriggerAwardedInventoryItemIDs;
                     newQItem.QTriggerAwardMultipliers = QTriggerAwardMultipliers;
                     //newQItem.QnewTriggerAwardedInventoryItemID = QnewTriggerAwardedInventoryItemID;
                     // newQItem.QnewTriggerAwardMultiplier = QnewTriggerAwardMultiplier;
                     newQItem.QCompletionStatus = QCompletionStatus;
                     newQItem.isQItemVisible = isQItemVisible;
                     newQItem.QuestAwardsEnabled = QuestAwardsEnabled;
                     newQItem.QuestTriggerAwardsEnabled = QuestTriggerAwardsEnabled;
                     newQItem.IDGroupEnabled = IDGroupEnabled;
                     newQItem.RandomSelectToggle = RandomSelectToggle;
                     newQItem.GiveAllSelectToggle = GiveAllSelectToggle;
                     newQItem.TriggerRandomSelectToggle = TriggerRandomSelectToggle;
                     newQItem.TriggerGiveAllSelectToggle = TriggerGiveAllSelectToggle;
                     newQItem.RemoveFailedSelectToggle = RemoveFailedSelectToggle;
                     newQItem.isQItemVisible = isQItemVisible;
                     newQItem.QPlayerInputSelectToggle = QPlayerInputSelectToggle;
                     newQItem.QProxUnits = QProxUnits;
                     newQItem.QuestAwardsEnabled = QuestAwardsEnabled;
                     newQItem.QuestTriggerAwardsEnabled = QuestTriggerAwardsEnabled;
                     newQItem.IDGroupEnabled = IDGroupEnabled;
                     newQItem.RandomSelectToggle = RandomSelectToggle;
                     newQItem.GiveAllSelectToggle = GiveAllSelectToggle;
                     newQItem.TriggerRandomSelectToggle = TriggerRandomSelectToggle;
                     newQItem.TriggerGiveAllSelectToggle = TriggerGiveAllSelectToggle;
                     newQItem.RemoveFailedSelectToggle = RemoveFailedSelectToggle;
                     newQItem.QuestEventsEnabled = QuestEventsEnabled;
                     newQItem.QProxSelectToggle = QProxSelectToggle;
                     newQItem.QCustIntSelectToggle = QCustIntSelectToggle;
                     newQItem.QPrefabInventorySelectToggle = QPrefabInventorySelectToggle;
                     newQItem.QIntPrefabItemPrefab = QIntPrefabItemPrefab;
                     newQItem.QIntPrefabItemPrefabs = eData.InteractionPrefabsList;
                     newQItem.CompletionPrerequisitesEnabled = CompletionPrerequisitesEnabled;
                     newQItem.QnewPrereqKillCount = QnewPrereqKillCount;
                     //public GameObject QnewEnemyPrefab;
                     newQItem.QPrereqKillCounts = QPrereqKillCounts;
                     newQItem.QEnemyPrefabs = eData.EnemyPrefabsList;
                     newQItem.QKillEnemeySelectToggle = QKillEnemeySelectToggle;
                     newQItem.QIntReqSelectToggle = QIntReqSelectToggle;
                     qdata.questItems.RemoveAt(QItemIndex);
                     qdata.questItems.Insert(QItemIndex, newQItem);
                     // Debug.Log(newQItem.QItemType);
                     string dataAsJson = JsonUtility.ToJson(qdata);
                     File.WriteAllText(filePath, dataAsJson);
                     Debug.Log("Done Saving Quest Changes");
                 }
             }
         }
         EditorGUILayout.EndHorizontal();
 
 
 
         // 
 
         EditorGUILayout.EndVertical();
 
 
 
 
     }
     public void DisplayQuestItems(int selectedType)
     {
         if (wasselected != selectedType)
         {
             QName = "";
             QDescr = "";
             QItemIndex = 0;
             QItemArtWork = null;
             QItemOverlay = null;
             QItemModel = null;
             QItemPrefab = null;
             newQItemID = 0;
             QItemFactionType = null;
             QItemClassType = null;
             QAwardedInventoryItemIDs = null;
             QAwardMultipliers = null;
             QCompletionStatus = false;
             isQItemVisible = true;
             QPlayerInputSelectToggle = false;
             QProxUnits = 3; ;
             QuestAwardsEnabled = false;
             QuestTriggerAwardsEnabled = false;
             IDGroupEnabled = false;
             RandomSelectToggle = false;
             GiveAllSelectToggle = false;
             TriggerRandomSelectToggle = false;
             TriggerGiveAllSelectToggle = false;
             RemoveFailedSelectToggle = false;
             QuestEventsEnabled = false;
             QProxSelectToggle = false;
             QCustIntSelectToggle = false;
             QPrefabInventorySelectToggle = false;
             QIntPrefabItemPrefabs = null;
             QInteractionItemPrefab = null;
             QIntPrefabItemPrefab = null;
             CompletionPrerequisitesEnabled = false;
             QnewPrereqKillCount = 0;
             QnewEnemyPrefab = null;
             QPrereqKillCounts = null;
             QEnemyPrefabs = null;
             QKillEnemeySelectToggle = false;
             QIntReqSelectToggle = false;
             //isQItemVisible = true;
         }
         if (selectedType == 0)
         {
             // GetTypeItemsFromQ(selectedType,options[selectedType]);
             //StartCoroutine(Started());
             LoadQuestsDataFile(options[selectedType]);
             EditorGUILayout.Space();
             wasselected = selected;
         }
         if (selectedType == 1)
         {
             LoadQuestsDataFile(options[selectedType]);
             EditorGUILayout.Space();
             wasselected = selected;
         }
         if (selectedType == 2)
         {
             LoadQuestsDataFile(options[selectedType]);
             EditorGUILayout.Space();
             wasselected = selected;
         }
         if (selectedType == 3)
         {
             LoadQuestsDataFile(options[selectedType]);
             EditorGUILayout.Space();
             wasselected = selected;
         }
         if (selectedType == 4)
         {
             LoadQuestsDataFile(options[selectedType]);
             EditorGUILayout.Space();
             wasselected = selected;
         }
         if (selectedType == 5)
         {
             LoadQuestsDataFile(options[selectedType]);
             EditorGUILayout.Space();
             wasselected = selected;
         }
         if (selectedType == 6)
         {
             LoadQuestsDataFile(options[selectedType]);
             EditorGUILayout.Space();
             wasselected = selected;
         }
     }
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
â–¼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

99 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Enum-like menu to display list elements? 1 Answer

Custom Inspector List Resetting after Play 0 Answers

Comparing list values 1 Answer

SQLite and Lists in C# 1 Answer

Removing the last duplicate of an object in List 4 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges