// Start is called before the first frame update void Start() { mouseDetection = GetComponent <MouseDetection>(); m_rigidBody = GetComponent <Rigidbody2D>(); m_Stop = false; Vector2 startingDir = Vector2.zero; switch (mouseDetection.startingDir) { case Detection.DIRECTIONS.UP: startingDir = new Vector2(0, 1); break; case Detection.DIRECTIONS.DOWN: startingDir = new Vector2(0, -1); break; case Detection.DIRECTIONS.LEFT: startingDir = new Vector2(-1, 0); break; case Detection.DIRECTIONS.RIGHT: startingDir = new Vector2(1, 0); break; } UpdateAnimation(false, startingDir); }
void Start() { mouseDetection = this.GetComponentInParent <MouseDetection>(); spriteRenderer = this.GetComponent <SpriteRenderer>(); spriteRenderer.enabled = false; SubscribeToMouseEvents(); }
void DisplayInventoryItem(int index, MouseDetection mouseDetection = MouseDetection.DetectHover | MouseDetection.DetectDrag) { Color backgroundColor = GUI.backgroundColor; ItemColor(index); GUIStyle style = new GUIStyle(EditorStyles.helpBox); RectOffset rect = new RectOffset(0, 0, 10, 10); style.padding = rect; Rect itemRect = EditorGUILayout.BeginHorizontal(style); InventoryItemData inventoryItem = null; if (index > -1) { inventoryItem = inventoryData.items[index]; } Texture image = new Texture2D(0, 0); string name = "None"; if (inventoryItem != null) { image = AssetPreview.GetAssetPreview(inventoryItem.prefab.gameObject); name = inventoryItem.prefab.name; } if ((mouseDetection & MouseDetection.DetectDrag) == MouseDetection.DetectDrag) { DetectMouseDrag(itemRect, draggedObj => { inventoryData.items[index] = new InventoryItemData(((GameObject)draggedObj).GetComponent <InventoryItem>()); }); } if ((mouseDetection & MouseDetection.DetectHover) == MouseDetection.DetectHover) { DetectMouseHover(itemRect, index); } GUIStyle imageStyle = new GUIStyle(EditorStyles.helpBox) { fixedHeight = 70, }; float labelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 20f; EditorGUILayout.LabelField(index.ToString() + "."); EditorGUIUtility.labelWidth = labelWidth; GUIContent itemLabel = new GUIContent(name, image); EditorGUILayout.LabelField(itemLabel, imageStyle); EditorGUILayout.EndHorizontal(); GUI.backgroundColor = backgroundColor; }