Beispiel #1
0
        //needs to assign the text asset as part of its creation
        static void ProcessAsset(string origLocation, TextAsset txt, DeadSimpleCSV csv)
        {
            //if matching file exists, then get it
            ExternalVarsSO extvar = ExternalVarsSOManager.Instance().FindByExternalFile(txt);

            var  fileName     = origLocation.Substring(0, origLocation.Length - (".csv".Length)) + ".asset";
            bool createdAsset = false;

            //if not create it an
            if (extvar == null)
            {
                extvar          = ExternalVarsSO.CreateInstance <ExternalVarsSO>();
                extvar.localCSV = txt;
                AssetDatabase.CreateAsset(extvar, fileName);
                createdAsset = true;
            }

            try
            {
                extvar.GenerateVars(csv.ConvertRowsToObjects <ExternalVarsSO.VarSpec>());
            }
            catch (Exception)
            {
                if (createdAsset)
                {
                    AssetDatabase.DeleteAsset(fileName);
                    UnityEngine.Object.DestroyImmediate(extvar);
                }
            }
        }
Beispiel #2
0
        public void NotifyNoLongerExists(ExternalVarsSO extVar)
        {
            allExternalVars.Remove(extVar);
#if UNITY_EDITOR
            EditorUtility.SetDirty(this);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
#endif
        }
Beispiel #3
0
        public void NotifyExists(ExternalVarsSO extVar)
        {
            if (!allExternalVars.Contains(extVar))
            {
                allExternalVars.Add(extVar);
            }
#if UNITY_EDITOR
            EditorUtility.SetDirty(this);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
#endif
        }
Beispiel #4
0
        public override void OnInspectorGUI()
        {
            ExternalVarsSO extVar = target as ExternalVarsSO;

            if (GUILayout.Button("Generate from Local CSV"))
            {
                extVar.GenerateVarsLocalCSV();
            }
            if (GUILayout.Button("Remove & Delete All"))
            {
                extVar.RemoveVars();
            }
            if (GUILayout.Button("Write all to Local CSV"))
            {
                extVar.WriteVarsToLocal();
            }

            EditorGUILayout.Space();
            base.OnInspectorGUI();
        }