因此,在Unity3d中,当我在下面使用以下脚本时,控制台不会说Debug.Log给出的消息。这是脚本:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class Gui : MonoBehaviour
{
void OnMouseDown()
{
Debug.Log("It Works");
}
}
但是,当我单击包含此脚本的对象时,控制台上没有任何显示。我究竟做错了什么?任何帮助将不胜感激。
答案 0 :(得分:2)
根据文档,import numpy as np
weights=np.array([100, 45, 35, 25, 10, 5, 2.5])
weights=weights*2
target_weight = int(input('How much weight do you need? '))
nweights=[]
remaining = target_weight
for i, weight in enumerate(weights):
nweights=np.append(nweights, int(remaining/ weight))
remaining = remaining - nweights[i]*weights[i]
if remaining == 0:
break
nweights = nweights*2
weights=weights*0.5
weightlist=zip(nweights, weights)
barweight=0
for weight in weightlist:
print(f"{weight[0]} | {weight[1]}'s")
barweight=barweight+weight[0]*weight[1]
print(f'total weight: {barweight} pound')
if remaining !=0:
print(f'the correct weight combination cannot be found,'
f'the remaining weight is: {remaining} pound')
适用于具有碰撞器的GUI元素或对象。向您的对象添加一个对撞机,它应该可以正常工作。