Exemplo n.º 1
0
        /// <summary>
        /// Refreshes the Generator
        /// </summary>
        /// <param name="forceUpdate">true to force a refresh of all modules</param>
        public void Refresh(bool forceUpdate = false)
        {
            if (!IsInitialized)
            {
                return;
            }
            if (mNeedSort)
            {
                doSortModules();
            }

            CGModule firstChanged = null;

            for (int i = 0; i < Modules.Count; i++)
            {
                if (forceUpdate && Modules[i] is IOnRequestProcessing)
                {
                    Modules[i].Dirty = true; // Dirty state will be resetted to false, but last data will be deleted - forcing a recalculation
                }
                if (!(Modules[i] is INoProcessing) && (Modules[i].Dirty || (forceUpdate && !(Modules[i] is IOnRequestProcessing))))
                {
                    Modules[i].checkOnStateChangedINTERNAL();
                    if (Modules[i].IsInitialized && Modules[i].IsConfigured)
                    {
                        if (firstChanged == null)
                        {
#if UNITY_EDITOR || CURVY_DEBUG
                            DEBUG_ExecutionTime.Start();
#endif
                            firstChanged = Modules[i];
                        }

                        //Debug.Log("Refresh " + Modules[i].ModuleName);
                        Modules[i].doRefresh();
                        //Debug.Log("Updated " + Modules[i].ModuleName);
                    }

                    //else
                    //{
                    //Debug.Log("Early OUT at "+Modules[i].ModuleName);
                    //break;

                    //}
                }
            }
            if (firstChanged != null)
            {
#if UNITY_EDITOR || CURVY_DEBUG
                DEBUG_ExecutionTime.Stop();
                if (!Application.isPlaying)
                {
                    EditorUtility.UnloadUnusedAssetsImmediate();
                }
#endif
                OnRefreshEvent(new CurvyCGEventArgs(this, firstChanged));
            }
        }
Exemplo n.º 2
0
        public Component Create(CGModule module, string context)
        {
            var spl = CurvySpline.Create();

            spl.transform.position = Vector3.zero;
            spl.Closed             = true;
            spl.Add(new Vector3(0, 0, 0), new Vector3(5, 0, 10), new Vector3(-5, 0, 10));
            return(spl);
        }
Exemplo n.º 3
0
        public Component Create(CGModule module, string context)
        {
            var spl = CurvySpline.Create();

            spl.transform.position = Vector3.zero;
            spl.RestrictTo2D       = true;
            spl.Closed             = true;
            spl.Orientation        = CurvyOrientation.None;
            spl.gameObject.AddComponent <CSCircle>().Refresh();
            return(spl);
        }
Exemplo n.º 4
0
        public void Destroy(CGModule module, Component obj, string context, bool kill)
        {
            if (obj != null)
            {
#if UNITY_EDITOR
                if (!Application.isPlaying)
                {
                    Undo.DestroyObjectImmediate(obj.gameObject);
                }
                else
#endif
                GameObject.Destroy(obj);
            }
        }
Exemplo n.º 5
0
 public static void DestroyResource(CGModule module, string resName, Component obj, string context, bool kill)
 {
     if (Loader.Count == 0)
     {
         getLoaders();
     }
     if (Loader.ContainsKey(resName))
     {
         var loader = Loader[resName];
         loader.Destroy(module, obj, context, kill);
     }
     else
     {
         Debug.LogError("CGResourceHandler: Missing Loader for resource '" + resName + "'");
     }
 }
Exemplo n.º 6
0
 public static Component CreateResource(CGModule module, string resName, string context)
 {
     if (Loader.Count == 0)
     {
         getLoaders();
     }
     if (Loader.ContainsKey(resName))
     {
         var loader = Loader[resName];
         return(loader.Create(module, context));
     }
     else
     {
         Debug.LogError("CGResourceHandler: Missing Loader for resource '" + resName + "'");
         return(null);
     }
 }
Exemplo n.º 7
0
 public void Destroy(CGModule module, Component obj, string context, bool kill)
 {
     if (obj != null)
     {
         if (kill)
         {
             if (Application.isPlaying)
             {
                 GameObject.Destroy(obj.gameObject);
             }
             else
             {
                 GameObject.DestroyImmediate(obj.gameObject);
             }
         }
         else
         {
             module.Generator.PoolManager.GetPrefabPool(context).Push(obj.gameObject);
         }
     }
 }
Exemplo n.º 8
0
 public void Destroy(CGModule module, Component obj, string context, bool kill)
 {
     if (obj != null)
     {
         if (kill)
         {
             if (Application.isPlaying)
             {
                 GameObject.Destroy(obj.gameObject);
             }
             else
             {
                 GameObject.DestroyImmediate(obj.gameObject);
             }
         }
         else
         {
             obj.StripComponents(typeof(CGMeshResource), typeof(MeshFilter), typeof(MeshRenderer));
             module.Generator.PoolManager.GetComponentPool <CGMeshResource>().Push(obj);
         }
     }
 }
Exemplo n.º 9
0
 public void setINTERNAL(CurvyGenerator generator, string moduleName, string slotName)
 {
     m_Module   = generator.GetModule(moduleName);
     m_SlotName = slotName;
     mSlot      = null;
 }
Exemplo n.º 10
0
        /*! \cond PRIVATE */

        public void setINTERNAL(CGModule module, string slotName)
        {
            m_Module   = module;
            m_SlotName = slotName;
            mSlot      = null;
        }
Exemplo n.º 11
0
 public CGDataReference(CGModule module, string slotName)
 {
     setINTERNAL(module, slotName);
 }
Exemplo n.º 12
0
        public Component Create(CGModule module, string context)
        {
            var go = module.Generator.PoolManager.GetPrefabPool(context).Pop();

            return(go.transform);
        }
Exemplo n.º 13
0
        public Component Create(CGModule module, string context)
        {
            var cmp = module.Generator.PoolManager.GetComponentPool <CGMeshResource>().Pop();

            return(cmp);
        }
Exemplo n.º 14
0
 public bool IsUsing(CGModule module)
 {
     return(ModuleID == module.UniqueID || TargetModuleID == module.UniqueID);
 }
Exemplo n.º 15
0
 public CGDataReference(CurvyGenerator generator, string moduleName, string slotName)
 {
     m_Module   = generator.GetModule(moduleName);
     m_SlotName = slotName;
 }
Exemplo n.º 16
0
 public CGDataReference(CGModule module, string slotName)
 {
     m_Module   = module;
     m_SlotName = slotName;
 }