示例#1
0
        // Awake ops
        void AwakeMethods()
        {
            // Create RayFire manager if not created
            RayfireMan.RayFireManInit();

            // Set components for mesh / skinned mesh / clusters
            SetComponentsBasic();

            // Set particles
            RFParticles.SetParticleComponents(this);

            // Init mesh root.
            if (SetRootMesh() == true)
            {
                return;
            }

            // Check for user mistakes
            RFLimitations.Checks(this);

            // Set components for mesh / skinned mesh / clusters
            SetComponentsPhysics();

            // Initialization Mesh input
            if (meshDemolition.meshInput == RFDemolitionMesh.MeshInputType.AtInitialization)
            {
                MeshInput();
            }

            // Precache meshes at awake
            AwakePrecache();

            // Prefragment object at awake
            AwakePrefragment();
        }
        void ClusterSetupUI()
        {
            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Setup Cluster", GUILayout.Height(25)))
            {
                if (Application.isPlaying == false)
                {
                    foreach (var targ in targets)
                    {
                        if (targ as RayfireRigid != null)
                        {
                            RFPhysic.DestroyColliders(targ as RayfireRigid);
                            (targ as RayfireRigid).clusterDemolition.cluster       = new RFCluster();
                            (targ as RayfireRigid).clusterDemolition.clsCount      = 1;
                            (targ as RayfireRigid).clusterDemolition.minorClusters = null;

                            (targ as RayfireRigid).SetComponentsBasic();
                            RFParticles.SetParticleComponents(targ as RayfireRigid);

                            if (RFDemolitionCluster.Clusterize(targ as RayfireRigid) == false)
                            {
                                Debug.Log("RayFire Rigid: " + (targ as RayfireRigid).name + " has no children with mesh.");
                            }
                            SetDirty(targ as RayfireRigid);
                        }
                    }
                }
            }

            if (GUILayout.Button("Reset Cluster", GUILayout.Height(25)))
            {
                if (Application.isPlaying == false)
                {
                    foreach (var targ in targets)
                    {
                        if (targ as RayfireRigid != null)
                        {
                            RFPhysic.DestroyColliders(targ as RayfireRigid);
                            (targ as RayfireRigid).clusterDemolition.cluster       = new RFCluster();
                            (targ as RayfireRigid).clusterDemolition.clsCount      = 1;
                            (targ as RayfireRigid).clusterDemolition.minorClusters = null;
                            SetDirty(targ as RayfireRigid);
                        }
                    }
                }
            }

            EditorGUILayout.EndHorizontal();
        }