static void CreateText() { Object prefabObject = AssetDatabase.LoadAssetAtPath <Object>("Assets/CastleFramework/Primitives/CastleText.prefab"); CastleText castleText = ((GameObject)PrefabUtility.InstantiatePrefab(prefabObject)).GetComponent <CastleText>(); Selection.activeGameObject = castleText.gameObject; }
public static void Select(CastleObject _object, bool _override = false) { if (!selectedObject && !_object) { return; } if (_override) { if (selectedObject) { selectedObject.Release(); } selectedObject = _object; selectedObject.Tap(); return; } if (Input.GetMouseButtonDown(0)) { selectedObject = _object; selectedObject.Tap(); } else if (Input.GetMouseButton(0)) { if (selectedObject) { if (CheckObject(selectedObject.coll)) { selectedObject.Hold(); } else { selectedObject.DragOff(); } } } else if (Input.GetMouseButtonUp(0)) { if (selectedObject) { selectedObject.Release(); selectedObject = null; } } if (editingText) { if (Input.GetKeyDown(KeyCode.Return) || Input.GetMouseButtonDown(0)) { editingText = false; focusedText = null; } foreach (KeyCode vKey in System.Enum.GetValues(typeof(KeyCode))) { if (Input.GetKeyDown(vKey)) { if (vKey == KeyCode.Backspace || vKey == KeyCode.Delete) { Debug.Log("delete"); focusedText.text = CastleTools.StripBack(focusedText.text, 1); } else if (vKey == KeyCode.Space) { focusedText.text += " "; } else if (CastleTools.ValidateText(vKey.ToString())) { focusedText.text += vKey.ToString(); } } } } }
public static void Edit(CastleText castleText) { focusedText = castleText; editingText = true; }