Initial commit

This commit is contained in:
HussienX72u
2026-07-21 08:56:10 +03:00
commit 4017028111
9410 changed files with 2150500 additions and 0 deletions
@@ -0,0 +1,48 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a786d380a7823b4d9a0511ba886548f, type: 3}
m_Name: Connector Prefab Settings
m_EditorClassIdentifier:
MainComponents:
GrabInteractable: {fileID: 11500000, guid: d9a466110b129074db957157c7ec5b2f, type: 3}
MechanicalBlock: {fileID: 11500000, guid: c4a1be166f8c7184ab860f9a010f5764, type: 3}
AttachableBlock: {fileID: 11500000, guid: 6f653344f2c17b64fb6a4073754cb555, type: 3}
SocketContainer: {fileID: 11500000, guid: aa5c0234b0ff887468bde7ca9dbbf542, type: 3}
PlacementValidator: {fileID: 11500000, guid: 8245c6e3d94e025439b7ccced75276db,
type: 3}
SocketPoint: {fileID: 11500000, guid: 7d04d85508b5c414d82419db222f9936, type: 3}
ContainerInit: {fileID: 11500000, guid: b628454e932ec7e47be99c98c50c21d2, type: 3}
BlockSettings:
grabInteractable:
Test:
mechanicalBlock:
Test:
attachableBlock:
Type: 1
socketContainer:
Test:
validator:
CollisionLayerMask:
serializedVersion: 2
m_Bits: 64
socketPoint:
SocketRadius: 0.3
MiscellaneousSettings:
BlockLayer:
serializedVersion: 2
m_Bits: 64
categoryData: {fileID: 11400000, guid: 5a2a0a71bcd471d468b7bcacbbc8176a, type: 2}
SavePath: Assets/_Project/Prefabs/Final Prefabs/Connectors
Name: Connector
IteratedNumbering: 1
Suffix: _v
OverwriteExisting: 0
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 38c572c2bd6d37d47b52e39734d17138
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,48 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a786d380a7823b4d9a0511ba886548f, type: 3}
m_Name: Joint Prefab Settings
m_EditorClassIdentifier:
MainComponents:
GrabInteractable: {fileID: 11500000, guid: d9a466110b129074db957157c7ec5b2f, type: 3}
MechanicalBlock: {fileID: 11500000, guid: c4a1be166f8c7184ab860f9a010f5764, type: 3}
AttachableBlock: {fileID: 11500000, guid: 6f653344f2c17b64fb6a4073754cb555, type: 3}
SocketContainer: {fileID: 11500000, guid: aa5c0234b0ff887468bde7ca9dbbf542, type: 3}
PlacementValidator: {fileID: 11500000, guid: 8245c6e3d94e025439b7ccced75276db,
type: 3}
SocketPoint: {fileID: 11500000, guid: 7d04d85508b5c414d82419db222f9936, type: 3}
ContainerInit: {fileID: 11500000, guid: b628454e932ec7e47be99c98c50c21d2, type: 3}
BlockSettings:
grabInteractable:
Test:
mechanicalBlock:
Test:
attachableBlock:
Type: 0
socketContainer:
Test:
validator:
CollisionLayerMask:
serializedVersion: 2
m_Bits: 64
socketPoint:
SocketRadius: 0
MiscellaneousSettings:
BlockLayer:
serializedVersion: 2
m_Bits: 64
categoryData: {fileID: 11400000, guid: ffda9eca5fbd46e4badbaf708cf51b66, type: 2}
SavePath: Assets/_Project/Prefabs/Final Prefabs/Joints
Name: Joint
IteratedNumbering: 1
Suffix: _v
OverwriteExisting: 0
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2de43eefeedfd8a4eb9ba0e9d8b1ef93
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,48 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a786d380a7823b4d9a0511ba886548f, type: 3}
m_Name: Link Prefab Settings
m_EditorClassIdentifier:
MainComponents:
GrabInteractable: {fileID: 11500000, guid: d9a466110b129074db957157c7ec5b2f, type: 3}
MechanicalBlock: {fileID: 11500000, guid: c4a1be166f8c7184ab860f9a010f5764, type: 3}
AttachableBlock: {fileID: 11500000, guid: 6f653344f2c17b64fb6a4073754cb555, type: 3}
SocketContainer: {fileID: 11500000, guid: aa5c0234b0ff887468bde7ca9dbbf542, type: 3}
PlacementValidator: {fileID: 11500000, guid: 8245c6e3d94e025439b7ccced75276db,
type: 3}
SocketPoint: {fileID: 11500000, guid: 7d04d85508b5c414d82419db222f9936, type: 3}
ContainerInit: {fileID: 11500000, guid: b628454e932ec7e47be99c98c50c21d2, type: 3}
BlockSettings:
grabInteractable:
Test:
mechanicalBlock:
Test:
attachableBlock:
Type: 1
socketContainer:
Test:
validator:
CollisionLayerMask:
serializedVersion: 2
m_Bits: 64
socketPoint:
SocketRadius: 0.3
MiscellaneousSettings:
BlockLayer:
serializedVersion: 2
m_Bits: 64
categoryData: {fileID: 11400000, guid: 86480ee67e6364b4fa1f9a1a496e5b4c, type: 2}
SavePath: Assets/_Project/Prefabs/Final Prefabs/Links
Name: Link
IteratedNumbering: 1
Suffix: _v
OverwriteExisting: 0
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 94270647119ef4240866cec766f99b11
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,112 @@
using NaughtyAttributes;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
[System.Serializable]
public class mainComponent
{
[Header("Input the scripts for the components as intstructed by their name")]
[Tooltip("Input the Grab Interactable script here")] public MonoScript GrabInteractable;
[Tooltip("Input the Mechanical Block script here")] public MonoScript MechanicalBlock;
[Tooltip("Input the Attachable Block script here")] public MonoScript AttachableBlock;
[Tooltip("Input the Socket Container script here")] public MonoScript SocketContainer;
[Tooltip("Input the Placement Validator script here")] public MonoScript PlacementValidator;
[Tooltip("Input the Socket Point script here")] public MonoScript SocketPoint;
[Tooltip("Input the Block Container Init script here")] public MonoScript ContainerInit;
}
[System.Serializable]
public class blockSettings
{
[System.Serializable]
public class GrabInteractableSettings
{
[Header("WIP")]
public string Test;
}
[System.Serializable]
public class MechanicalBlockSettings
{
[Header("WIP")]
public string Test;
}
[System.Serializable]
public class AttachableBlockSettings
{
public BlockType Type;
}
[System.Serializable]
public class SocketContainerSettings
{
[Header("WIP")]
public string Test;
}
[System.Serializable]
public class ValidatorSettings
{
public LayerMask CollisionLayerMask;
}
[System.Serializable]
public class SocketPointSettings
{
public float SocketRadius;
}
[System.Serializable]
public class MiscSettings
{
public LayerMask BlockLayer;
}
public GrabInteractableSettings grabInteractable;
public MechanicalBlockSettings mechanicalBlock;
public AttachableBlockSettings attachableBlock;
public SocketContainerSettings socketContainer;
public ValidatorSettings validator;
public SocketPointSettings socketPoint;
public MiscSettings MiscellaneousSettings;
}
[CreateAssetMenu(fileName = "BlockPrefabSettings", menuName = "Youssef Tools/Prefab Creator Settings")]
public class PrefabCreatorSettings : ScriptableObject
{
public mainComponent MainComponents;
public blockSettings BlockSettings;
public CategoryData categoryData;
[Header("-- Save Settings --")]
[ContextMenuItem("Browse Folder", "Browse")]
public string SavePath = "Assets/_Project/Prefabs";
public string Name = "Block";
public bool IteratedNumbering = false;
public string Suffix = " vX";
[Header("-- Behavior [Leave if unsure] --")]
public bool OverwriteExisting = false;
private void Browse()
{
string path = EditorUtility.OpenFolderPanel("Select Save Folder", "Assets", "");
if (!string.IsNullOrEmpty(path))
{
if (path.StartsWith(Application.dataPath))
{
SavePath = "Assets" + path.Substring(Application.dataPath.Length);
}
else
{
Debug.LogWarning("Please select a folder inside the Assets directory.");
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7a786d380a7823b4d9a0511ba886548f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,242 @@
using Codice.CM.SEIDInfo;
using IconsCreationTool.Editor.Core;
using JetBrains.Annotations;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Unity.EditorCoroutines.Editor;
using Unity.VisualScripting;
using UnityEditor;
using UnityEngine;
using static UnityEditor.Experimental.GraphView.GraphView;
using static UnityEngine.GraphicsBuffer;
public class PrefabCreatorTool
{
static BlockDataCreatorEditor BDCE = new BlockDataCreatorEditor();
static IconsCreator IC = new IconsCreator();
[MenuItem("Youssef Tools/Create Prefab", false, 0)]
static void CreatePrefab()
{
string SavedPath = EditorPrefs.GetString("YoussefTool_SettingsPath", "");
if (string.IsNullOrEmpty(SavedPath))
{
Debug.Log("Couldn't find settings script. Please add it via the setup window");
return;
}
else
{
Debug.Log("Found settings scriptable object");
}
PrefabCreatorSettings Settings = AssetDatabase.LoadAssetAtPath<PrefabCreatorSettings>(SavedPath);
if (Settings == null)
{
Debug.LogError("The assigned settings file was deleted or moved. Please reassign in the Settings Manager.");
return;
}
GameObject[] selectedObjects = Selection.gameObjects;
int count = selectedObjects.Length;
if (count == 0)
{
Debug.LogError("Please select a GameObject in the hierarchy first");
return;
}
for (int i = 0; i < count; i++)
{
float progress = (float)i / count;
EditorUtility.DisplayProgressBar("Creating Prefabs", $"Processing {selectedObjects[i].name}...", progress);
GameObject instObj = Object.Instantiate(selectedObjects[i]);
Undo.RegisterCreatedObjectUndo(instObj, "Create Prefab");
CreateStart(instObj, Settings);
}
EditorUtility.ClearProgressBar();
}
// Logic (ngl Youssef cooked here)
public static void CreateStart(GameObject Target, PrefabCreatorSettings Settings)
{
if (Target.transform.childCount == 0)
{
Debug.LogError("Please setup the target object by supplying it with the spheres as children");
return;
}
// Main mesh part
var MC = Settings.MainComponents;
if (MC.GrabInteractable != null)
{
var scriptType = MC.GrabInteractable.GetClass();
if (scriptType == null || !typeof(GrabInteractable).IsAssignableFrom(scriptType))
Debug.LogError("The Grab Interactable script is incorrect or does not inherit from GrabInteractable");
else
{
var gInteract = Target.AddComponent(scriptType);
}
}
if (MC.MechanicalBlock != null)
{
var scriptType = MC.MechanicalBlock.GetClass();
if (scriptType == null || !typeof(Block).IsAssignableFrom(scriptType))
Debug.LogError("The Block script is incorrect!");
else
{
var mBlock = Target.AddComponent(scriptType);
}
}
if (MC.AttachableBlock != null)
{
var scriptType = MC.AttachableBlock.GetClass();
if (scriptType == null || !typeof(AttachableBlock).IsAssignableFrom(scriptType))
Debug.LogError("The Attachable Block script is incorrect!");
else
{
Target.AddComponent(scriptType);
BlockType layerM = Settings.BlockSettings.attachableBlock.Type;
Target.GetComponent<AttachableBlock>().SetBlockType(layerM);
}
}
if (MC.SocketContainer != null)
{
var scriptType = MC.SocketContainer.GetClass();
if (scriptType == null || !typeof(SocketContainer).IsAssignableFrom(scriptType))
Debug.LogError("The Socket Container script is incorrect!");
else
{
var sContain = Target.AddComponent(scriptType);
}
}
if (MC.PlacementValidator != null)
{
var scriptType = MC.PlacementValidator.GetClass();
if (scriptType == null || !typeof(IValidator).IsAssignableFrom(scriptType))
Debug.LogError("The Validator script is incorrect!");
else
{
var pValidate = Target.AddComponent(scriptType);
LayerMask Coll = Settings.BlockSettings.validator.CollisionLayerMask;
Target.GetComponent<IValidator>().SetLayerMask(Coll);
}
}
if (MC.ContainerInit != null)
{
var scriptType = MC.ContainerInit.GetClass();
if (scriptType == null || !typeof(BlockContainerInit).IsAssignableFrom(scriptType))
Debug.LogError("The Block Container Init script is incorrect");
else
{
var cInit = Target.AddComponent(scriptType);
}
}
Rigidbody RB = Target.AddComponent<Rigidbody>();
MeshCollider MeshC = Target.AddComponent<MeshCollider>();
MeshC.convex = false;
RB.isKinematic = true;
RB.useGravity = false;
Target.transform.localEulerAngles = new Vector3(0, 0, 0);
var Tlayer = Settings.BlockSettings.MiscellaneousSettings.BlockLayer;
// Children part
Transform[] Children = Target.GetComponentsInChildren<Transform>().Where(x => x != Target.transform).ToArray();
if (Children.Length < 0)
Debug.Log($"No children exist for object {Target.name}, please make sure the object has children or add sockets manually");
else
{
foreach (Transform t in Children)
{
Object.DestroyImmediate(t.GetComponent<MeshRenderer>());
if (MC.SocketPoint != null)
{
var scriptType = MC.SocketPoint.GetClass();
if (scriptType == null || !typeof(SocketPoint).IsAssignableFrom(scriptType))
Debug.LogError("The Socket Point script is incorrect!");
else
{
t.gameObject.AddComponent(scriptType);
var sPoint = t.gameObject.GetComponent<SocketPoint>();
sPoint.SetSocketRadius(Settings.BlockSettings.socketPoint.SocketRadius);
}
}
Rigidbody rb = t.AddComponent<Rigidbody>();
CapsuleCollider sc = t.AddComponent<CapsuleCollider>();
rb.isKinematic = true;
rb.useGravity = false;
sc.isTrigger = true;
t.localPosition = new Vector3(t.localPosition.x, t.localPosition.y / 2, t.localPosition.z);
t.localScale = new Vector3(0.006f, 0.006f, 0.006f);
}
}
if (!Directory.Exists(Settings.SavePath))
{
Directory.CreateDirectory(Settings.SavePath);
AssetDatabase.Refresh();
}
string fileName = Settings.Name + Settings.Suffix;
string localPath = $"{Settings.SavePath}/{fileName}.prefab";
if (Settings.IteratedNumbering || !Settings.OverwriteExisting)
{
localPath = AssetDatabase.GenerateUniqueAssetPath(localPath);
}
bool success;
GameObject prefabAsset = PrefabUtility.SaveAsPrefabAsset(Target, localPath, out success);
if (success)
{
Debug.Log($"Success! Prefab created at: {localPath}");
EditorGUIUtility.PingObject(prefabAsset);
}
else
{
Debug.LogError("Prefab failed to save. Check the Save Path in Settings.");
}
var BD = BDCE.CreateBlockData(prefabAsset);
prefabAsset.GetComponent<MechanicalBlock>().SetBlockData(BD);
if (Settings.categoryData)
{
var Category = Settings.categoryData;
BD.associatedCategory = Category;
Category.blocks.Add(BD);
}
List<Object> list = new List<Object>();
list.Add(prefabAsset);
IconBackgroundData IBD = new IconBackgroundData(IconBackground.None, Color.white, Texture2D.whiteTexture);
IconsCreatorData ICD = new IconsCreatorData(1024, 0, null, null, IBD, list, true);
IC.SetData(ICD);
IC.CreateIcon();
PrefabUtility.RecordPrefabInstancePropertyModifications(prefabAsset);
EditorUtility.SetDirty(prefabAsset);
AssetDatabase.SaveAssetIfDirty(prefabAsset);
AssetDatabase.Refresh();
Object.DestroyImmediate(Target);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 147dedb329e334b4e8f14903b5a67d1e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,37 @@
using UnityEngine;
using UnityEditor;
public class PrefabSettingsWindow : EditorWindow
{
public PrefabCreatorSettings CurrentSettings;
[MenuItem("Youssef Tools/Prefab Creator Setup")]
public static void ShowWindow() => GetWindow<PrefabSettingsWindow>("Setup Window");
private void OnEnable()
{
string SavedPath = EditorPrefs.GetString("YoussefTool_SettingsPath", "");
if (!string.IsNullOrEmpty(SavedPath))
{
CurrentSettings = AssetDatabase.LoadAssetAtPath<PrefabCreatorSettings>(SavedPath);
}
}
void OnGUI()
{
GUILayout.Label("Active Tool Settings", EditorStyles.boldLabel);
EditorGUI.BeginChangeCheck();
CurrentSettings = (PrefabCreatorSettings)EditorGUILayout.ObjectField(
"Prefab Creator Settings", CurrentSettings, typeof(PrefabCreatorSettings), false);
if (EditorGUI.EndChangeCheck())
{
string path = AssetDatabase.GetAssetPath(CurrentSettings);
EditorPrefs.SetString("YoussefTool_SettingsPath", path);
}
if (CurrentSettings != null)
Editor.CreateEditor(CurrentSettings).OnInspectorGUI();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 81bb800f6ea1d69459bb074210dd283a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: