Ошибка в unity: error CS1061
Здраствуйте!
имеется скрипт для пули:
Используется csharp
using UnityEngine;
using System.Collections;
public class Vistrel : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider col)//Заметь, что в col хранится информация о коллайдере, который вошел в триггер, через него мы можем получить ссылку на объект
{
if(col.gameObjext.tag==«Enemy»)//делаем проверку на тэг, чтобы случайно не отправить сообщение о дамаге стене.
{
col.gameObject.SendMessage(«TakeDamage»,50);
}
}
}
В консоле видаёт ошибку на этот скрипт:
Assets/scripts/Vistrel.cs(16,16): error CS1061: Type `UnityEngine.Collider’ does not contain a definition for `gameObjext’ and no extension method `gameObjext’ of type `UnityEngine.Collider’ could be found (are you missing a using directive or an assembly reference?)
Кто знает что делать и как исправить?
-
Dragon-FAST - UNIт
- Сообщения: 92
- Зарегистрирован: 15 авг 2016, 08:29
Re: Ошибка в unity: error CS1061
waruiyume 19 авг 2016, 04:04
gameObjext
-
waruiyume - Адепт
- Сообщения: 6059
- Зарегистрирован: 30 окт 2010, 05:03
- Откуда: Ростов на Дону
Re: Ошибка в unity: error CS1061
Dragon-FAST 19 авг 2016, 06:03
waruiyume писал(а):gameObjext
Спасибо видать просто допустил опечатку…
-
Dragon-FAST - UNIт
- Сообщения: 92
- Зарегистрирован: 15 авг 2016, 08:29
Вернуться в Скрипты
Кто сейчас на конференции
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 9
I’m running into the quite simple aforementioned error. I thought I’d fix it quite quickly, but even after quite some searching, I can’t for the life of me figure out what the problem is. I Have the following Interface:
public interface ITemperatureEmitter
{
float CurrentTemperatureAddon { get; }
}
I implement this in two other (empty for now) Interfaces:
public interface ITemperatureEmitterEnvironment : ITemperatureEmitter
public interface ITemperatureEmitterSphere : ITemperatureEmitter
Subsequently I use these three interfaces in the following class:
using System.Collections.Generic;
using UnityEngine;
public class TemperatureReceiver : MonoBehaviour, ITemperatureReceiver
{
public float PerceivedTemperature;
// Serialized for debug purposes
[SerializeField] private List<ITemperatureEmitterSphere> temperatureEmitterSpheres;
[SerializeField] private List<ITemperatureEmitterEnvironment> temperatureEmitterEnvironments;
[SerializeField] private float environmentTemperature;
[SerializeField] private float temperatureToModifyBy;
[SerializeField] private float currentTemperatureAddon;
[SerializeField] private float appliedTemperatureAddon;
[SerializeField] private float totalTemperatureAddon;
private void Update()
{
UpdatePerceivedTemperature();
}
private void OnTriggerEnter(Collider other)
{
if (other.GetComponent<ITemperatureEmitterSphere>() != null)
{
temperatureEmitterSpheres.Add(other.GetComponent<ITemperatureEmitterSphere>());
}
else if (other.GetComponent<ITemperatureEmitterEnvironment>() != null)
{
temperatureEmitterEnvironments.Add(other.GetComponent<ITemperatureEmitterEnvironment>());
}
}
private void OnTriggerExit(Collider other)
{
if (other.GetComponent<ITemperatureEmitterSphere>() != null)
{
temperatureEmitterSpheres.Remove(other.GetComponent<ITemperatureEmitterSphere>());
}
else if (other.GetComponent<ITemperatureEmitterEnvironment>() != null)
{
temperatureEmitterEnvironments.Remove(other.GetComponent<ITemperatureEmitterEnvironment>());
}
}
private void UpdatePerceivedTemperature()
{
ModifyPerceivedTemperature(temperatureEmitterSpheres);
ModifyPerceivedTemperature(temperatureEmitterEnvironments);
}
private void ModifyPerceivedTemperature<ITemperatureEmitter>(List<ITemperatureEmitter> list)
{
if (list.Count > 0)
{
foreach (var item in list)
{
currentTemperatureAddon += item.CurrentTemperatureAddon;
}
currentTemperatureAddon = currentTemperatureAddon / list.Count;
appliedTemperatureAddon = PerceivedTemperature;
temperatureToModifyBy = currentTemperatureAddon = appliedTemperatureAddon;
PerceivedTemperature += temperatureToModifyBy;
}
}
}
Now the item.CurrentTemperatureAddon
in the ModifyPercievedTemperature
method emits «error CS1061: Type ITemperatureEmitter
does not contain a definition for CurrentTemperatureAddon
and no extension method CurrentTemperatureAddon
of type ITemperatureEmitter
could be found. Are you missing an assembly reference?«
ITemperatureEmitter
quite literally does contain a definition for CurrentTemperatureAddonm
… Anyone has an idea what’s happening here?
I cannot explain why this is not working. So, I downloaded Git from the link. Is there an extra option after? After I downloaded and installed it I went to the package handler option. I then entered the link into the search by ULR option. I got the same Error saying Git was not Installed, but it is installed, so I do not know If I am missing a option. I went into the Package handler and installed the json file and it actually installed. It says that 2D Tilemap Extras has been installed. Now I keep getting a error though in the bottom. It is the
C:UserssabolDesktop123452d-extras-masterEditorTilesRuleTileRuleTileEditor.cs(347,82): error CS1061: ‘ReorderableList’ does not contain a definition for ‘IsSelected’ and no accessible extension method ‘IsSelected’ accepting a first argument of type ‘ReorderableList’ could be found (are you missing a using directive or an assembly reference?)
C:UserssabolDesktop123452d-extras-masterEditorTilesRuleTileRuleTileEditor.cs(341,22): error CS1061: ‘ReorderableList’ does not contain a definition for ‘IsSelected’ and no accessible extension method ‘IsSelected’ accepting a first argument of type ‘ReorderableList’ could be found (are you missing a using directive or an assembly reference?)
C:UserssabolDesktop123452d-extras-masterEditorTilesRuleTileRuleTileEditor.cs(327,26): error CS1061: ‘ReorderableList’ does not contain a definition for ‘IsSelected’ and no accessible extension method ‘IsSelected’ accepting a first argument of type ‘ReorderableList’ could be found (are you missing a using directive or an assembly reference?)
Search Issue Tracker
Fixed in 2019.1.X
Found in
2018.2.0a2
2018.3.0a1
2018.3.0b10
2019.1.0a1
How to reproduce:
1. Open the attached project (that contains ‘2D Common’ package)
2. Observe the Console window
Expected result: There are no Console errors caused by ‘2D Common’ package.
Actual result: There is a compile error message «CS1061: ‘SpriteRenderer’ does not contain a definition for ‘SetDeformableBuffer’ <…>» that prevents from entering Play mode.
Reproducible with — 2018.2.0a2, 2018.2.16f1, 2018.3.0a1, 2018.3.0b10, 2019.1.0a1, 2019.1.0a8
Not reproducible with — 2018.2.0a1, 2019.1.0a9
Error thrown:
Packagescom.unity.2d.commonRuntimeInternalBridgeInternalEngineBridge.cs(15,28): error CS1061: ‘SpriteRenderer’ does not contain a definition for ‘SetDeformableBuffer’ and no accessible extension method ‘SetDeformableBuffer’ accepting a first argument of type ‘SpriteRenderer’ could be found (are you missing a using directive or an assembly reference?)
Fixed in 2019.1.0a9
-
#2
Why exactly do you think that the Vector2
class does have a GetAxisRaw
method? I’ve never used Unity but, as far as I can tell, the error message is spot on and the only GetAxisRaw
method is a static
member of the Input
class. Example 5 here uses both the Vector2
class and the Input.GetAxisRaw
method. If I could find that information, which I did by simply searching the web for «unity getaxisraw», then you should have been able to as well.
-
#3
Hi guys, New to coding trying to create player movement and these errors are showing up in unity —
AssetsScriptMovement.cs(16,26): error CS1061: ‘Vector2’ does not contain a definition for ‘GetAxisRaw’ and no accessible extension method ‘GetAxisRaw’ accepting a first argument of type ‘Vector2’ could be found (are you missing a using directive or an assembly reference?)
AssetsScriptMovement.cs(17,26): error CS1061: ‘Vector2’ does not contain a definition for ‘GetAxisRaw’ and no accessible extension method ‘GetAxisRaw’ accepting a first argument of type ‘Vector2’ could be found (are you missing a using directive or an assembly reference?)
How can I fix this?using System.Collections; using System.Collections.Generic; using UnityEngine; public class Movement : MonoBehaviour { public float moveSpeed; private bool isMoving; private Vector2 input; private void Update () { if (!isMoving) { input.x = input.GetAxisRaw("Horizontal"); input.y = input.GetAxisRaw("Vertical"); if (input != Vector2.zero) { var targetPos = transform.position; targetPos.x += input.x; targetPos.y += input.y; StartCoroutine(Move(targetPos)); } } } IEnumerator Move(Vector3 targetPos) { isMoving = true; while ((targetPos - transform.position).sqrMagnitude > Mathf.Epsilon) { transform.position = Vector3.MoveTowards(transform.position, targetPos, moveSpeed * Time.deltaTime); yield return null; } transform.position = targetPos; } }
Change the input.GetAxisRaw to Input.GetAxisRaw
SkripSan 0 / 0 / 0 Регистрация: 15.02.2022 Сообщений: 12 |
||||
1 |
||||
29.03.2022, 00:10. Показов 1266. Ответов 16 Метки unity (Все метки)
error CS1061: ‘Text’ does not contain a definition for ‘Text’ and no accessible extension method ‘Text’ accepting a first argument of type ‘Text’ could be found (are you missing a using directive or an assembly reference?) такая ошибка выходит, помогите заранее спасибо
__________________
0 |
93 / 59 / 35 Регистрация: 07.08.2013 Сообщений: 241 |
|
29.03.2022, 00:40 |
2 |
а если эти строки убрать
GameObject scoreGO = GameObject.Find(«ScoreCounter»); и поместить текс руками в поле
public Text scoreGT; ошибка пропадает?
0 |
0 / 0 / 0 Регистрация: 15.02.2022 Сообщений: 12 |
|
29.03.2022, 17:46 [ТС] |
3 |
да пропадает но появляется две другие
0 |
529 / 341 / 196 Регистрация: 18.10.2019 Сообщений: 1,152 |
|
29.03.2022, 17:52 |
4 |
SkripSan, на какие строки указывают эти ошибки? И вообще, кроме текста самой ошибки, важно и то, что пишется рядом с ней в скобках в консоли (место вызова ошибки).
0 |
0 / 0 / 0 Регистрация: 15.02.2022 Сообщений: 12 |
|
29.03.2022, 20:43 [ТС] |
5 |
16 35 37
0 |
529 / 341 / 196 Регистрация: 18.10.2019 Сообщений: 1,152 |
|
30.03.2022, 15:54 |
6 |
SkripSan, вообще странно, но ошибка указывает будто бы бы обращаешься к тексту как: scoreGT.Text, и понятное дело, что параметра Text нет, а есть только text. Но твой код говорит об обратном, ты пишешь всё правильно.
0 |
Алексанierecumi 93 / 59 / 35 Регистрация: 07.08.2013 Сообщений: 241 |
||||
30.03.2022, 23:13 |
7 |
|||
BattleCrow, SkripSan,ковычки.
0 |
0 / 0 / 0 Регистрация: 15.02.2022 Сообщений: 12 |
|
31.03.2022, 00:07 [ТС] |
8 |
Кавычки не помогли ((( Добавлено через 1 минуту
0 |
529 / 341 / 196 Регистрация: 18.10.2019 Сообщений: 1,152 |
|
31.03.2022, 20:35 |
9 |
SkripSan, тот код, который ты представил рабочий. Он не вызывает ошибок. Ты уверен, что сохранил изменения внесённые в скрипт?
0 |
0 / 0 / 0 Регистрация: 15.02.2022 Сообщений: 12 |
|
31.03.2022, 20:55 [ТС] |
10 |
BattleCrow
0 |
BattleCrow 529 / 341 / 196 Регистрация: 18.10.2019 Сообщений: 1,152 |
||||
31.03.2022, 21:02 |
11 |
|||
SkripSan,
Чуток укоротил код, исправил некоторые косяки с пробелами и табуляцией. От этого код не особо изменился, но возможно какую-то ошибку я этим и исправил
0 |
0 / 0 / 0 Регистрация: 15.02.2022 Сообщений: 12 |
|
07.04.2022, 18:30 [ТС] |
12 |
Подскажите как скачать библеотеку ui?
0 |
93 / 59 / 35 Регистрация: 07.08.2013 Сообщений: 241 |
|
07.04.2022, 18:35 |
13 |
SkripSan, [[меню] Window => Package Manager => [меню] Packages:Unity Registry => [поле] 2D Sprite => Download => Install.
0 |
93 / 59 / 35 Регистрация: 07.08.2013 Сообщений: 241 |
|
07.04.2022, 18:36 |
14 |
SkripSan, Миниатюры
0 |
0 / 0 / 0 Регистрация: 15.02.2022 Сообщений: 12 |
|
07.04.2022, 18:39 [ТС] |
15 |
Алексанierecumi спасибо я посмотрел у меня скачано ui все равно не помогло а как в visual Studio скачивать?
0 |
0 / 0 / 0 Регистрация: 22.09.2022 Сообщений: 13 |
|
08.12.2022, 15:01 |
16 |
Я исправил эту ошибку так: Удачи!
0 |
67 / 50 / 18 Регистрация: 28.05.2022 Сообщений: 484 |
|
08.12.2022, 15:10 |
17 |
2)Тебе нужно перейти в объект Text (TMP)(он появляется сразу после создания Text — TextMeshPro) можно просто использовать библиотеку: using TMPro;
0 |
IT_Exp Эксперт 87844 / 49110 / 22898 Регистрация: 17.06.2006 Сообщений: 92,604 |
08.12.2022, 15:10 |
Помогаю со студенческими работами здесь Ошибка в MFC Wizard: ‘Error occurred while converting the wizard’s text to the code page of the existing text in the file GameObject’ does not contain a definition for ‘transfrom’ and no accessible extension method ‘transfrom’ (часть кода public class… Как задать диапазон Shapes. Range(Array(«Text box 1», «Text box 2», «Text box 3», «Text box 4».»Text box 10″).Select ActiveX Control: Form1.Show bvModal if(Form1.Text1.Text <> ») then UserControl.Text2.Text = Form1.Text1.Text Сохранение текста (label.text или textBox.text) для повторного использования Как исправить ошибку too many actual parameters-делфи. Строка Edit6.Text, Edit7.Text) Искать еще темы с ответами Или воспользуйтесь поиском по форуму: 17 |