This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // fragment = nested sub-activity w/ its own layout and lifecycle. (modular section of an activity) | |
| // fragment receives the same lifecycle callbacks as its parent activity does | |
| public class ArticleFragment extends Fragment { | |
| @Override | |
| public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
| return inflater.inflate(R.layout.article_view, container, false); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- Declaring the main "launcher" activity --> | |
| <activity android:name=".MainActivity" android:label="@string/app_name"> | |
| <intent-filter> | |
| <action android:name="android.intent.action.MAIN" /> | |
| <category android:name="android.intent.category.LAUNCHER" /> | |
| </intent-filter> | |
| </activity> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protected void onCreate(...) { | |
| super.onCreate(savedInstanceState); | |
| TextView tv = new TextView(this); | |
| tv.setTextSize(40); | |
| tv.setText("blah"); | |
| setContentView(tv); // adds tv as the root view of the activity's layout | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // constant movement | |
| void Update() { | |
| transform.position = Vector3.Lerp(pos1.position, pos2.position, speed * timer); | |
| if (destination == pos1) { | |
| timer = Mathf.Clamp(timer = Time.deltaTime, 0.0f, 1.0f/speed); | |
| } else { | |
| timer = Mathf.Clamp(timer + Time.deltaTime, 0.0f, 1.0f/speed); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections; | |
| [ExecuteInEditMode] | |
| public class SnapToGrid : MonoBehaviour { | |
| public float cell_size = 1f; // = larghezza/altezza delle celle | |
| private float x, y, z; | |
| void Start() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections; | |
| public class Gizmo : MonoBehaviour { | |
| public bool ShowMainCameraBorder; | |
| void OnDrawGizmos() { | |
| if (ShowMainCameraBorder) { | |
| float z = GetComponent<Camera>().nearClipPlane; | |
| Vector3 max = GetComponent<Camera>().ViewportToWorldPoint(new Vector3(1, 1, z)); |
NewerOlder