Skip to content

Commit d51a964

Browse files
committed
衝突情報の設定部分の処理を最適化
1 parent d4d8dd0 commit d51a964

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2443
-2140
lines changed
Lines changed: 135 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,135 @@
1-
using System.Collections;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using UnityEngine;
5-
using UnityEditor;
6-
7-
namespace a3geek.PhysicsLayers.Editors
8-
{
9-
using Common;
10-
using Components.InternalManagements;
11-
12-
public partial class LayersManagerInspector
13-
{
14-
private void DrawPhysicsLayers(Dictionary<int, string> layers)
15-
{
16-
EditorGUI.indentLevel += 1;
17-
18-
using(var vert = new EditorGUILayout.VerticalScope())
19-
{
20-
using(var hori = new EditorGUILayout.HorizontalScope())
21-
{
22-
EditorGUILayout.PrefixLabel("Size");
23-
24-
var count = EditorGUILayout.DelayedIntField(layers.Count);
25-
layers.SetCount(count, index => index + LayersManager.UnityLayerCount, index => "PhysicsLayer" + index);
26-
}
27-
28-
EditorGUILayout.Space();
29-
30-
var layerIDs = new List<int>(layers.Keys);
31-
foreach(var layerID in layerIDs)
32-
{
33-
using(var hori = new EditorGUILayout.HorizontalScope())
34-
{
35-
var layerName = layers[layerID];
36-
37-
EditorGUILayout.PrefixLabel("Layer ID : " + layerID);
38-
layers[layerID] = EditorGUILayout.DelayedTextField(layerName);
39-
40-
if(string.IsNullOrEmpty(layers[layerID]) == true)
41-
{
42-
layers[layerID] = layerName;
43-
}
44-
45-
if(GUILayout.Button("Delete"))
46-
{
47-
layers.Remove(layerID);
48-
}
49-
}
50-
}
51-
}
52-
53-
EditorGUI.indentLevel -= 1;
54-
}
55-
56-
private void DrawCollInfos(PhysicsLayerInfos layerInfos)
57-
{
58-
EditorGUI.indentLevel += 1;
59-
60-
this.collInfosFolders.SetCount(layerInfos.LayerCount, index => new CollInfosFolders());
61-
62-
var i = 0;
63-
foreach(var physicsLayer in layerInfos.GetEnumerable().OrderBy(layer => layer.LayerID))
64-
{
65-
var folder = this.collInfosFolders[i];
66-
folder.collision = EditorGUILayout.Foldout(folder.collision, "Collision : " + physicsLayer.LayerName, true);
67-
if(this.collInfosFolders[i].collision == false)
68-
{
69-
i++;
70-
continue;
71-
}
72-
73-
var collInfos = physicsLayer.CollisionInfos;
74-
75-
EditorGUI.indentLevel += 1;
76-
using(var vert = new EditorGUILayout.VerticalScope())
77-
{
78-
var keys = collInfos.Keys.OrderBy(info => info);
79-
var physicsKeys = keys.Where(key => key >= LayersManager.UnityLayerCount);
80-
81-
folder.unityLayer = EditorGUILayout.Foldout(folder.unityLayer, "Unity Layers", true);
82-
if(folder.unityLayer == true)
83-
{
84-
EditorGUI.indentLevel += 1;
85-
86-
var unityKeys = keys.Where(key => key < LayersManager.UnityLayerCount);
87-
foreach(var key in unityKeys)
88-
{
89-
collInfos[key] = this.DrawCollInfo(key, collInfos[key]);
90-
}
91-
92-
EditorGUI.indentLevel -= 1;
93-
}
94-
95-
EditorGUILayout.Space();
96-
folder.physicsLayer = EditorGUILayout.Foldout(folder.physicsLayer, "Physics Layers", true);
97-
if(folder.physicsLayer == true)
98-
{
99-
EditorGUI.indentLevel += 1;
100-
101-
foreach(var key in physicsKeys)
102-
{
103-
if(key < physicsLayer.LayerID)
104-
{
105-
collInfos[key] = layerInfos[key][physicsLayer.LayerID].Collision;
106-
}
107-
else
108-
{
109-
collInfos[key] = this.DrawCollInfo(key, collInfos[key]);
110-
}
111-
}
112-
113-
EditorGUI.indentLevel -= 1;
114-
}
115-
}
116-
117-
i++;
118-
physicsLayer.Update(collInfos);
119-
EditorGUI.indentLevel -= 1;
120-
}
121-
122-
EditorGUI.indentLevel -= 1;
123-
}
124-
125-
private bool DrawCollInfo(int layerID, bool collision)
126-
{
127-
using(var hori = new EditorGUILayout.HorizontalScope())
128-
{
129-
EditorGUILayout.PrefixLabel(this.Target.LayerToName(layerID));
130-
return EditorGUILayout.Toggle(collision);
131-
}
132-
}
133-
}
134-
}
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using UnityEngine;
5+
using UnityEditor;
6+
7+
namespace a3geek.PhysicsLayers.Editors
8+
{
9+
using Common;
10+
using Components.InternalManagements;
11+
using Common.Extensions;
12+
13+
public partial class LayersManagerInspector
14+
{
15+
private void DrawPhysicsLayers(Dictionary<int, string> layers)
16+
{
17+
EditorGUI.indentLevel += 1;
18+
19+
using(var vert = new EditorGUILayout.VerticalScope())
20+
{
21+
using(var hori = new EditorGUILayout.HorizontalScope())
22+
{
23+
EditorGUILayout.PrefixLabel("Size");
24+
25+
var count = EditorGUILayout.DelayedIntField(layers.Count);
26+
layers.SetCount(count, index => index + LayersManager.UnityLayerCount, index => "PhysicsLayer" + index);
27+
}
28+
29+
EditorGUILayout.Space();
30+
31+
var layerIDs = new List<int>(layers.Keys);
32+
foreach(var layerID in layerIDs)
33+
{
34+
using(var hori = new EditorGUILayout.HorizontalScope())
35+
{
36+
var layerName = layers[layerID];
37+
38+
EditorGUILayout.PrefixLabel("Layer ID : " + layerID);
39+
layers[layerID] = EditorGUILayout.DelayedTextField(layerName);
40+
41+
if(string.IsNullOrEmpty(layers[layerID]) == true)
42+
{
43+
layers[layerID] = layerName;
44+
}
45+
46+
if(GUILayout.Button("Delete"))
47+
{
48+
layers.Remove(layerID);
49+
}
50+
}
51+
}
52+
}
53+
54+
EditorGUI.indentLevel -= 1;
55+
}
56+
57+
private void DrawCollInfos(PhysicsLayerInfos layerInfos)
58+
{
59+
EditorGUI.indentLevel += 1;
60+
61+
this.collInfosFolders.SetCount(layerInfos.LayerCount, index => new CollInfosFolders());
62+
63+
var i = 0;
64+
foreach(var physicsLayer in layerInfos.GetEnumerable().OrderBy(layer => layer.LayerID))
65+
{
66+
var folder = this.collInfosFolders[i];
67+
folder.collision = EditorGUILayout.Foldout(folder.collision, "Collision : " + physicsLayer.LayerName, true);
68+
if(this.collInfosFolders[i].collision == false)
69+
{
70+
i++;
71+
continue;
72+
}
73+
74+
var collInfos = physicsLayer.CollisionInfos;
75+
76+
EditorGUI.indentLevel += 1;
77+
using(var vert = new EditorGUILayout.VerticalScope())
78+
{
79+
var keys = collInfos.Keys.OrderBy(info => info);
80+
var physicsKeys = keys.Where(key => key >= LayersManager.UnityLayerCount);
81+
82+
folder.unityLayer = EditorGUILayout.Foldout(folder.unityLayer, "Unity Layers", true);
83+
if(folder.unityLayer == true)
84+
{
85+
EditorGUI.indentLevel += 1;
86+
87+
var unityKeys = keys.Where(key => key < LayersManager.UnityLayerCount);
88+
foreach(var key in unityKeys)
89+
{
90+
collInfos[key] = this.DrawCollInfo(key, collInfos[key]);
91+
}
92+
93+
EditorGUI.indentLevel -= 1;
94+
}
95+
96+
EditorGUILayout.Space();
97+
folder.physicsLayer = EditorGUILayout.Foldout(folder.physicsLayer, "Physics Layers", true);
98+
if(folder.physicsLayer == true)
99+
{
100+
EditorGUI.indentLevel += 1;
101+
102+
foreach(var key in physicsKeys)
103+
{
104+
if(key < physicsLayer.LayerID)
105+
{
106+
collInfos[key] = layerInfos[key][physicsLayer.LayerID].Collision;
107+
}
108+
else
109+
{
110+
collInfos[key] = this.DrawCollInfo(key, collInfos[key]);
111+
}
112+
}
113+
114+
EditorGUI.indentLevel -= 1;
115+
}
116+
}
117+
118+
i++;
119+
physicsLayer.Update(collInfos);
120+
EditorGUI.indentLevel -= 1;
121+
}
122+
123+
EditorGUI.indentLevel -= 1;
124+
}
125+
126+
private bool DrawCollInfo(int layerID, bool collision)
127+
{
128+
using(var hori = new EditorGUILayout.HorizontalScope())
129+
{
130+
EditorGUILayout.PrefixLabel(this.Target.LayerToName(layerID));
131+
return EditorGUILayout.Toggle(collision);
132+
}
133+
}
134+
}
135+
}
Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
using System.Collections;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using UnityEngine;
5-
using UnityEditor;
6-
7-
namespace a3geek.PhysicsLayers.Editors
8-
{
9-
using Common;
10-
using Components;
11-
12-
public partial class LayersManagerInspector
13-
{
14-
private class CollInfosFolders
15-
{
16-
public bool collision = true;
17-
public bool unityLayer = true;
18-
public bool physicsLayer = true;
19-
}
20-
21-
private bool layersFolder = true;
22-
private bool collInfosFolder = true;
23-
private List<CollInfosFolders> collInfosFolders = new List<CollInfosFolders>();
24-
}
25-
}
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using UnityEngine;
5+
using UnityEditor;
6+
7+
namespace a3geek.PhysicsLayers.Editors
8+
{
9+
using Common;
10+
using Components;
11+
12+
public partial class LayersManagerInspector
13+
{
14+
private class CollInfosFolders
15+
{
16+
public bool collision = true;
17+
public bool unityLayer = true;
18+
public bool physicsLayer = true;
19+
}
20+
21+
private bool layersFolder = true;
22+
private bool collInfosFolder = true;
23+
private List<CollInfosFolders> collInfosFolders = new List<CollInfosFolders>();
24+
}
25+
}

0 commit comments

Comments
 (0)