예제 #1
0
 void OnEnable()
 {
     script = (IVPObjectData)target;
 }
예제 #2
0
    static void PrePaint(RaycastHit hitData)
    {
        //Get Data from the object.
        if (IVPVariables.Data.ActualObject == hitData.collider.gameObject)
        {
            return;
        }
        MeshFilter          meshFilter       = hitData.collider.gameObject.GetComponent <MeshFilter>();
        SkinnedMeshRenderer skinMeshRenderer = hitData.collider.gameObject.GetComponent <SkinnedMeshRenderer>();
        IVPObjectData       objectProperties = hitData.collider.gameObject.GetComponent <IVPObjectData>();

        //Add Object Properties if it's missing
        if (objectProperties == null)
        {
            objectProperties            = hitData.collider.gameObject.AddComponent <IVPObjectData>();
            objectProperties.instanceID = objectProperties.GetInstanceID();
        }

        //Instance
        if (IVPController.IVPData.saveMode == SaveMode.Instance)
        {
            Mesh meshInstance = null;

            if (meshFilter != null)
            {
                if (!objectProperties.instance || objectProperties.instance && objectProperties.instanceID != objectProperties.GetInstanceID())
                {
                    meshFilter.sharedMesh     = Instantiate(meshFilter.sharedMesh) as Mesh;
                    meshInstance              = meshFilter.sharedMesh;
                    meshInstance.name         = meshFilter.sharedMesh.name;
                    objectProperties.instance = true;
                }
                else
                {
                    meshInstance = meshFilter.sharedMesh;
                }

                IVPVariables.Data.ActualMesh = meshInstance;
            }
            else if (skinMeshRenderer != null)
            {
                if (!objectProperties.instance || objectProperties.instance && objectProperties.instanceID != objectProperties.GetInstanceID())
                {
                    meshInstance              = Instantiate(skinMeshRenderer.sharedMesh) as Mesh;
                    meshInstance.name         = skinMeshRenderer.sharedMesh.name;
                    objectProperties.instance = true;
                }
                else
                {
                    meshInstance = skinMeshRenderer.sharedMesh;
                }
            }

            objectProperties.instanceID = objectProperties.GetInstanceID();
            objectProperties.instance   = true;
        }

        //Asset
        if (IVPController.IVPData.saveMode == SaveMode.Asset)
        {
            Mesh meshClone = null;

            if (meshFilter != null)
            {
                meshClone = Mesh.Instantiate(meshFilter.sharedMesh) as Mesh;
            }
            else if (skinMeshRenderer != null)
            {
                meshClone = Mesh.Instantiate(skinMeshRenderer.sharedMesh) as Mesh;
            }

            meshClone.name = meshFilter.sharedMesh.name;
            objectProperties.instanceID = objectProperties.GetInstanceID();
            objectProperties.instance   = true;
        }
    }