Browse Source

remove useless code

tags/Rel1
sebas77 7 years ago
parent
commit
58b9d16d48
5 changed files with 0 additions and 164 deletions
  1. +0
    -6
      Context/Factories/GameObjectFactory.cs
  2. +0
    -98
      Context/Factories/Legacy/GameObjectFactory.cs
  3. +0
    -12
      Context/Factories/Legacy/GameObjectFactory.cs.meta
  4. +0
    -36
      Context/Factories/Legacy/MonoBehaviourFactory.cs
  5. +0
    -12
      Context/Factories/Legacy/MonoBehaviourFactory.cs.meta

+ 0
- 6
Context/Factories/GameObjectFactory.cs View File

@@ -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
/// <param name="prefab">original prefab</param>
public GameObject Build(GameObject prefab)
{
UnityEngine.Profiling.Profiler.BeginSample("GameObject Factory Build");

var copy = Object.Instantiate(prefab) as GameObject;

return copy;


+ 0
- 98
Context/Factories/Legacy/GameObjectFactory.cs View File

@@ -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<IUnityContextHierarchyChangedListener>(root);

_prefabs = new Dictionary<string, GameObject[]>();
}

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;
}

/// <summary>
/// Register a prefab to be built later using a string ID.
/// </summary>
/// <param name="prefab">original prefab</param>
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<MonoBehaviour>(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<NotifyComponentsRemoved>() == null)
currentGo.AddComponent<NotifyComponentsRemoved>().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<string, GameObject[]> _prefabs;
WeakReference<IUnityContextHierarchyChangedListener> _unityContext;
}
}

+ 0
- 12
Context/Factories/Legacy/GameObjectFactory.cs.meta View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 110a36d7de251bc41a444815f58a61c5
timeCreated: 1466179612
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

+ 0
- 36
Context/Factories/Legacy/MonoBehaviourFactory.cs View File

@@ -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<IUnityContextHierarchyChangedListener>(unityContext);
}

public M Build<M>(Func<M> 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<NotifyComponentsRemoved>() == null)
go.AddComponent<NotifyComponentsRemoved>().unityContext = _unityContext;

return mb;
}

WeakReference<IUnityContextHierarchyChangedListener> _unityContext;
}
}

+ 0
- 12
Context/Factories/Legacy/MonoBehaviourFactory.cs.meta View File

@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 86181a20ee37df64c9332a1c32369d72
timeCreated: 1466179768
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Loading…
Cancel
Save