Error cs1061 unity

Здраствуйте!имеется скрипт для пули:

Ошибка в 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?) такая ошибка выходит, помогите заранее спасибо

C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
public class Basket : MonoBehaviour
{
    [Header("Set Dynamically")]
    public Text   scoreGT;
 
    
    void Start()
    {
        GameObject scoreGO = GameObject.Find("ScoreCounter");
        scoreGT = scoreGO.GetComponent<Text>();
        scoreGT.text = 0;
        
    }
 
    
    void Update()
    {
        Vector3 mousePos2D = Input.mousePosition;
        mousePos2D.z = -Camera.main.transform.position.z;
        Vector3 mousePos3D = Camera.main.ScreenToWorldPoint( mousePos2D);
        Vector3 pos = this.transform.position;
        pos.x = mousePos3D.x;
        this.transform.position = pos;
    }
    void OnCollisionEnter( Collision coll ) {
        GameObject collidedWith = coll.gameObject;
        if ( collidedWith.tag == "Apple" ) {
            Destroy( collidedWith );
 
            int score = int.Parse( scoreGT.text );
            score += 100;
            scoreGT.text = score.ToString();
 
        }
    }
}

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



93 / 59 / 35

Регистрация: 07.08.2013

Сообщений: 241

29.03.2022, 00:40

2

а если эти строки убрать

Цитата
Сообщение от SkripSan
Посмотреть сообщение

GameObject scoreGO = GameObject.Find(«ScoreCounter»);
scoreGT = scoreGO.GetComponent<Text>();

и поместить текс руками в поле

Цитата
Сообщение от SkripSan
Посмотреть сообщение

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. Но твой код говорит об обратном, ты пишешь всё правильно.
Тогда может стоит в 16-ой строке присваивать тексту значение типа string? («0» вместо 0)



0



Алексанierecumi

93 / 59 / 35

Регистрация: 07.08.2013

Сообщений: 241

30.03.2022, 23:13

7

BattleCrow, SkripSan,ковычки.

C#
1
scoreGT.text = "0";



0



0 / 0 / 0

Регистрация: 15.02.2022

Сообщений: 12

31.03.2022, 00:07

 [ТС]

8

Кавычки не помогли (((

Добавлено через 1 минуту
Алексанierecumi не помогло(((



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,

C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using UnityEngine;
using UnityEngine.UI;
 
public class Basket : MonoBehaviour
{
    private Text scoreGT; 
    
    private void Start()
    {
        scoreGT = GameObject.Find("ScoreCounter").GetComponent<Text>();
        scoreGT.text = "0";       
    }
    
    private void Update()
    {
        Vector3 mousePos2D = Input.mousePosition;
        mousePos2D.z = -Camera.main.transform.position.z;
        Vector3 mousePos3D = Camera.main.ScreenToWorldPoint(mousePos2D);
        Vector3 pos = this.transform.position;
        pos.x = mousePos3D.x;
        this.transform.position = pos;
    }
 
    private void OnCollisionEnter(Collision coll) 
    {
        if (coll.gameObject.CompareTag("Apple")) 
        {
            Destroy(coll.gameObject);
            scoreGT.text = ((int)scoreGT.text + 100).ToString(); 
        }
    }
}

Чуток укоротил код, исправил некоторые косяки с пробелами и табуляцией. От этого код не особо изменился, но возможно какую-то ошибку я этим и исправил



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,

Миниатюры

Error CS1061: 'Text' does not contain a definition for 'Text' and no accessible extension method 'Text'
 



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

Я исправил эту ошибку так:
1)Скорее всего когда ты добавлял Text в сцену,ты добавил Text — TextMeshPro
2)Тебе нужно перейти в объект Text (TMP)(он появляется сразу после создания Text — TextMeshPro)
и тебе нужно удалить в нём компонент «TextMeshPro — Text…», а вместо него добавить компонент «Text»
(Add Component => Text) и всё должно заработать(Ну по крайней мере у меня была в этом проблема)

Удачи!



0



67 / 50 / 18

Регистрация: 28.05.2022

Сообщений: 484

08.12.2022, 15:10

17

Цитата
Сообщение от Raerdre44
Посмотреть сообщение

2)Тебе нужно перейти в объект Text (TMP)(он появляется сразу после создания Text — TextMeshPro)
и тебе нужно удалить в нём компонент «TextMeshPro — Text…», а вместо него добавить компонент «Text»
(Add Component => Text) и всё должно заработать(Ну по крайней мере у меня была в этом проблема)

можно просто использовать библиотеку: 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
Я с помощью MFC wizard создаю однодокументный проект с поддержкой базы данных с файлом(MDB), после…

GameObject’ does not contain a definition for ‘transfrom’ and no accessible extension method ‘transfrom’ (часть кода
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class…

Как задать диапазон Shapes. Range(Array(«Text box 1», «Text box 2», «Text box 3», «Text box 4».»Text box 10″).Select
Здравствуйте, все. Подскажите, пожалуйста, возможно ли в макросе VBA MS Word заменить область…

ActiveX Control: Form1.Show bvModal if(Form1.Text1.Text <> ») then UserControl.Text2.Text = Form1.Text1.Text
Имеется проект ActiveX Control, в нем: Form1(имеет Text1, Button1), UserControl1 (имеет Text2,…

Сохранение текста (label.text или textBox.text) для повторного использования
В общем когда пользователь входит необходимо чтоб он авторизовался, а для того чтоб этого не делать…

Как исправить ошибку too many actual parameters-делфи. Строка Edit6.Text, Edit7.Text)
procedure TForm1.Button1Click(Sender: TObject);
begin
if RadioButton1.Checked then

Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:

17

Понравилась статья? Поделить с друзьями:
  • Error cs1031 требуется тип
  • Error cs1026 юнити
  • Error cs1026 unexpected symbol expecting
  • Error cs1026 expected unity
  • Error cs1024 требуется директива препроцессора