This should do it.trueBlue wrote: ↑25 Aug 2022, 00:36 Is there a way, within your Make LookAt List script, to clear the list, if there are no objects in the scene that do not have Look At applied?
I have added a UnLook At button to the panel
Activity.Run("%THIS_NAME%" + "/UnLook At");
Activity.Run("%THIS_NAME%" + "/Make LookAt List");
Code: Select all
// Execute
// Called to execute the command
function Execute(params)
{
var LookAtEnum = params.ConValue('LookAtEnum');
lookatList = [];
FindAllLookAts(Space.CurrentScene());
var nodeEnum = System.CreateDO('Common Data Package/String Enum Data');
nodeEnum.Clear();
if(lookatList.length == 0) {
Node.Value(System.ThisOwner(), "LookAtEnum") = nodeEnum;
return;
}
for(var i=0;i<lookatList.length;i++) {
nodeEnum.SetStringAt(i,lookatList[i]);
}
nodeEnum.SetSelectedString(lookatList[0])
//params.ConValue("LookAtEnum") = nodeEnum;
Node.Value(System.ThisOwner(), "LookAtEnum") = nodeEnum;
}
function FindAllLookAts(curNode)
{
if(Node.Exists(curNode + "/LookAt2")) {
lookatList.push(curNode);
return;
}
var numChildren = Node.SubObjectCount(curNode);
if(numChildren == 0) return;
for(var i=0; i<numChildren; i++) {
var childNode = curNode + "/" + Node.SubObject(curNode, i);
FindAllLookAts(childNode)
}
}