From 58b9d16d48a309b2f9c13a6bd8bd8d477ca9c668 Mon Sep 17 00:00:00 2001 From: sebas77 Date: Mon, 23 Jan 2017 12:03:40 +0000 Subject: [PATCH] remove useless code --- Context/Factories/GameObjectFactory.cs | 6 -- Context/Factories/Legacy/GameObjectFactory.cs | 98 ------------------- .../Legacy/GameObjectFactory.cs.meta | 12 --- .../Factories/Legacy/MonoBehaviourFactory.cs | 36 ------- .../Legacy/MonoBehaviourFactory.cs.meta | 12 --- 5 files changed, 164 deletions(-) delete mode 100644 Context/Factories/Legacy/GameObjectFactory.cs delete mode 100644 Context/Factories/Legacy/GameObjectFactory.cs.meta delete mode 100644 Context/Factories/Legacy/MonoBehaviourFactory.cs delete mode 100644 Context/Factories/Legacy/MonoBehaviourFactory.cs.meta diff --git a/Context/Factories/GameObjectFactory.cs b/Context/Factories/GameObjectFactory.cs index 9519e6d..551c88f 100644 --- a/Context/Factories/GameObjectFactory.cs +++ b/Context/Factories/GameObjectFactory.cs @@ -1,10 +1,6 @@ -#region - using System.Collections.Generic; using UnityEngine; -#endregion - namespace Svelto.Context { public class GameObjectFactory : Factories.IGameObjectFactory @@ -48,8 +44,6 @@ namespace Svelto.Context /// original prefab public GameObject Build(GameObject prefab) { - UnityEngine.Profiling.Profiler.BeginSample("GameObject Factory Build"); - var copy = Object.Instantiate(prefab) as GameObject; return copy; diff --git a/Context/Factories/Legacy/GameObjectFactory.cs b/Context/Factories/Legacy/GameObjectFactory.cs deleted file mode 100644 index 49c1008..0000000 --- a/Context/Factories/Legacy/GameObjectFactory.cs +++ /dev/null @@ -1,98 +0,0 @@ -#region - -using System.Collections.Generic; -using Svelto.Context.Legacy; -using Svelto.DataStructures; -using UnityEngine; - -#endregion - -namespace Svelto.Context.Legacy -{ - public class GameObjectFactory : Factories.IGameObjectFactory - { - public GameObjectFactory(IUnityContextHierarchyChangedListener root) - { - _unityContext = new WeakReference(root); - - _prefabs = new Dictionary(); - } - - public GameObject Build(string prefabName) - { - DesignByContract.Check.Require(_prefabs.ContainsKey(prefabName), "Svelto.Factories.IGameObjectFactory - Invalid Prefab Type"); - - var go = Build(_prefabs[prefabName][0]); - - GameObject parent = _prefabs[prefabName][1]; - - if (parent != null) - { - Transform transform = go.transform; - - var scale = transform.localScale; - var rotation = transform.localRotation; - var position = transform.localPosition; - - parent.SetActive(true); - - transform.parent = parent.transform; - - transform.localPosition = position; - transform.localRotation = rotation; - transform.localScale = scale; - } - - return go; - } - - /// - /// Register a prefab to be built later using a string ID. - /// - /// original prefab - public GameObject Build(GameObject prefab) - { - DesignByContract.Check.Require(_unityContext.IsAlive == true, "Context is used, but not alive"); - - UnityEngine.Profiling.Profiler.BeginSample("GameObject Factory Build"); - - var copy = Object.Instantiate(prefab) as GameObject; - var components = copy.GetComponentsInChildren(true); - - for (var i = 0; i < components.Length; ++i) - { - var monoBehaviour = components[i]; - - if (monoBehaviour != null) - { - var currentGo = monoBehaviour.gameObject; - - _unityContext.Target.OnMonobehaviourAdded(monoBehaviour); - - if (currentGo.GetComponent() == null) - currentGo.AddComponent().unityContext = _unityContext; - } - else - { - //Utility.Console.Log("delete me"); - } - } - - UnityEngine.Profiling.Profiler.EndSample(); - - return copy; - } - - public void RegisterPrefab(GameObject prefab, string prefabName, GameObject parent = null) - { - var objects = new GameObject[2]; - - objects[0] = prefab; objects[1] = parent; - - _prefabs.Add(prefabName, objects); - } - - Dictionary _prefabs; - WeakReference _unityContext; - } -} \ No newline at end of file diff --git a/Context/Factories/Legacy/GameObjectFactory.cs.meta b/Context/Factories/Legacy/GameObjectFactory.cs.meta deleted file mode 100644 index b07702c..0000000 --- a/Context/Factories/Legacy/GameObjectFactory.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 110a36d7de251bc41a444815f58a61c5 -timeCreated: 1466179612 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Context/Factories/Legacy/MonoBehaviourFactory.cs b/Context/Factories/Legacy/MonoBehaviourFactory.cs deleted file mode 100644 index 5669802..0000000 --- a/Context/Factories/Legacy/MonoBehaviourFactory.cs +++ /dev/null @@ -1,36 +0,0 @@ -#region - -using System; -using Svelto.DataStructures; -using UnityEngine; - -#endregion - -namespace Svelto.Context.Legacy -{ - public class MonoBehaviourFactory : Factories.IMonoBehaviourFactory - { - public MonoBehaviourFactory(IUnityContextHierarchyChangedListener unityContext) - { - _unityContext = new WeakReference(unityContext); - } - - public M Build(Func constructor) where M : MonoBehaviour - { - DesignByContract.Check.Require(_unityContext.IsAlive == true, "Context is used, but not alive"); - - var mb = constructor(); - - _unityContext.Target.OnMonobehaviourAdded(mb); - - GameObject go = mb.gameObject; - - if (go.GetComponent() == null) - go.AddComponent().unityContext = _unityContext; - - return mb; - } - - WeakReference _unityContext; - } -} diff --git a/Context/Factories/Legacy/MonoBehaviourFactory.cs.meta b/Context/Factories/Legacy/MonoBehaviourFactory.cs.meta deleted file mode 100644 index 8922e2e..0000000 --- a/Context/Factories/Legacy/MonoBehaviourFactory.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 86181a20ee37df64c9332a1c32369d72 -timeCreated: 1466179768 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: