array is pointer and float variable is not - why not? C#

I’m wandering why it guesses array is pointer and it automatically sets all KeyCodes in another script with load

while I must make public floats for mouse X Y Z
like I’m trying with asdf example and I sucseed I can load all KeyCodes only with this in other script

saveLoad.LoadControllsF(keyControllKeyCode, mouseSensitivityXf, mouseSensitivityYf, mouseSensitivityZf, MouseSmoothingb);

mouseSensitivityYf = saveLoad.asdf;

and float needs to be adressed manually

main problem is LoadControllsF

	public void SaveControllsF(KeyCode[] key, float MouseX, float MouseY, float MouseZ, bool MouseSmoothb){
		string[] FilePaths = Directory.GetFiles(Application.dataPath + "/Save/User/Controlls/", "*.sav", SearchOption.AllDirectories);
		// If file exists we create backeup
		if (FilePaths.Length != 0){
			File.Copy(FilePaths[0],(FilePaths[0] + ".back"), true);
		}
		asdf = 50.5f;
		using(var writer = new BinaryWriter(File.OpenWrite(Application.dataPath + "/Save/User/Controlls/Controlls.sav"))){
			for (int i=0; i < 3; i++) {
				writer.Write((int)key*);*
  •  	}*
    
  •  	writer.Write((decimal)MouseX);*
    
  •  	writer.Write((decimal)asdf);*
    
  •  	writer.Write((decimal)MouseZ);*
    
  •  	//writer.Write(MouseSmoothb);*
    
  •  	writer.Close();*
    
  •  }*
    
  • }*
    ___

  • public void LoadControllsF(KeyCode key, float MouseX, float MouseY, float MouseZ, bool MouseSmoothb){*
    _ string FilePaths = Directory.GetFiles(Application.dataPath + “/Save/User/Controlls/”, “*.sav”, SearchOption.AllDirectories);_

  •  if (FilePaths.Length == 0){*
    
  •  	LoadDefaultControllsF(key, MouseX, MouseY, MouseZ, MouseSmoothb);*
    
  •  }*
    
  •  else {*
    
  •  	using(var reader = new BinaryReader(File.OpenRead(FilePaths[0]))){*
    
  •  		for (int i=0; i < 3; i++) {*
    

_ key = (KeyCode)reader.ReadInt32();_
* }*
* MouseX = (float)reader.ReadDecimal();*
* asdf = (float)reader.ReadDecimal();*
* MouseZ = (float)reader.ReadDecimal();*
* reader.Close();*
* }*
* }*
* }*
# Full Struct code
using UnityEngine;
using System.Collections;
using System.IO;

public struct SaveLoadS {
* public float asdf;*

_ /****** START DEFAULTS /_
_
public void SaveDefaultControllsF(KeyCode[] key, float MouseX, float MouseY, float MouseZ, bool MouseSmoothb){
_
_
using(var writer = new BinaryWriter(File.OpenWrite(Application.dataPath + “/Save/Default/Controlls.sav”))){
_
_
for (int i=0; i < key.Length; i++) {
_
_ writer.Write((int)key*);
}
writer.Close();
}
} // Development puropses ONLY*
* public void LoadDefaultControllsF(KeyCode key, float MouseX, float MouseY, float MouseZ, bool MouseSmoothb){
using(var reader = new BinaryReader(File.OpenRead(Application.dataPath + “/Save/Default/Controlls.sav”))){
for (int i=0; i < key.Length; i++) {
key = (KeyCode)reader.ReadInt32();
}
reader.Close();
}
}
/***** END DEFAULTS */
public void SaveControllsF(KeyCode[] key, float MouseX, float MouseY, float MouseZ, bool MouseSmoothb){
string[] FilePaths = Directory.GetFiles(Application.dataPath + “/Save/User/Controlls/”, ".sav", SearchOption.AllDirectories);

// If file exists we create backeup

if (FilePaths.Length != 0){
File.Copy(FilePaths[0],(FilePaths[0] + “.back”), true);
}
asdf = 50.5f;
using(var writer = new BinaryWriter(File.OpenWrite(Application.dataPath + “/Save/User/Controlls/Controlls.sav”))){
for (int i=0; i < 3; i++) {
writer.Write((int)key);
}*_

* writer.Write((decimal)MouseX);*
* writer.Write((decimal)asdf);*
* writer.Write((decimal)MouseZ);*
* //writer.Write(MouseSmoothb);*
* writer.Close();*
* }*
* }*
* public void LoadControllsF(KeyCode[] key, float MouseX, float MouseY, float MouseZ, bool MouseSmoothb){*
_ string FilePaths = Directory.GetFiles(Application.dataPath + “/Save/User/Controlls/”, ".sav", SearchOption.AllDirectories);
if (FilePaths.Length == 0){
LoadDefaultControllsF(key, MouseX, MouseY, MouseZ, MouseSmoothb);
}
else {
using(var reader = new BinaryReader(File.OpenRead(FilePaths[0]))){
for (int i=0; i < 3; i++) {
key = (KeyCode)reader.ReadInt32();
}
MouseX = (float)reader.ReadDecimal();
asdf = (float)reader.ReadDecimal();
MouseZ = (float)reader.ReadDecimal();
reader.Close();
}
}
}
}*_

and maybe as partionally solution how do I make a pointer?

C# determines whether parameters are passed by value or passed by reference based on the type of that parameter. Roughly speaking all structs and simple types are passed by value and all classes and arrays are passed by reference. This is just the way things work in C#. Follow these links for more info on value types and reference types.

Although its possible to use pointers in C#, doing so requires that you specify the unsafe keyword which Unity doesn’t support. It is however possible to specify the ‘ref’ keyword when declaring a function parameter in order to pass a value type parameter as a reference. This is effectively like having a pointer function parameter. Follow this link for more information on passing by value and reference.