JS to CS conversion problem with multiple class files
So I'm converting a few javascript files into c# files for basic continuity purposes. These JS files came from an outside source, but work in their current state. One particularly big file contains several class objects and a whole bunch of functions. In my CS file I have translated all of the functions and variables easily enough, but I'm stumped on how to deal with the classes. I know pre .NET 4 c# doesn't handle multiple inheritance, and I'm assuming I can't just put multiple classes within a c# class.
These classes contain most of the needed variable declarations and methods needed for the rest of the functions to work, so how would I go about separating them out in a workable way?
Answer by pekalicious · Dec 03, 2015 at 02:49 AM
These classes have nothing to do with multiple inheritance or inheritance in general. They are just classes within the outer class for convenience. You can safely convert them as you see them in the file:
public class CharacterMotor : MonoBehaviour
{
CharacterMotorMovement movement;
class CharacterMotorMovement
{
}
enum MovementTransferOnJump
{
}
}
Note that if you make the 'movement' variable public, you'll also need to make 'CharacterMotorMovement' class public.
And because these classes are public within another class, you need to use both class names if you want to use it in another script.
For example, if I have another script and I want to use CharacterMotorMovement, i will need to define it like so:
CharacterMotor.CharacterMotorMovement movement = ...;
Another thing you can do is move these classes outside of the outer class but in the same file. This however exposes those classes, which might not be what you want.
Your answer
Follow this Question
Related Questions
Running C# Function from JS file 0 Answers
How do I access a variable/class from a C# file in a JS file? 1 Answer
GUI.Window from child class not reacting 1 Answer
Model TextureBlurring Effect (Optimization) 0 Answers
il2cpp type casting issue -1 Answers