public static void ResetSpriteSelection(ObjectField pField) { switch (GameObjectEditor.GetCurrentScriptable().mType) { case GameScriptable.ObjectType.SpawnFactory: SpawnFactory aTempObj = (SpawnFactory)GameObjectEditor.GetCurrentScriptable(); if (!string.IsNullOrEmpty(aTempObj.mTextureGUID)) { pField.SetEnabled(false); pField.value = aTempObj.mDisplaySprite; pField.SetEnabled(true); } break; case GameScriptable.ObjectType.StaticObject: StaticObject aTObj = (StaticObject)GameObjectEditor.GetCurrentScriptable(); if (!string.IsNullOrEmpty(aTObj.mTextureGUID)) { pField.SetEnabled(false); pField.value = aTObj.mDisplaySprite; pField.SetEnabled(true); } break; case GameScriptable.ObjectType.Item: Item aTmpObj = (Item)GameObjectEditor.GetCurrentScriptable(); if (!string.IsNullOrEmpty(aTmpObj.mTextureGUID)) { pField.SetEnabled(false); pField.value = aTmpObj.mDisplaySprite; pField.SetEnabled(true); } break; } }
static void CreateInstance() { if (mInstance == null) { mInstance = new GameObjectEditor(); } }
public static void ResetCollectSelection(ObjectField pField) { switch (GameObjectEditor.GetCurrentScriptable().mType) { case GameScriptable.ObjectType.Item: Item aItem = (Item)GameObjectEditor.GetCurrentScriptable(); if (!string.IsNullOrEmpty(aItem.mSoundGUID)) { pField.SetEnabled(false); pField.value = aItem.mItemCollectSound; pField.SetEnabled(true); } break; case GameScriptable.ObjectType.SpawnFactory: SpawnFactory aTem = (SpawnFactory)GameObjectEditor.GetCurrentScriptable(); if (!string.IsNullOrEmpty(aTem.mSoundGUID)) { pField.SetEnabled(false); pField.value = aTem.mSpawnSound; pField.SetEnabled(true); } break; } }
public static void OnCollectSoundSelection(AudioClip pClip, ObjectField pField) { if (pClip == null) { return; } string[] aAssetFolder = { "Assets/ScriptableObjects/Asset Meta Data" }; if (!AssetDatabase.IsValidFolder(aAssetFolder[0])) { ShowSelectionWarning(); ResetCollectSelection(pField); return; } string[] aAssetGUIDs = AssetDatabase.FindAssets(pClip.name, aAssetFolder); if (aAssetGUIDs.Length > 0) { string aPath = AssetDatabase.GUIDToAssetPath(aAssetGUIDs[0]); if (AssetDatabase.GetMainAssetTypeAtPath(aPath) == typeof(AssetMetaData)) { AssetMetaData aCurrentAssetData = (AssetMetaData)AssetDatabase.LoadAssetAtPath(aPath, typeof(AssetMetaData)); if (aCurrentAssetData.mType == AssetMetaData.AssetType.AudioAsset) { switch (GameObjectEditor.GetCurrentScriptable().mType) { case GameScriptable.ObjectType.Item: Item aTempObj = (Item)GameObjectEditor.GetCurrentScriptable(); aTempObj.mSoundGUID = aCurrentAssetData.mGUID; aTempObj.mItemCollectSound = pClip; break; case GameScriptable.ObjectType.SpawnFactory: SpawnFactory aTmpObj = (SpawnFactory)GameObjectEditor.GetCurrentScriptable(); aTmpObj.mSoundGUID = aCurrentAssetData.mGUID; aTmpObj.mSpawnSound = pClip; break; } } else { ShowSelectionWarning(); ResetCollectSelection(pField); return; } } else { ShowSelectionWarning(); ResetCollectSelection(pField); return; } } else { ShowSelectionWarning(); ResetCollectSelection(pField); return; } }
public static void ResetProjectileSelection(ObjectField pField) { Enemy aTem = (Enemy)GameObjectEditor.GetCurrentScriptable(); if (!string.IsNullOrEmpty(aTem.mProjectileGUID)) { pField.SetEnabled(false); pField.value = aTem.mProjectile; pField.SetEnabled(true); } }
public static void ResetSpawnEnemySelection(ObjectField pField) { SpawnFactory aTem = (SpawnFactory)GameObjectEditor.GetCurrentScriptable(); if (!string.IsNullOrEmpty(aTem.mEnemyGUID)) { pField.SetEnabled(false); pField.value = aTem.mSpawnEnemy; pField.SetEnabled(true); } }
public static void OnAttackSoundSelection(AudioClip pAttackSound, ObjectField pField) { if (pAttackSound == null) { return; } string[] aAssetFolder = { "Assets/ScriptableObjects/Asset Meta Data" }; if (!AssetDatabase.IsValidFolder(aAssetFolder[0])) { ShowSelectionWarning(); ResetAttackSoundSelection(pField); return; } string[] aAssetGUIDs = AssetDatabase.FindAssets(pAttackSound.name, aAssetFolder); if (aAssetGUIDs.Length > 0) { string aPath = AssetDatabase.GUIDToAssetPath(aAssetGUIDs[0]); if (AssetDatabase.GetMainAssetTypeAtPath(aPath) == typeof(AssetMetaData)) { AssetMetaData aCurrentAssetData = (AssetMetaData)AssetDatabase.LoadAssetAtPath(aPath, typeof(AssetMetaData)); if (aCurrentAssetData.mType == AssetMetaData.AssetType.AudioAsset) { Enemy aTmpObj = (Enemy)GameObjectEditor.GetCurrentScriptable(); aTmpObj.mAttackSoundGUID = aCurrentAssetData.mGUID; aTmpObj.mAttackSound = pAttackSound; } else { ShowSelectionWarning(); ResetAttackSoundSelection(pField); return; } } else { ShowSelectionWarning(); ResetAttackSoundSelection(pField); return; } } else { ShowSelectionWarning(); ResetAttackSoundSelection(pField); return; } }
public static void OnSpawnEnemySelection(Enemy pEnemy, ObjectField pField) { if (pEnemy == null) { return; } string[] aAssetFolder = { "Assets/ScriptableObjects/Asset Meta Data" }; if (!AssetDatabase.IsValidFolder(aAssetFolder[0])) { ShowSelectionWarning(); ResetSpawnEnemySelection(pField); return; } string[] aAssetGUIDs = AssetDatabase.FindAssets(pEnemy.name, aAssetFolder); if (aAssetGUIDs.Length > 0) { string aPath = AssetDatabase.GUIDToAssetPath(aAssetGUIDs[0]); if (AssetDatabase.GetMainAssetTypeAtPath(aPath) == typeof(AssetMetaData)) { AssetMetaData aCurrentAssetData = (AssetMetaData)AssetDatabase.LoadAssetAtPath(aPath, typeof(AssetMetaData)); if (aCurrentAssetData.mType == AssetMetaData.AssetType.PrefabAsset) { SpawnFactory aTmpObj = (SpawnFactory)GameObjectEditor.GetCurrentScriptable(); aTmpObj.mEnemyGUID = aCurrentAssetData.mGUID; aTmpObj.mSpawnEnemy = pEnemy; } else { ShowSelectionWarning(); ResetSpawnEnemySelection(pField); return; } } else { ShowSelectionWarning(); ResetSpawnEnemySelection(pField); return; } } else { ShowSelectionWarning(); ResetSpawnEnemySelection(pField); return; } }
void CreateCurrentEditor() { switch (mActiveEditor) { case EditorType.AssetEditor: mCurrentEditor = AssetEditor.CreateNewAssetEditorUI(); break; case EditorType.GameObjectEditor: mCurrentEditor = GameObjectEditor.CreateNewGameObjectEditorUI(); break; case EditorType.LevelEditor: mCurrentEditor = LevelEditor.CreateNewLevelEditorUI(); break; case EditorType.PlayerEditor: mCurrentEditor = PlayerEditor.CreateNewPlayerEditorUI(); break; } }
void OnGUI() { EditorGUILayout.BeginVertical(); mAnimationData.mAnimationName = EditorGUILayout.TextField("Name: ", mAnimationData.mAnimationName); mAnimationData.mAnimSpeed = EditorGUILayout.Slider("Animation Speed: ", mAnimationData.mAnimSpeed, 0, 50); mAnimationScroll = EditorGUILayout.BeginScrollView(mAnimationScroll, GUILayout.Width(500), GUILayout.Height(450)); if (Event.current.commandName == "ObjectSelectorUpdated" && mObjectPickerId == EditorGUIUtility.GetObjectPickerControlID()) { Sprite a = (Sprite)EditorGUIUtility.GetObjectPickerObject(); mObjectPickerId = -1; if (a != null) { if (mAnimationData.mSprites.Count > 0) { if (AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(a.texture)) != mAnimationData.mTextureAssetGUID) { EditorUtility.DisplayDialog("Cannot Add Sprite", "Sprite Not Part of The Same Texture Asset", "Okay"); } else { mAnimationData.mSprites.Add(a); if (mIsPlayer) { EditorUtility.SetDirty(PlayerEditor.GetActivePlayer()); } else { EditorUtility.SetDirty(GameObjectEditor.GetCurrentScriptable()); } mWindow.Repaint(); } } else { mAnimationData.mTextureAssetGUID = DoesAssetExists(a); if (mAnimationData.mTextureAssetGUID != null) { mAnimationData.mSprites.Add(a); if (mIsPlayer) { EditorUtility.SetDirty(PlayerEditor.GetActivePlayer()); } else { EditorUtility.SetDirty(GameObjectEditor.GetCurrentScriptable()); } mWindow.Repaint(); } } } } mAnimations.DoLayoutList(); EditorGUILayout.EndScrollView(); if (GUILayout.Button("Save Animation")) { if (mAnimationData.mSprites.Count <= 0) { EditorUtility.DisplayDialog("Animation Data Empty", "Cannot add an empty animation to the animation data", "Okay"); } else { if (!mIsPlayer) { GameObjectEditor.AddToCurrentAnimationList(mAnimationData); mWindow.Close(); } else { PlayerEditor.AddToPlayerAnimation(mAnimationData); mWindow.Close(); } } } EditorGUILayout.EndVertical(); }
public static void OnSpriteSelection(Sprite pSelectedSprite, ObjectField pField) { if (pSelectedSprite == null) { return; } string[] aAssetFolder = { "Assets/ScriptableObjects/Asset Meta Data" }; if (!AssetDatabase.IsValidFolder(aAssetFolder[0])) { ShowSelectionWarning(); ResetSpriteSelection(pField); return; } string[] aAssetGUIDs = AssetDatabase.FindAssets(pSelectedSprite.texture.name, aAssetFolder); if (aAssetGUIDs.Length > 0) { string aPath = AssetDatabase.GUIDToAssetPath(aAssetGUIDs[0]); if (AssetDatabase.GetMainAssetTypeAtPath(aPath) == typeof(AssetMetaData)) { AssetMetaData aCurrentAssetData = (AssetMetaData)AssetDatabase.LoadAssetAtPath(aPath, typeof(AssetMetaData)); if (aCurrentAssetData.mType == AssetMetaData.AssetType.TextureAsset) { switch (GameObjectEditor.GetCurrentScriptable().mType) { case GameScriptable.ObjectType.SpawnFactory: SpawnFactory aTempObj = (SpawnFactory)GameObjectEditor.GetCurrentScriptable(); aTempObj.mTextureGUID = aCurrentAssetData.mGUID; aTempObj.mDisplaySprite = pSelectedSprite; break; case GameScriptable.ObjectType.StaticObject: StaticObject aTObj = (StaticObject)GameObjectEditor.GetCurrentScriptable(); aTObj.mTextureGUID = aCurrentAssetData.mGUID; aTObj.mDisplaySprite = pSelectedSprite; break; case GameScriptable.ObjectType.Item: Item aTmpObj = (Item)GameObjectEditor.GetCurrentScriptable(); aTmpObj.mTextureGUID = aCurrentAssetData.mGUID; aTmpObj.mDisplaySprite = pSelectedSprite; break; default: ShowSelectionWarning(); ResetSpriteSelection(pField); break; } } else { ShowSelectionWarning(); ResetSpriteSelection(pField); return; } } else { ShowSelectionWarning(); ResetSpriteSelection(pField); return; } } else { ShowSelectionWarning(); ResetSpriteSelection(pField); return; } }