private void ManagePrefabPlacement(RaycastHit raycastHit) { Quaternion rot = Quaternion.Euler(rotation) * Quaternion.LookRotation(Vector3.forward, raycastHit.normal); if (placingProp != null) { if (!placingProp.gameObject.activeSelf) { placingProp.gameObject.SetActive(true); } placingProp.SetPosition(raycastHit.point, false); placingProp.SetRotation(rot, false); } }
private WorldProp CreatePropGameObjectInternal(WorldObject obj) { var prefab = PrefabDatabase.Instance.GetEntry(obj.guid); GameObject instacne = Instantiate(prefab.Prop.gameObject); SetLayerRecursively(instacne, WorldLayer); WorldProp prop = instacne.GetComponent <WorldProp>(); prop.SetPrefab(prefab); prop.SetPosition(obj.pos, false); prop.SetRotation(obj.rotation, false); prop.SetScale(obj.scale, false); prop.SetColor(obj.color, false); return(prop); }
private void DoInspector(WorldProp prop) { GUILayout.BeginHorizontal(); Vector3 pos = prop.Position; GUILayout.Label(new GUIContent("Position"), GUILayout.Width(90)); GUILayout.Label(new GUIContent("X"), Styles.prefixLabelClose); pos.x = RuntimeEditorGUI.FloatFieldInternal(GUILayoutUtility.GetRect(GUIContent.none, GUI.skin.textField), pos.x, GUI.skin.textField); GUILayout.Label(new GUIContent("Y"), Styles.prefixLabelClose); pos.y = RuntimeEditorGUI.FloatFieldInternal(GUILayoutUtility.GetRect(GUIContent.none, GUI.skin.textField), pos.y, GUI.skin.textField); GUILayout.Label(new GUIContent("Z"), Styles.prefixLabelClose); pos.z = RuntimeEditorGUI.FloatFieldInternal(GUILayoutUtility.GetRect(GUIContent.none, GUI.skin.textField), pos.z, GUI.skin.textField); prop.SetPosition(pos, true); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); Vector3 eualrRotation = prop.Rotation.eulerAngles; GUILayout.Label(new GUIContent("Rotation"), GUILayout.Width(90)); GUILayout.Label(new GUIContent("X"), Styles.prefixLabelClose); eualrRotation.x = RuntimeEditorGUI.FloatFieldInternal(GUILayoutUtility.GetRect(GUIContent.none, GUI.skin.textField), eualrRotation.x, GUI.skin.textField); GUILayout.Label(new GUIContent("Y"), Styles.prefixLabelClose); eualrRotation.y = RuntimeEditorGUI.FloatFieldInternal(GUILayoutUtility.GetRect(GUIContent.none, GUI.skin.textField), eualrRotation.y, GUI.skin.textField); GUILayout.Label(new GUIContent("Z"), Styles.prefixLabelClose); eualrRotation.z = RuntimeEditorGUI.FloatFieldInternal(GUILayoutUtility.GetRect(GUIContent.none, GUI.skin.textField), eualrRotation.z, GUI.skin.textField); prop.SetRotation(Quaternion.Euler(eualrRotation), true); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); Vector3 scale = prop.Scale; GUILayout.Label(new GUIContent("Scale"), GUILayout.Width(90)); GUILayout.Label(new GUIContent("X"), Styles.prefixLabelClose); scale.x = RuntimeEditorGUI.FloatFieldInternal(GUILayoutUtility.GetRect(GUIContent.none, GUI.skin.textField), scale.x, GUI.skin.textField); GUILayout.Label(new GUIContent("Y"), Styles.prefixLabelClose); scale.y = RuntimeEditorGUI.FloatFieldInternal(GUILayoutUtility.GetRect(GUIContent.none, GUI.skin.textField), scale.y, GUI.skin.textField); GUILayout.Label(new GUIContent("Z"), Styles.prefixLabelClose); scale.z = RuntimeEditorGUI.FloatFieldInternal(GUILayoutUtility.GetRect(GUIContent.none, GUI.skin.textField), scale.z, GUI.skin.textField); prop.SetScale(scale, true); GUILayout.EndHorizontal(); }