Tree command, and more fixes.
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
using System.Collections.Generic;
|
||||
using OpenCover.Framework.Model;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cogwheel
|
||||
@@ -58,13 +55,13 @@ namespace Cogwheel
|
||||
if (arg == "-a")
|
||||
{
|
||||
Log(CommandsManager.IsCommandContextValid(command)
|
||||
? $"<color=green>({command.Method.DeclaringType.Name})</color> : {command.Name} - {command.Description}"
|
||||
: $"<color=#333333>({command.Method.DeclaringType.Name})</color> : {command.Name} - {command.Description}");
|
||||
? $"<color=green>({command.Method.DeclaringType.Name})</color> : {command.Name} - <i>{command.Description}</i>"
|
||||
: $"<color=#333333>({command.Method.DeclaringType.Name})</color> : {command.Name} - <i>{command.Description}</i>");
|
||||
}
|
||||
|
||||
if (CommandsManager.IsCommandContextValid(command))
|
||||
{
|
||||
Log($"<color=green>({command.Method.DeclaringType.Name})</color> : {command.Name} - {command.Description}");
|
||||
Log($"<color=green>({command.Method.DeclaringType.Name})</color> : {command.Name} - <i>{command.Description}</i>");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,16 +83,50 @@ namespace Cogwheel
|
||||
$"Usage: {CommandsManager.GetCommandUsage(command)}");
|
||||
}
|
||||
|
||||
[Command(CommandName = "search", Description = "Searches the scene for a GameObject with the given name and sets the Context to it.")]
|
||||
[Command(CommandName = "cd", Description = "Sets the context to the given path\n(If no specific path is given, it will set the context to the first object with the given name found in the scene)")]
|
||||
public static void SetContextByName(string name)
|
||||
{
|
||||
CommandsManager.SetContext(name);
|
||||
}
|
||||
|
||||
[Command(CommandName = "whois", Description = "Prints out the current Context name")]
|
||||
[Command(CommandName = "ctx", Description = "Prints out the current Context name")]
|
||||
public static void PrintContext()
|
||||
{
|
||||
Log($"Current context is: {CommandsManager.Context.name}");
|
||||
if (CommandsManager.Context is null)
|
||||
{
|
||||
LogWarning("No context set.");
|
||||
return;
|
||||
}
|
||||
Log($"-- CONTEXT <i>{CommandsManager.Context.name}</i> --");
|
||||
Log("-Components-");
|
||||
if (CommandsManager.Context.GetComponentCount() < 1)
|
||||
{
|
||||
LogWarning("No components found on this object.");
|
||||
return;
|
||||
}
|
||||
foreach (var component in CommandsManager.Context.GetComponents<MonoBehaviour>())
|
||||
{
|
||||
Log($"<color=green>- {component.GetType()}</color>");
|
||||
}
|
||||
}
|
||||
|
||||
[Command(CommandName = "tree", Description = "Prints the hierarchy of the scene")]
|
||||
public static void PrintObjectsInHierarchy()
|
||||
{
|
||||
foreach (var rootObject in UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects())
|
||||
{
|
||||
PrintHierarchy(rootObject.transform, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static void PrintHierarchy(Transform transform, int indentLevel)
|
||||
{
|
||||
string indent = new string(' ', indentLevel * 2);
|
||||
Log($"{indent}- {transform.name}");
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
PrintHierarchy(transform.GetChild(i), indentLevel + 1);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -257,10 +257,7 @@ namespace Cogwheel
|
||||
{
|
||||
var commandName = attribute.CommandName ?? method.Name;
|
||||
var newCommand = new Command(commandName, method, attribute.Description);
|
||||
if (!Commands.Values.Contains(newCommand))
|
||||
{
|
||||
Commands.TryAdd(newCommand.Name, newCommand);
|
||||
}
|
||||
Commands.TryAdd(newCommand.Name, newCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Cogwheel;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
@@ -18,4 +19,10 @@ public class Test : MonoBehaviour
|
||||
{
|
||||
Debug.Log($"PrivateCommand called: int is {value} and string is {text} and float is {f}");
|
||||
}
|
||||
|
||||
[Command]
|
||||
private void What()
|
||||
{
|
||||
COGWHEEL.Log("WHAT");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,6 +122,50 @@ NavMeshSettings:
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &510361092
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 510361094}
|
||||
- component: {fileID: 510361093}
|
||||
m_Layer: 0
|
||||
m_Name: Test2
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &510361093
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 510361092}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a2c4c2a5f3f0432eaf914b6d27031ca6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!4 &510361094
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 510361092}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 758753411}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &705507993
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -216,6 +260,51 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
|
||||
--- !u!1 &758753409
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 758753411}
|
||||
- component: {fileID: 758753410}
|
||||
m_Layer: 0
|
||||
m_Name: Test
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &758753410
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 758753409}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f2dd85165475cf7a81bf4b02e9502f4, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!4 &758753411
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 758753409}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 6.010771, y: 13.350267, z: 7.386556}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 510361094}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &963194225
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -360,6 +449,10 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: Cogwheel
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6812011641737714985, guid: bfba73797df1fe94c91fd68237bdb897, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
@@ -372,3 +465,4 @@ SceneRoots:
|
||||
- {fileID: 963194228}
|
||||
- {fileID: 705507995}
|
||||
- {fileID: 1414270578}
|
||||
- {fileID: 758753411}
|
||||
|
||||
Reference in New Issue
Block a user