private void GetCloneInfos(Func <int, int, bool> getIgnore, out LayersDic layersDic, out LayerCollsDic collsDic) { layersDic = new LayersDic(); collsDic = new LayerCollsDic(); for (var i = 0; i < UnityLayerCount; i++) { var layerName = LayerMask.LayerToName(i); if (string.IsNullOrEmpty(layerName) == true) { continue; } layersDic.Add(i, layerName); } var keys = new List <int>(layersDic.Keys).Select((key, index) => new { key, index }); foreach (var layerID1 in keys) { var index1 = layerID1.index + UnityLayerCount; collsDic.Add(index1, new Dictionary <int, bool>()); foreach (var layerID2 in keys) { collsDic[index1].Add(layerID2.index + UnityLayerCount, !getIgnore(layerID1.key, layerID2.key)); collsDic[index1].Add(layerID2.key, !getIgnore(layerID1.key, layerID2.key)); } } layersDic = layersDic .Select((pair, i) => new { pair, i }) .ToDictionary(v => v.i + UnityLayerCount, v => v.pair.Value); }
private void Clone(LayersDic layersDic, LayerCollsDic collsDic) { Undo.RecordObject(this, "Changed Physics Layers"); this.PhysicsLayerInfos.Update(layersDic); foreach (var layer in layersDic) { if (collsDic.ContainsKey(layer.Key) == false) { return; } var colls = collsDic[layer.Key]; this.PhysicsLayerInfos[layer.Key].Update(colls); } EditorUtility.SetDirty(this); Undo.IncrementCurrentGroup(); }