(07-03-2019, 02:49 PM)josemendez Wrote: There should not be a file named "ObiTearableCloth (1)".
It should be "ObiTearableCloth". Again, look trough your project for copies of this file and remove them, since the name "ObiTearableCloth (1)" indicates you have created a copy of the file, instead of replacing the original one.
There should be only one file named ObiTearableCloth.cs, located at Obi/Scripts/Actors/ObiTearableCloth.cs
07-03-2019, 04:04 PM (This post was last modified: 07-03-2019, 04:05 PM by josemendez.)
(07-03-2019, 03:08 PM)Richard Wrote: I removed (1), but can't add script.
Have you made sure that:
- There are no compile errors.
- The name of the script and the class are exactly the same.
Also, removing the (1) from the file name (if that's what you did) is not enough. There should only be one file with that name in the entire project. This is all standard Unity know-how.
(07-03-2019, 04:04 PM)josemendez Wrote: Have you made sure that:
- There are no compile errors.
- The name of the script and the class are exactly the same.
Also, removing the (1) from the file name (if that's what you did) is not enough. There should only be one file with that name in the entire project. This is all standard Unity know-how.
There was a compile error.
New error happened.
NullReferenceException: Object reference not set to an instance of an object
ClothTornEvent.OnEnable () (at Assets/ClothTornEvent.cs:16)
NullReferenceException: Object reference not set to an instance of an object
ClothTornEvent.OnDisable () (at Assets/ClothTornEvent.cs:22)
11-03-2019, 08:41 AM (This post was last modified: 11-03-2019, 08:50 AM by josemendez.)
(11-03-2019, 03:16 AM)Richard Wrote: There was a compile error.
New error happened.
NullReferenceException: Object reference not set to an instance of an object
ClothTornEvent.OnEnable () (at Assets/ClothTornEvent.cs:16)
NullReferenceException: Object reference not set to an instance of an object
ClothTornEvent.OnDisable () (at Assets/ClothTornEvent.cs:22)
There's no ClothTornEvent class in Obi. That's a file you created, how am I supposed to know what's wrong with it? Assuming you copied the one I provided verbatim, this error refers to empty lines in the original script, so you must have modified it.
Make sure the cloth variable is not null (my script uses the RequireComponent attribute to make sure there's a cloth component in the object, so "cloth" can never be null).
11-03-2019, 10:20 AM (This post was last modified: 11-03-2019, 10:27 AM by Richard.)
(11-03-2019, 08:41 AM)josemendez Wrote: There's no ClothTornEvent class in Obi. That's a file you created, how am I supposed to know what's wrong with it? Assuming you copied the one I provided verbatim, this error refers to empty lines in the original script, so you must have modified it.
Make sure the cloth variable is not null (my script uses the RequireComponent attribute to make sure there's a cloth component in the object, so "cloth" can never be null).
Yes, I changed a bit, but error is same(line is different). Even the original code you did cause error, so I tried to find out what I have to do.
"cloth component" means obi cloth or obi tearable cloth?
(11-03-2019, 08:41 AM)josemendez Wrote: There's no ClothTornEvent class in Obi. That's a file you created, how am I supposed to know what's wrong with it? Assuming you copied the one I provided verbatim, this error refers to empty lines in the original script, so you must have modified it.
Make sure the cloth variable is not null (my script uses the RequireComponent attribute to make sure there's a cloth component in the object, so "cloth" can never be null).
I set the ClothTornEvent and Obi Tearable Cloth as the image
11-03-2019, 07:45 PM (This post was last modified: 11-03-2019, 07:46 PM by josemendez.)
(11-03-2019, 10:20 AM)Richard Wrote: "cloth component" means obi cloth or obi tearable cloth?
Hi,
It means ObiTearableCloth, as regular ObiCloth cannot be torn.
About the null ref issue:
- It is happening in two lines where the only thing that can be null is the "cloth" variable, of type ObiTearableCloth.
- If the RequireComponent attribute is being used (which it is in the original code), then cloth cannot be null, since Unity guarantees a ObiTearableCloth component is present.
So either you're removing the component programmatically in some other script (only way to trigger a null ref exception in this situation), or things aren't set up as you described.
It means ObiTearableCloth, as regular ObiCloth cannot be torn.
About the null ref issue:
- It is happening in two lines where the only thing that can be null is the "cloth" variable, of type ObiTearableCloth.
- If the RequireComponent attribute is being used (which it is in the original code), then cloth cannot be null, since Unity guarantees a ObiTearableCloth component is present.
So either you're removing the component programmatically in some other script (only way to trigger a null ref exception in this situation), or things aren't set up as you described.
I would like to deny about removing or setting. Can I send you the project(my setting)?