Ошибка в 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
AssetsRoomSpawner.cs(35,58): error CS1061: ‘GameObject[]’ does not contain a definition for ‘Lenght’ and no accessible extension method ‘Lenght’ accepting a first argument of type ‘GameObject[]’ could be found (are you missing a using directive or an assembly reference?)это ошибка полностью
помогите пожалуйста разобраться.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RoomSpawner : MonoBehaviour
{
public Direction direction;
public enum Direction
{
Top,
Bottom,
Left,
Right,
None
}
private RoomVariants variants;
private int rand;
private bool spawned = false;
private float waitTime = 3f;
private void Start()
{
variants = GameObject.FindGameObjectWithTag(«Rooms»).GetComponent<RoomVariants>();
Destroy(gameObject, waitTime);
Invoke(«Spawn», 0.2f);
}
public void Spawn()
{
if (!spawned)
{
if(direction == Direction.Top)
{
rand = Random.Range(0, variants.topRooms.Lenght);
Instantiate(variants.topRooms[rand], transform.position, variants.topRooms[rand].transform.rotation);
}
else if(direction == Direction.Bottom)
{
rand = Random.Range(0, variants.bottomRooms.Lenght);
Instantiate(variants.bottomRooms[rand], transform.position, variants.bottomRooms[rand].transform.rotation);
}
else if(direction == Direction.Right)
{
rand = Random.Range(0, variants.rightRooms.Lenght);
Instantiate(variants.rightRooms[rand], transform.position, variants.rightRooms[rand].transform.rotation);
}
else if(direction == Direction.Left)
{
rand = Random.Range(0, variants.leftRooms.Lenght);
Instantiate(variants.leftRooms[rand], transform.position, variants.leftRooms[rand].transform.rotation);
}
spawned = true;
}
}
private void OnTriggerStay2D(Collider2D other)
{
if(other.CompareTag(«RoomPoint») && other.GetComponent<RoomSpawner>().spawned)
{
Destroy(gameObject);
}
}
}
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?)
Cs1061 IS SELECTED ERROR. Nothing is fixing it. #308
Comments
Assets2d-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?)
This is the error code that I keep receiving. I am doing a Stacks tutorial on unity. One of the steps is to download the 2d extras file. I have tried the master version and the 2020.3.15 version. Every time I try to import it into unity I get the same error code. I have even have tried renaming the file to «com.unity.2d.tilemap.extras» which was stated in a tutorial video on youtube. I also have tried dragging into Packages and Assets. I dont know what to do.
The text was updated successfully, but these errors were encountered:
I have Unity Version 2020.3.2
You can add it in using the Unity Package Manager by entering «https://github.com/Unity-Technologies/2d-extras.git#2020.3» when adding a package by name.
[Package Manager Window] Unable to add package [https://github.com/Unity-Technologies/2d-extras.git#2020.3]:
No ‘git’ executable was found. Please install Git on your system then restart Unity and Unity Hub
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
[Package Manager Window] Cannot perform upm operation: Unable to add package [https://github.com/Unity-Technologies/2d-extras.git#2020.3]:
No ‘git’ executable was found. Please install Git on your system then restart Unity and Unity Hub [NotFound].
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
[Package Manager Window] Error adding package: https://github.com/Unity-Technologies/2d-extras.git#2020.3.
UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
I went to package manager and added from Git Url and it responded with this. I downloaded the 2020.3 zip file from your link and Extracted it as well on the desktop so that the files would be able to be accessed without being stuck behind the zip wall. I tried dragging the file into packages and assets again but same result. On the video it give him the option to clone or something but for it just says code in the green box before I download the Zip.
You would need to install Git (https://git-scm.com/) to use the method I recommended above unfortunately.
As you do not have Git installed, but have downloaded the 2020.3 zip file, could you try the following instead:
- Extract the 2020.3 zip file contents to a folder
- In the Unity Package Manager window, click on + and select Add package from disk
- Browse to the folder where you extracted the 2020.3 zip file
- Select the package.json file and open it
This will install the package from the zip file.
Also, ensure you do not have any duplicates in your Project, eg. you do not need a copy in Assets2d-extras-master if you have installed the package this way.
Let us know if that works!
I had the same problem checking it out and switching branches seems to have cleared the issue.
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?)
I think the problem may be that the GitHub interface is downloading the master version despite you switching to the 2020.3 branch. When you extract the zip file, could you check what version of the package is listed in the package.json file and share it here?
Would it be possible for you to try to download and extract the package from the following link?
https://github.com/Unity-Technologies/2d-extras/archive/refs/tags/1.8.1-preview.zip
You can follow the steps again to install the package:
- Extract the 2020.3 zip file contents to a folder
- In the Unity Package Manager window, click on + and select Add package from disk
- Browse to the folder where you extracted the 2020.3 zip file
- Select the package.json file and open it
Hopefully this works this time!
I just checked and you’re right! It says master on the .json file. I swear I keep switching it to my version the 2020.3, there has to be some sort of override happening. Alright, so I followed your steps. It installed successfully I think. No code errors at the bottom, but. It has in big yellow letters at the top «preview packages in use». I did a little research into that and it says that they are unstable or beta versions and shouldn’t be used to production and only be used for testing? I did however find the animated tile option, which is new an added, I just had to search for it in a different spot of the menu.
My question is, is there an error right now with the website? Is every link downloading the master file? Also is the temporary?
It seems to be the behaviour across all GitHub repositories (or at least based on the one non-Unity repository I checked). I believe it was not like this before, and you could download a zip of the branch you were in. If it applies across all GitHub repositories, it may not be temporary unfortunately.
Doesnt that ultimately make the entire asset package unusable ? Like how do I get it to work with master if we are stuck with this.
The master branch is targeted for the current latest version of the Unity Editor, which is 2021.1. For previous versions, you should use the branch specifically targeting that version of the Unity Editor, eg. 2019.4 for 2019.4 version of the Unity Editor. The reason for this is that the public APIs can change for each version of the Unity Editor and are not compatible with prior versions, as they may not be backported.
On a side note, GitHub fixed the Download Zip option for different branches, so if you select the 2019.4 branch and download the zip for that, you will get a zip of the 2019.4 branch.
Hope that helps, and do let us know if you need more details and clarifications!
Источник
-
#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
Baltick 0 / 0 / 0 Регистрация: 14.08.2021 Сообщений: 1 |
||||
1 |
||||
14.08.2021, 21:12. Показов 1905. Ответов 2 Метки unity, unity3d (Все метки)
AssetsPlayerMovement.cs(20,16): error CS1061: ‘GameManager’ does not contain a definition for ‘EndGame’ and no accessible extension method ‘EndGame’ accepting a first argument of type ‘GameManager’ could be found (are you missing a using directive or an assembly reference?) AssetsPlayerMovement.cs(49,16): error CS1061: ‘GameManager’ does not contain a definition for ‘EndGame’ and no accessible extension method ‘EndGame’ accepting a first argument of type ‘GameManager’ could be found (are you missing a using directive or an assembly reference?) Вот мой код
__________________
0 |
529 / 341 / 196 Регистрация: 18.10.2019 Сообщений: 1,152 |
|
14.08.2021, 21:40 |
2 |
Baltick, тебе ошибка прямо говорит, что в классе GameManager нет метода EndGame. Значит либо его там и правда вовсе нет, либо ты его по другому назвал, а пытаешься вызвать по несуществующему названию.
0 |
1 / 1 / 0 Регистрация: 25.03.2021 Сообщений: 15 |
|
14.08.2021, 22:07 |
3 |
Чет очень знакомый код, это с какого-то урока?
0 |
IT_Exp Эксперт 87844 / 49110 / 22898 Регистрация: 17.06.2006 Сообщений: 92,604 |
14.08.2021, 22:07 |
3 |