Esempio 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));
            }
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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);
            }
        }
Esempio 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 + "'");
     }
 }
Esempio 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);
     }
 }
Esempio 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);
         }
     }
 }
Esempio 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);
         }
     }
 }
Esempio n. 9
0
 public void setINTERNAL(CurvyGenerator generator, string moduleName, string slotName)
 {
     m_Module   = generator.GetModule(moduleName);
     m_SlotName = slotName;
     mSlot      = null;
 }
Esempio n. 10
0
        /*! \cond PRIVATE */

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

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

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