public void Initialize(string[] names, SplatMap splatMap) { if (names == null || splatMap.data == null) { Debug.LogWarning("Failed to initialize foley map"); return; } lookup = new int[splatMap.count]; for (int i = 0, n = splatMap.count; i < n; ++i) { var texture = splatMap.data.splatPrototypes[i].texture; bool found = false; for (int j = 0, m = names.Length; j < m; ++j) { if (!string.IsNullOrEmpty(names[j])) { if (texture.name.IndexOf(names[j], StringComparison.OrdinalIgnoreCase) >= 0) { // Debug.Log("map: " + names[j] + " -- " + texture.name); lookup[i] = j; found = true; break; } } } if (!found) { Debug.LogWarningFormat("Failed to bind footstep foley to terrain texture '{0}'", texture.name); } } }
public int GetFoleyIndexAtPosition(Vector3 position, SplatMap splatMap) { if (lookup == null) { return(-1); } int index = splatMap.GetSplatIndexAtPosition(position); if (index < 0 || index >= lookup.Length) { return(-1); } return(lookup[index]); }