Saving KeyCode in PlayerPrefs
Is there a way to turn a saved string in player prefs back into a keycode. (Or is there a better way of saving key preferences?) e.g.upKey = PlayerPrefs.GetString("upKey",...
View ArticleTextField text pushed to left on space
When I use GUILayout.TextField in my script, I find that in the standalone player, the field is not enlarged when I press space, and instead the text is shoved to the left outside the boundary of the...
View ArticleOverloading RPCs
I'm attempting to use overloading for RPC functions. The script compiles fine (javascript), but results in an error while running when I call the overloaded function.The fact that there isn't a...
View ArticleChange prefab before instantiation
Is it possible (or sensible) to change a "prefab" in a script before passing it to instantiate?For example, something like the following:// assigned in the editor var prefab : GameObject; function...
View Articlec# optional parameters
I have a function like the following:public static void Foo(Vector3 foo = Vector3.zero) { //... }Which gives me an error: "The expression being assigned to optional parameter 'foo' must be constant or...
View Articleget Collider[] as GameObject[]
I want to get the GameObjects in a sphere, as an array, rather than the colliders. I can do this manually (iterate through and use .gameObject), but is there a more concise way of converting the whole...
View ArticleDestroy mesh / material after attaching to renderer
If I create a mesh or material using Instantiate, then assign it to a GameObject, do I then need to call Destroy on the mesh reference I have left, or on the mesh attached to the gameObject, or both?...
View ArticleChange blend mode from outside shader?
I've been doing something which requires quite a lot of rendering transparent objects to texture. These objects are used directly in the scene with standard alpha blending ("Blend SrcAlpha...
View ArticleFinding sharedMesh users.
I have an editor script that replaces the meshes of selected objects (using Instantiate), before performing modifications. This works fine. However, later on (when saving the scene) I get a message...
View ArticleChange intensity of one light on specific objects
I have a somewhat open pseudo-2D world with caves (think minecraft, but constrained to 2D) lit largely by a directional light. For the outside, this is fine, but in the caves I want to use various...
View Article