deniszykov/t4-templates-unity3d

NullReference Exception

soma-web opened this issue · 8 comments

  • Bought the Asset
  • Imported it in my project
  • Created a .tt File
  • Every time I generate it I get 20 times this Exception
Failed to load template's settings: System.NullReferenceException: Object reference not set to an instance of an object
  at GameDevWare.TextTransform.TemplateSettings.Load (System.String templatePath) [0x0001d] in <269bbfe4ea7749ad8ec7178e1d170085>:0 
UnityEngine.Debug:LogError (object)
GameDevWare.TextTransform.TemplateSettings:Load (string)
GameDevWare.TextTransform.CodeCompilationTrigger:Initialize ()
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()

image

----- Appendix
image

<#@ template linePragmas="false" language="C#" #>
<#@ output extension=".cs" #>
<#@ import namespace="EscapeTheLoop.Addressables" #>
<#@ import namespace="System.Text.RegularExpressions" #>

//-----------------------------------------
// AUTO GENERATED
// please do not do any changes in here, the file is getting generated from 
//-----------------------------------------

namespace EscapeTheLoop
{
    public class AddressableConstants
    {
        
        // Auto generated constants for all addressable groups

<#
        var groups = AddressableHelper.GetAllGroups();
        foreach (var group in groups)
        {            
            if(group.Name.Contains("Built In Data")) continue;

            var addressables = AddressableHelper.GetAddressablesFromGroup(group.Name);
            if(addressables.Count == 0) continue;
#>
        #region AddressableGroup <#= group.Name #>

<#

            foreach(var addressable in addressables)
            {
#>
        public const string <#= Regex.Replace(addressable.address, "[^0-9a-zA-Z]+", "") #> = "<#= addressable.address #>";
<#
            }
#>

        #endregion

<#
        }
#>
    }
}

Hi @soma-web ! Can you specify Unity Editor's version you are using.
And while I'm investigating a problem, could you enter "Output Path" property in inspector and re-check?

Actually there is NRE fixes in TemplateSettings.Load for version 2.0.0. I did additional checks. So you could update to 2.0.1 and try out.

Downloaded the fresh .dll and imported it.

I get this Warning:

Failed to read settings for T4 Transform: Could not find file "E:\Projects\EscapeTheLoop\ETL-Unity\Assets\Editor\GameDevWare.TextTransform\GameDevWare.TextTransform.Settings.json"
UnityEngine.Debug:LogWarning (object)
GameDevWare.TextTransform.Settings:Load ()
GameDevWare.TextTransform.Settings:.cctor ()
GameDevWare.TextTransform.UnityTemplateGenerator:.ctor ()
GameDevWare.TextTransform.UnityTemplateGenerator:RunForTemplate (string,string,GameDevWare.TextTransform.TemplateSettings,System.Collections.Generic.Dictionary`2<string, string>,System.Collections.Generic.List`1<string>,System.Collections.Generic.List`1<string>,System.Collections.Generic.List`1<string>)
GameDevWare.TextTransform.UnityTemplateGenerator:RunForTemplate (string)
GameDevWare.TextTransform.Editors.TemplateInspector:OnInspectorGUI ()
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Settings file is present and looks like that:

{"ExcludeAssemblies": ["mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"], "ExcludePaths": [], "IncludePaths": [], "Verbose": false}

It is auto-created after such warning. In 6ecf74a I changed warning message to be less confusing.

thank you! Can be closed

I have the same issue - where can I get this 2.0.1 version? Asset Store still shows 2.0.0.

updated to 2.0.1