@Composable
fun CategoryScreen(categories: List<Category>) {
val selectedCategory = remember { mutableStateOf(categories[0]) }
val subcategories = selectedCategory.value.subcategories
Column(Modifier.fillMaxSize()) {
// Категории
TabRow(selectedTabIndex = categories.indexOf(selectedCategory.value)) {
categories.forEachIndexed { index, category ->
Tab(
text = { Text(category.name) },
selected = selectedCategory.value == category,
onClick = { selectedCategory.value = category }
)
}
}
// Подкатегории
LazyColumn(Modifier.weight(1f)) {
items(subcategories.size) { index ->
val subcategory = subcategories[index]
Button(
modifier = Modifier.fillMaxWidth().padding(16.dp),
onClick = { /* Обработка выбора подкатегории */ }
) {
Text(subcategory.name)
}
}
}
// Предметы
LazyColumn(Modifier.weight(1f)) {
val items = subcategories.flatMap { it.items }
items(items.size) { index ->
val item = items[index]
Button(
modifier = Modifier.fillMaxWidth().padding(16.dp),
onClick = { /* Обработка выбора предмета */ }
) {
Text(item.name)
}
}
}
// Описание предмета
Box(Modifier.weight(1f)) {
Text("Здесь будет описание")
}
}
}
.UseStartup<Startup>().UseUrls("http://192.168.88.6:6666", "https://192.168.88.6:6669");
var speed = rigidbody.velocity.magnitude;
speed *= 3.6f;
var speed = rigidbody.velocity.magnitude*3.6f;
[SerializeField]private GameObject player;
[SerializeField] private float speed=2f;
private Camera camera => Camera.main;
private bool isMove;
private Vector3 targetPosition;
private void Update()
{
if (Input.GetMouseButton(0))
{
targetPosition = camera.ScreenToWorldPoint(Input.mousePosition);
targetPosition.z = 0;
isMove = true;
}
if (isMove)
{
player.transform.position =
Vector3.Lerp(player.transform.position, targetPosition, Time.deltaTime * speed);
if ((targetPosition-player.transform.position).sqrMagnitude < 0.1f)
{
isMove = false;
}
}
}
private GameObject player;
private float oldSqrMagnitude;
private Camera camera => Camera.main;
private void Update()
{
var newSqrMagnitude = (player.transform.position - camera.ScreenToWorldPoint(Input.mousePosition)).sqrMagnitude;
if (newSqrMagnitude > oldSqrMagnitude)
{
Debug.Log("дальше");
}
else if (newSqrMagnitude < oldSqrMagnitude)
{
Debug.Log("ближе");
}
else
{
Debug.Log("стоит");
}
oldSqrMagnitude = newSqrMagnitude;
}