private void Awake() { allPathern = new List <Grid.Pathern>(); allNodeType = new List <Grid.NodeType>(); var files = Directory.GetFiles(Application.dataPath + "/Pathern", "*.asset"); for (int i = 0; i < files.Length; ++i) { string fileName = files[i].Substring(files[i].LastIndexOf('/') + 1).Replace('\\', '/'); Grid.Pathern pathern = AssetDatabase.LoadAssetAtPath <Grid.Pathern>("Assets/" + fileName); allPathern.Add(pathern); } files = Directory.GetFiles(Application.dataPath + "/GridNodeType", "*.asset", SearchOption.TopDirectoryOnly); for (int i = 0; i < files.Length; ++i) { string fileName = files[i].Substring(files[i].LastIndexOf('/') + 1).Replace('\\', '/'); Grid.NodeType gridType = AssetDatabase.LoadAssetAtPath <Grid.NodeType>("Assets/" + fileName); allNodeType.Add(gridType); } }
public ViewGridPathern(Grid.Pathern pathern) { currentPathern = new SerializedObject(pathern); nodesArray = currentPathern.FindProperty("nodes"); Vector3Int propertyPosition; for (int i = 0; i < nodesArray.arraySize; ++i) { propertyPosition = nodesArray.GetArrayElementAtIndex(i).FindPropertyRelative("position").vector3IntValue; ++propertyPosition.x; ++propertyPosition.z; if (propertyPosition.x > size.x) { size.x = propertyPosition.x; } if (propertyPosition.z > size.y) { size.y = propertyPosition.z; } } if (size.x < 1) { size.x = 1; } if (size.y < 1) { size.y = 1; } grid = new Grid.NodeType[size.x, size.y]; skinGrid = new GUIStyle(GUI.skin.button) { fixedWidth = 50f, fixedHeight = 50f }; }